| 203 | } |
| 204 | |
| 205 | void TestKdevFormatSource::testWildcardPathMatching() |
| 206 | { |
| 207 | QFETCH(QStringList, formatDirs); |
| 208 | QFETCH(QByteArrayList, formatContents); |
| 209 | QFETCH(QStringList, unmatchedPaths); |
| 210 | QFETCH(QStringList, matchedPaths); |
| 211 | |
| 212 | QTemporaryDir tmpDir; |
| 213 | QVERIFY2(tmpDir.isValid(), qPrintable("couldn't create temporary directory: " + tmpDir.errorString())); |
| 214 | |
| 215 | using FilesystemHelpers::makeAbsoluteCreateAndWrite; |
| 216 | |
| 217 | for (auto& dir : formatDirs) { |
| 218 | dir = QFileInfo{QDir{dir}, "format_sources"}.filePath(); |
| 219 | } |
| 220 | QString errorPath = makeAbsoluteCreateAndWrite(tmpDir.path(), formatDirs, formatContents); |
| 221 | QVERIFY2(errorPath.isEmpty(), qPrintable("couldn't create or write to temporary file or directory " + errorPath)); |
| 222 | |
| 223 | errorPath = makeAbsoluteCreateAndWrite(tmpDir.path(), unmatchedPaths); |
| 224 | if (errorPath.isEmpty()) { |
| 225 | errorPath = makeAbsoluteCreateAndWrite(tmpDir.path(), matchedPaths); |
| 226 | } |
| 227 | QVERIFY2(errorPath.isEmpty(), qPrintable("couldn't create temporary file or directory " + errorPath)); |
| 228 | |
| 229 | bool expectedFormattingResult = false; // for unmatchedPaths |
| 230 | for (const auto& paths : { unmatchedPaths, matchedPaths }) { |
| 231 | for (const auto& path : paths) { |
| 232 | QVERIFY2(QFileInfo{path}.isFile(), qPrintable(path + ": file was not created or was deleted")); |
| 233 | const QString error = applyFormatting(path, expectedFormattingResult); |
| 234 | QVERIFY2(error.isEmpty(), qPrintable(error)); |
| 235 | } |
| 236 | expectedFormattingResult = true; // for matchedPaths |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | bool TestKdevFormatSource::initTest(const QStringList& formatFileData) |
| 241 | { |
nothing calls this directly
no test coverage detected