Changeset View
Changeset View
Standalone View
Standalone View
projectmanagers/cmake/cmakeutils.cpp
Show First 20 Lines • Show All 637 Lines • ▼ Show 20 Line(s) | 627 | { | |||
---|---|---|---|---|---|
638 | return defGen; | 638 | return defGen; | ||
639 | } | 639 | } | ||
640 | 640 | | |||
641 | QVector<Test> importTestSuites(const Path &buildDir) | 641 | QVector<Test> importTestSuites(const Path &buildDir) | ||
642 | { | 642 | { | ||
643 | const auto contents = CMakeListsParser::readCMakeFile(buildDir.toLocalFile() + "/CTestTestfile.cmake"); | 643 | const auto contents = CMakeListsParser::readCMakeFile(buildDir.toLocalFile() + "/CTestTestfile.cmake"); | ||
644 | 644 | | |||
645 | QVector<Test> tests; | 645 | QVector<Test> tests; | ||
646 | QVector<QString> subdirs; | | |||
647 | for (const auto& entry: contents) { | 646 | for (const auto& entry: contents) { | ||
648 | if (entry.name == QLatin1String("add_test")) { | 647 | if (entry.name == QLatin1String("add_test")) { | ||
649 | auto args = entry.arguments; | 648 | auto args = entry.arguments; | ||
650 | 649 | | |||
651 | Test test; | 650 | Test test; | ||
652 | test.name = args.takeFirst().value; | 651 | test.name = args.takeFirst().value; | ||
653 | test.executable = args.takeFirst().value; | 652 | test.executable = args.takeFirst().value; | ||
654 | test.arguments = kTransform<QStringList>(args, [](const CMakeFunctionArgument& arg) { return arg.value; }); | 653 | test.arguments = kTransform<QStringList>(args, [](const CMakeFunctionArgument& arg) { return arg.value; }); | ||
655 | tests += test; | 654 | tests += test; | ||
656 | } else if (entry.name == QLatin1String("subdirs")) { | 655 | } else if (entry.name == QLatin1String("subdirs")) { | ||
657 | tests += importTestSuites(Path(buildDir, entry.arguments.constFirst().value)); | 656 | tests += importTestSuites(Path(buildDir, entry.arguments.constFirst().value)); | ||
657 | } else if (entry.name == QLatin1String("set_tests_properties")) { | ||||
658 | if(entry.arguments.count() < 4 || entry.arguments.count() % 2) { | ||||
659 | qCWarning(CMAKE) << "found set_tests_properties() with unexpected number of arguments:" | ||||
660 | << entry.arguments.count(); | ||||
661 | continue; | ||||
662 | } | ||||
663 | if (tests.isEmpty() || entry.arguments.constFirst().value != tests.constLast().name) { | ||||
664 | qCWarning(CMAKE) << "found set_tests_properties(" << entry.arguments.constFirst().value | ||||
665 | << " ...), but expected test " << tests.constLast().name; | ||||
666 | continue; | ||||
667 | } | ||||
668 | if (entry.arguments[1].value != QLatin1String("PROPERTIES")) { | ||||
669 | qCWarning(CMAKE) << "found set_tests_properties(" << entry.arguments.constFirst().value | ||||
670 | << entry.arguments.at(1).value << "...), but expected PROPERTIES as second argument"; | ||||
671 | continue; | ||||
672 | } | ||||
673 | Test &test = tests.last(); | ||||
674 | for (int i = 2; i < entry.arguments.count(); i += 2) | ||||
675 | test.properties[entry.arguments[i].value] = entry.arguments[i + 1].value; | ||||
658 | } | 676 | } | ||
659 | } | 677 | } | ||
660 | 678 | | |||
661 | return tests; | 679 | return tests; | ||
662 | } | 680 | } | ||
663 | 681 | | |||
664 | } | 682 | } | ||
665 | |