MCPcopy Create free account
hub / github.com/KDE/kdevelop / TestCMakeFileApi

Class TestCMakeFileApi

plugins/cmake/tests/test_cmakefileapi.cpp:33–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31using namespace KDevelop;
32
33class TestCMakeFileApi : public QObject
34{
35 Q_OBJECT
36
37private Q_SLOTS:
38 void initTestCase()
39 {
40 QLoggingCategory::setFilterRules(QStringLiteral("default.debug=true\nkdevelop.projectmanagers.cmake.debug=true\n"));
41
42 if (!CMake::FileApi::supported(CMake::findExecutable())) {
43 QSKIP("cmake exe doesn't support file API");
44 }
45
46 AutoTestShell::init({"KDevCMakeManager", "KDevCMakeBuilder", "KDevMakeBuilder", "KDevStandardOutputView"});
47 TestCore::initialize();
48 }
49
50 void cleanupTestCase()
51 {
52 TestCore::shutdown();
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);

Callers

nothing calls this directly

Calls 5

supportedFunction · 0.85
initializeFunction · 0.85
initTestCaseFunction · 0.50
findExecutableFunction · 0.50
initClass · 0.50

Tested by

no test coverage detected