diff --git a/projectmanagers/cmake/testing/ctestutils.cpp b/projectmanagers/cmake/testing/ctestutils.cpp index 3191d218cf..8cfeedb1a1 100644 --- a/projectmanagers/cmake/testing/ctestutils.cpp +++ b/projectmanagers/cmake/testing/ctestutils.cpp @@ -1,68 +1,61 @@ /* This file is part of KDevelop Copyright 2012 Miha Čančula CTestTestfile.cmake parsing uses code from the xUnit plugin Copyright 2008 Manuel Breugelmans Copyright 2010 Daniel Calviño Sánchez This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "ctestutils.h" #include "ctestsuite.h" #include "ctestfindjob.h" #include #include #include #include #include #include #include #include using namespace KDevelop; #pragma message("TODO: we are lacking introspection into targets, to see what files belong to each target.") static CMakeTarget targetByName(const QHash< KDevelop::Path, QVector>& targets, const QString& name) { for (const auto &subdir: targets.values()) { for (const auto &target: subdir) { if (target.name == name) return target; } } return {}; } void CTestUtils::createTestSuites(const QVector& testSuites, const QHash< KDevelop::Path, QVector>& targets, KDevelop::IProject* project) { -// IProject* project = folder->project(); -// IBuildSystemManager* bsm = project->buildSystemManager(); -// const QString binDir = bsm->buildDirectory(folder->project()->projectItem()).toLocalFile(); -// const Path currentBinDir = bsm->buildDirectory(folder); -// const Path currentSourceDir = folder->path(); -// QList items = bsm->targets(folder); - foreach (const Test& test, testSuites) { const auto target = targetByName(targets, test.executable); const bool willFail = test.properties.value(QStringLiteral("WILL_FAIL"), QStringLiteral("FALSE")) == QLatin1String("TRUE"); CTestSuite* suite = new CTestSuite(test.name, target.artifacts.constFirst(), {}, project, test.arguments, willFail); ICore::self()->runController()->registerJob(new CTestFindJob(suite)); } } diff --git a/projectmanagers/cmake/tests/test_ctestfindsuites.cpp b/projectmanagers/cmake/tests/test_ctestfindsuites.cpp index be43d32a98..e4661ba99a 100644 --- a/projectmanagers/cmake/tests/test_ctestfindsuites.cpp +++ b/projectmanagers/cmake/tests/test_ctestfindsuites.cpp @@ -1,99 +1,97 @@ /* KDevelop CMake Support * * Copyright 2012 Miha Čančula * Copyright 2017 Kevin Funk * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. */ #include "test_ctestfindsuites.h" #include "testhelpers.h" #include "cmakeutils.h" #include "cmake-test-paths.h" #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace KDevelop; void waitForSuites(IProject* project, int count, int max) { auto testController = ICore::self()->testController(); for(int i = 0; testController->testSuitesForProject(project).size() < count && i < max * 10; ++i) { QSignalSpy spy(testController, &ITestController::testSuiteAdded); QVERIFY(spy.wait(1000)); } } void TestCTestFindSuites::initTestCase() { AutoTestShell::init({"kdevcmakemanager"}); TestCore::initialize(); cleanup(); } void TestCTestFindSuites::cleanup() { foreach(IProject* p, ICore::self()->projectController()->projects()) { ICore::self()->projectController()->closeProject(p); } QVERIFY(ICore::self()->projectController()->projects().isEmpty()); } void TestCTestFindSuites::cleanupTestCase() { TestCore::shutdown(); } void TestCTestFindSuites::testCTestSuite() { IProject* project = loadProject( "unit_tests" ); QVERIFY2(project, "Project was not opened"); waitForSuites(project, 5, 10); QList suites = ICore::self()->testController()->testSuitesForProject(project); QCOMPARE(suites.size(), 5); DUChainReadLocker locker(DUChain::lock()); foreach (auto suite, suites) { QCOMPARE(suite->cases(), QStringList()); QVERIFY(!suite->declaration().isValid()); CTestSuite* ctestSuite = (CTestSuite*)(suite); const auto buildDir = Path(CMake::allBuildDirs(project).at(0)); QString exeSubdir = buildDir.relativePath(ctestSuite->executable().parent()); - //Support for custom RUNTIME_OUTPUT_DIRECTORY target prop is broken - //QCOMPARE(exeSubdir, ctestSuite->name() == "fail" ? QString("build/bin") : QString("build") ); - QCOMPARE(exeSubdir, ctestSuite->name() == "test_five" ? QString("five") : QString()); + QCOMPARE(exeSubdir, ctestSuite->name() == "fail" ? QStringLiteral("bin") : QString() ); } } QTEST_MAIN(TestCTestFindSuites)