Commit 2aa50fdd authored by Milian Wolff's avatar Milian Wolff
Browse files

Unbreak test_qmakeproject

The test was... completely broken? I really have no clue how it
could have ever worked. It tried to lookup the target item by its
path, but targets have no path. And definitely not a path in the
build dir?

Furthermore, for subdirs we don't have an "all" target, we only
have the individual targets for dir_a and dir_b...

Adapt the test such that it works. Quite frankly noone should be
using QMake anyways, and I spend far too much time on QMake here.
Let's just make it pass and be done with it for now...
parent 1c248f8e
Pipeline #192236 passed with stage
in 24 minutes and 55 seconds
......@@ -29,6 +29,26 @@ QTEST_MAIN(TestQMakeProject)
using namespace KDevelop;
namespace
{
ProjectTargetItem* findTarget(const ProjectFolderItem* folder, const QString& name)
{
const auto items = folder->children();
for (const auto* item : items) {
if (item->target() && item->baseName() == name) {
return item->target();
} else if (item->folder()) {
auto ret = findTarget(item->folder(), name);
if (ret) {
return ret;
}
}
}
return nullptr;
}
}
TestQMakeProject::TestQMakeProject(QObject* parent)
: QObject(parent)
{
......@@ -62,12 +82,12 @@ void TestQMakeProject::testBuildDirectory_data()
QTest::newRow("Basic Project") << "basic_project"
<< ""
<< "";
QTest::newRow("Subdirs Project (root)") << "subdirs_project"
<< ""
<< "";
QTest::newRow("Subdirs Project (dir_a)") << "subdirs_project"
<< "dir_a"
<< "dir_a";
QTest::newRow("Subdirs Project (dir_b)") << "subdirs_project"
<< "dir_b"
<< "dir_b";
}
void TestQMakeProject::testBuildDirectory()
......@@ -116,15 +136,12 @@ void TestQMakeProject::testBuildDirectory()
// adds expected directory to our base path
const Path expectedPath(Path{m_buildDir.path()}, expected);
// path for files to build
Path buildUrl(QStringLiteral("%1/%2/%3").arg(QMAKE_TESTS_PROJECTS_DIR, projectName, target));
QList<ProjectFolderItem*> buildItems = project->foldersForPath(IndexedString(buildUrl.pathOrUrl()));
QCOMPARE(buildItems.size(), 1);
IBuildSystemManager* buildManager = project->buildSystemManager();
const auto buildFolder = buildItems.first();
auto targetItem = findTarget(project->projectItem(), target.isEmpty() ? projectName : target);
QVERIFY(targetItem);
const Path actual = buildManager->buildDirectory(buildFolder);
IBuildSystemManager* buildManager = project->buildSystemManager();
const Path actual = buildManager->buildDirectory(targetItem);
QCOMPARE(actual, expectedPath);
auto buildJob = buildManager->builder()->configure(project);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment