Changeset View
Changeset View
Standalone View
Standalone View
plugins/cmake/cmakeutils.cpp
Show First 20 Lines • Show All 685 Lines • ▼ Show 20 Line(s) | 685 | { | |||
---|---|---|---|---|---|
686 | qCWarning(CMAKE) << "Couldn't find builder with index " << CMakeBuilderSettings::self()->generator() | 686 | qCWarning(CMAKE) << "Couldn't find builder with index " << CMakeBuilderSettings::self()->generator() | ||
687 | << ", defaulting to 0"; | 687 | << ", defaulting to 0"; | ||
688 | CMakeBuilderSettings::self()->setGenerator(0); | 688 | CMakeBuilderSettings::self()->setGenerator(0); | ||
689 | defGen = generatorNames.at(0); | 689 | defGen = generatorNames.at(0); | ||
690 | } | 690 | } | ||
691 | return defGen; | 691 | return defGen; | ||
692 | } | 692 | } | ||
693 | 693 | | |||
694 | QVector<Test> importTestSuites(const Path &buildDir) | 694 | QVector<Test> importTestSuites(const Path &buildDir, const QString &cmakeTestFileName) | ||
mwolff: then add this function here (with the style fixes mentioned above), and have importTestSuites… | |||||
Do you want importTestSuites(buildDir, QStringLiteral("CTestTestfile.cmake")) also exported in the .h file? tnorth: Do you want importTestSuites(buildDir, QStringLiteral("CTestTestfile.cmake")) also exported in… | |||||
695 | { | 695 | { | ||
696 | const auto contents = CMakeListsParser::readCMakeFile(buildDir.toLocalFile() + QLatin1String("/CTestTestfile.cmake")); | 696 | const auto cmakeTestFile = Path(buildDir, cmakeTestFileName).toLocalFile() ; | ||
mwolff: const and lower-case the start | |||||
mwolff: style: remove spaces before; | |||||
697 | const auto contents = CMakeListsParser::readCMakeFile(cmakeTestFile); | ||||
697 | 698 | | |||
698 | QVector<Test> tests; | 699 | QVector<Test> tests; | ||
699 | for (const auto& entry: contents) { | 700 | for (const auto& entry: contents) { | ||
700 | if (entry.name == QLatin1String("add_test")) { | 701 | if (entry.name == QLatin1String("add_test")) { | ||
701 | auto args = entry.arguments; | 702 | auto args = entry.arguments; | ||
702 | | ||||
703 | Test test; | 703 | Test test; | ||
704 | test.name = args.takeFirst().value; | 704 | test.name = args.takeFirst().value; | ||
705 | test.executable = args.takeFirst().value; | 705 | test.executable = args.takeFirst().value; | ||
706 | test.arguments = kTransform<QStringList>(args, [](const CMakeFunctionArgument& arg) { return arg.value; }); | 706 | test.arguments = kTransform<QStringList>(args, [](const CMakeFunctionArgument& arg) { return arg.value; }); | ||
707 | tests += test; | 707 | tests += test; | ||
708 | } else if (entry.name == QLatin1String("subdirs")) { | 708 | } else if (entry.name == QLatin1String("subdirs")) { | ||
709 | tests += importTestSuites(Path(buildDir, entry.arguments.first().value)); | 709 | tests += importTestSuites(Path(buildDir, entry.arguments.first().value)); | ||
710 | } else if (entry.name == QLatin1String("include")) { | ||||
711 | // Include directive points directly to a .cmake file hosting the tests | ||||
712 | tests += importTestSuites(Path(buildDir, entry.arguments.first().value), QString()); | ||||
710 | } else if (entry.name == QLatin1String("set_tests_properties")) { | 713 | } else if (entry.name == QLatin1String("set_tests_properties")) { | ||
711 | if(entry.arguments.count() < 4 || entry.arguments.count() % 2) { | 714 | if(entry.arguments.count() < 4 || entry.arguments.count() % 2) { | ||
mwolff: `QString()` or `{}` instead of empty string literal | |||||
712 | qCWarning(CMAKE) << "found set_tests_properties() with unexpected number of arguments:" | 715 | qCWarning(CMAKE) << "found set_tests_properties() with unexpected number of arguments:" | ||
713 | << entry.arguments.count(); | 716 | << entry.arguments.count(); | ||
714 | continue; | 717 | continue; | ||
715 | } | 718 | } | ||
716 | if (tests.isEmpty() || entry.arguments.first().value != tests.last().name) { | 719 | if (tests.isEmpty() || entry.arguments.first().value != tests.last().name) { | ||
717 | qCWarning(CMAKE) << "found set_tests_properties(" << entry.arguments.first().value | 720 | qCWarning(CMAKE) << "found set_tests_properties(" << entry.arguments.first().value | ||
718 | << " ...), but expected test " << tests.last().name; | 721 | << " ...), but expected test " << tests.last().name; | ||
719 | continue; | 722 | continue; | ||
720 | } | 723 | } | ||
721 | if (entry.arguments[1].value != QLatin1String("PROPERTIES")) { | 724 | if (entry.arguments[1].value != QLatin1String("PROPERTIES")) { | ||
722 | qCWarning(CMAKE) << "found set_tests_properties(" << entry.arguments.first().value | 725 | qCWarning(CMAKE) << "found set_tests_properties(" << entry.arguments.first().value | ||
723 | << entry.arguments.at(1).value << "...), but expected PROPERTIES as second argument"; | 726 | << entry.arguments.at(1).value << "...), but expected PROPERTIES as second argument"; | ||
724 | continue; | 727 | continue; | ||
725 | } | 728 | } | ||
726 | Test &test = tests.last(); | 729 | Test &test = tests.last(); | ||
727 | for (int i = 2; i < entry.arguments.count(); i += 2) | 730 | for (int i = 2; i < entry.arguments.count(); i += 2) | ||
728 | test.properties[entry.arguments[i].value] = entry.arguments[i + 1].value; | 731 | test.properties[entry.arguments[i].value] = entry.arguments[i + 1].value; | ||
729 | } | 732 | } | ||
730 | } | 733 | } | ||
731 | 734 | | |||
732 | return tests; | 735 | return tests; | ||
733 | } | 736 | } | ||
734 | 737 | | |||
738 | QVector<Test> importTestSuites(const Path &buildDir) { | ||||
mwolff: style: move { to its own line for function bodies | |||||
739 | return importTestSuites(buildDir, QStringLiteral("CTestTestfile.cmake")); | ||||
740 | } | ||||
741 | | ||||
735 | } | 742 | } |
then add this function here (with the style fixes mentioned above), and have importTestSuites defer to it via