| 91 | } |
| 92 | |
| 93 | void TestQMakeProject::testBuildDirectory() |
| 94 | { |
| 95 | QFETCH(QString, projectName); |
| 96 | QFETCH(QString, target); |
| 97 | QFETCH(QString, expected); |
| 98 | |
| 99 | const auto projects = ICore::self()->projectController()->projects(); |
| 100 | for (IProject* p : projects) { |
| 101 | ICore::self()->projectController()->closeProject(p); |
| 102 | } |
| 103 | |
| 104 | // setup project config, to avoid build dir chooser dialog popping up |
| 105 | { |
| 106 | // note: all checks from QMakeProjectManager::projectNeedsConfiguration must be satisfied |
| 107 | const QString fileName |
| 108 | = QStringLiteral("%1/%2/.kdev4/%2.kdev4").arg(QMAKE_TESTS_PROJECTS_DIR, projectName); |
| 109 | |
| 110 | KConfig cfg(fileName); |
| 111 | KConfigGroup group(&cfg, QMakeConfig::CONFIG_GROUP()); |
| 112 | |
| 113 | group.writeEntry(QMakeConfig::BUILD_FOLDER, m_buildDir.path()); |
| 114 | group.writeEntry(QMakeConfig::QMAKE_EXECUTABLE, QMAKE_TESTS_QMAKE_EXECUTABLE); |
| 115 | group.sync(); |
| 116 | |
| 117 | /// create subgroup for one build dir |
| 118 | KConfigGroup buildDirGroup = KConfigGroup(&cfg, QMakeConfig::CONFIG_GROUP()).group(m_buildDir.path()); |
| 119 | buildDirGroup.writeEntry(QMakeConfig::QMAKE_EXECUTABLE, QMAKE_TESTS_QMAKE_EXECUTABLE); |
| 120 | buildDirGroup.sync(); |
| 121 | |
| 122 | QVERIFY(QFileInfo::exists(fileName)); |
| 123 | } |
| 124 | |
| 125 | // opens project with kdevelop |
| 126 | const QUrl projectUrl = QUrl::fromLocalFile( |
| 127 | QStringLiteral("%1/%2/%2.kdev4").arg(QMAKE_TESTS_PROJECTS_DIR, projectName)); |
| 128 | ICore::self()->projectController()->openProject(projectUrl); |
| 129 | |
| 130 | // wait for loading finished |
| 131 | QSignalSpy spy(ICore::self()->projectController(), SIGNAL(projectOpened(KDevelop::IProject*))); |
| 132 | bool gotSignal = spy.wait(30000); |
| 133 | QVERIFY2(gotSignal, "Timeout while waiting for opened signal"); |
| 134 | |
| 135 | IProject* project = ICore::self()->projectController()->findProjectByName(projectName); |
| 136 | |
| 137 | // adds expected directory to our base path |
| 138 | const Path expectedPath(Path{m_buildDir.path()}, expected); |
| 139 | |
| 140 | auto targetItem = findTarget(project->projectItem(), target.isEmpty() ? projectName : target); |
| 141 | QVERIFY(targetItem); |
| 142 | |
| 143 | IBuildSystemManager* buildManager = project->buildSystemManager(); |
| 144 | |
| 145 | const Path actual = buildManager->buildDirectory(targetItem); |
| 146 | QCOMPARE(actual, expectedPath); |
| 147 | |
| 148 | auto buildJob = buildManager->builder()->configure(project); |
| 149 | QVERIFY(buildJob->exec()); |
| 150 | } |
nothing calls this directly
no test coverage detected