| 53 | } |
| 54 | |
| 55 | void testConfigure() |
| 56 | { |
| 57 | auto project = loadProject(QStringLiteral("single_subdirectory")); |
| 58 | QVERIFY(project); |
| 59 | |
| 60 | auto bsm = project->buildSystemManager(); |
| 61 | const auto buildPath = bsm->buildDirectory(project->projectItem()); |
| 62 | const auto buildDir = buildPath.toLocalFile(); |
| 63 | QVERIFY(!buildDir.isEmpty()); |
| 64 | QVERIFY(QDir(buildDir).removeRecursively()); |
| 65 | |
| 66 | auto builder = bsm->builder(); |
| 67 | auto configureJob = builder->configure(project); |
| 68 | QVERIFY(configureJob); |
| 69 | QVERIFY(configureJob->exec()); |
| 70 | |
| 71 | const auto index = CMake::FileApi::findReplyIndexFile(buildDir); |
| 72 | QVERIFY(index.isValid()); |
| 73 | QVERIFY(!index.isOutdated()); |
| 74 | |
| 75 | const auto projectData = CMake::FileApi::parseReplyIndexFile(index, project->path(), buildPath); |
| 76 | QVERIFY(projectData.compilationData.isValid); |
| 77 | QCOMPARE(projectData.targets.size(), 1); |
| 78 | const auto subDirPath = Path(project->path(), "subdir"); |
| 79 | QVERIFY(projectData.targets.contains(subDirPath)); |
| 80 | const auto targets = projectData.targets[subDirPath]; |
| 81 | QCOMPARE(targets.size(), 1); |
| 82 | const auto target = targets.first(); |
| 83 | QCOMPARE(target.name, QLatin1String("foo")); |
| 84 | QCOMPARE(target.type, CMakeTarget::Executable); |
| 85 | const auto buildSubDirPath = Path(buildPath, "subdir"); |
| 86 | QCOMPARE(target.artifacts, {Path(buildSubDirPath, "foo")}); |
| 87 | const auto fooSrcPath = Path(subDirPath, "foo.cpp"); |
| 88 | QCOMPARE(target.sources, {fooSrcPath}); |
| 89 | |
| 90 | QCOMPARE(projectData.compilationData.files.size(), 1); |
| 91 | QVERIFY(projectData.compilationData.files.contains(fooSrcPath)); |
| 92 | const auto srcInfo = projectData.compilationData.files[fooSrcPath]; |
| 93 | QCOMPARE(srcInfo.language, QLatin1String("CXX")); |
| 94 | QCOMPARE(srcInfo.includes.size(), 3); |
| 95 | QVERIFY(srcInfo.includes.contains(buildPath)); |
| 96 | QVERIFY(srcInfo.includes.contains(buildSubDirPath)); |
| 97 | QVERIFY(srcInfo.includes.contains(subDirPath)); |
| 98 | |
| 99 | QVERIFY(projectData.cmakeFiles.contains(Path(project->path(), "CMakeLists.txt"))); |
| 100 | QVERIFY(projectData.cmakeFiles.contains(Path(subDirPath, "CMakeLists.txt"))); |
| 101 | QCOMPARE(projectData.cmakeFiles.size(), 2); |
| 102 | |
| 103 | QVERIFY(!projectData.isOutdated); |
| 104 | } |
| 105 | }; |
| 106 | |
| 107 | QTEST_MAIN(TestCMakeFileApi) |
nothing calls this directly
no test coverage detected