diff options
author | Betsy McPhail <betsy.mcphail@kitware.com> | 2017-06-30 16:15:30 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-07-10 20:25:19 (GMT) |
commit | a70d8e93e82e1a8fa37b4c9c0b23210d5031fd75 (patch) | |
tree | cb9e9caf66ba49732e3f68acc21e259bb34c8388 /Tests | |
parent | 47b3a57c9bc5c7db608bc3b59b139a902535255f (diff) | |
download | CMake-a70d8e93e82e1a8fa37b4c9c0b23210d5031fd75.zip CMake-a70d8e93e82e1a8fa37b4c9c0b23210d5031fd75.tar.gz CMake-a70d8e93e82e1a8fa37b4c9c0b23210d5031fd75.tar.bz2 |
Add tests for new directory labels and labels-for-subprojects features
Diffstat (limited to 'Tests')
32 files changed, 483 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 246138b..e15dd6c 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -348,6 +348,7 @@ if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") list(APPEND CompilerLauncher_ARGS -DCMake_TEST_CUDA=${CMake_TEST_CUDA}) endif() add_RunCMake_test(CompilerLauncher) + add_RunCMake_test(ctest_labels_for_subprojects) endif() add_RunCMake_test_group(CPack "DEB;RPM;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ") diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CMakeLists.txt.in b/Tests/RunCMake/ctest_labels_for_subprojects/CMakeLists.txt.in new file mode 100644 index 0000000..30dd37e --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/CMakeLists.txt.in @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.9) +@CASE_CMAKELISTS_PREFIX_CODE@ +project(CTestLabelsForSubprojects@CASE_NAME@ NONE) +include(CTest) +@CASE_CMAKELISTS_SUFFIX_CODE@ diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfig.cmake.in b/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfig.cmake.in new file mode 100644 index 0000000..1e1905b --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfig.cmake.in @@ -0,0 +1,2 @@ +set(CTEST_PROJECT_NAME "CTestLabelsForSubprojects@CASE_NAME@") +@CTEST_EXTRA_CONFIG@ diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfigCTestScript-check.cmake b/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfigCTestScript-check.cmake new file mode 100644 index 0000000..ea05851 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfigCTestScript-check.cmake @@ -0,0 +1,36 @@ +set(EXPERIMENTAL_FEATURE_REGEX "<Subproject name=\"MyExperimentalFeature\">.*<Label>MyExperimentalFeature</Label>.*</Subproject>") +set(PRODUCTION_CODE_REGEX "<Subproject name=\"MyProductionCode\">.*<Label>MyProductionCode</Label>.*</Subproject>") +set(SUBPROJECTS_REGEX "${EXPERIMENTAL_FEATURE_REGEX}.*${PRODUCTION_CODE_REGEX}") + +file(GLOB configure_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Configure.xml") +if(configure_xml_file) + file(READ "${configure_xml_file}" configure_xml) + if(NOT configure_xml MATCHES "${SUBPROJECTS_REGEX}.*<Configure>") + set(RunCMake_TEST_FAILED "Configure.xml does not contain the expected list of subprojects") + endif() +else() + set(RunCMake_TEST_FAILED "Configure.xml not found") +endif() + +file(GLOB build_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Build.xml") +if(build_xml_file) + file(READ "${build_xml_file}" build_xml) + set(BUILD_WARNING_REGEX "<Failure type=\"Warning\">.*<Labels>.*<Label>MyExperimentalFeature</Label>.*</Labels>") + if(NOT build_xml MATCHES "${SUBPROJECTS_REGEX}.*<Build>.*${BUILD_ERROR_REGEX}.*</Build>") + set(RunCMake_TEST_FAILED "Build.xml does not contain the expected list of subprojects and labels") + endif() +else() + set(RunCMake_TEST_FAILED "Build.xml not found") +endif() + +file(GLOB test_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Test.xml") +if(test_xml_file) + file(READ "${test_xml_file}" test_xml) + set(TEST_FAILED_REGEX "<Test Status=\"failed\">.*<Labels>.*<Label>MyExperimentalFeature</Label>.*<Label>NotASubproject</Label>.*</Labels>") + set(TEST_PASSED_REGEX "<Test Status=\"passed\">.*<Labels>.*<Label>MyProductionCode</Label>.*</Labels>") + if(NOT test_xml MATCHES "${SUBPROJECTS_REGEX}.*<Testing>.*${TEST_FAILED_REGEX}.*${TEST_PASSED_REGEX}.*${TEST_NOTRUN_REGEX}.*</Testing>") + set(RunCMake_TEST_FAILED "Test.xml does not contain the expected list of subprojects and labels") + endif() +else() + set(RunCMake_TEST_FAILED "${CTEST_BINARY_DIRECTORY}/Testing/*/Test.xml not found") +endif() diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfigCTestScript-stdout.txt b/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfigCTestScript-stdout.txt new file mode 100644 index 0000000..ae00e51 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfigCTestScript-stdout.txt @@ -0,0 +1,7 @@ +17% tests passed, 5 tests failed out of 6 ++ +Subproject Time Summary: +MyExperimentalFeature += +[0-9.]+ sec \(5 tests\) +MyProductionCode += +[0-9.]+ sec \(1 test\) ++ +Total Test time \(real\) = +[0-9.]+ sec diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariable-check.cmake b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariable-check.cmake new file mode 100644 index 0000000..ea05851 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariable-check.cmake @@ -0,0 +1,36 @@ +set(EXPERIMENTAL_FEATURE_REGEX "<Subproject name=\"MyExperimentalFeature\">.*<Label>MyExperimentalFeature</Label>.*</Subproject>") +set(PRODUCTION_CODE_REGEX "<Subproject name=\"MyProductionCode\">.*<Label>MyProductionCode</Label>.*</Subproject>") +set(SUBPROJECTS_REGEX "${EXPERIMENTAL_FEATURE_REGEX}.*${PRODUCTION_CODE_REGEX}") + +file(GLOB configure_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Configure.xml") +if(configure_xml_file) + file(READ "${configure_xml_file}" configure_xml) + if(NOT configure_xml MATCHES "${SUBPROJECTS_REGEX}.*<Configure>") + set(RunCMake_TEST_FAILED "Configure.xml does not contain the expected list of subprojects") + endif() +else() + set(RunCMake_TEST_FAILED "Configure.xml not found") +endif() + +file(GLOB build_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Build.xml") +if(build_xml_file) + file(READ "${build_xml_file}" build_xml) + set(BUILD_WARNING_REGEX "<Failure type=\"Warning\">.*<Labels>.*<Label>MyExperimentalFeature</Label>.*</Labels>") + if(NOT build_xml MATCHES "${SUBPROJECTS_REGEX}.*<Build>.*${BUILD_ERROR_REGEX}.*</Build>") + set(RunCMake_TEST_FAILED "Build.xml does not contain the expected list of subprojects and labels") + endif() +else() + set(RunCMake_TEST_FAILED "Build.xml not found") +endif() + +file(GLOB test_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Test.xml") +if(test_xml_file) + file(READ "${test_xml_file}" test_xml) + set(TEST_FAILED_REGEX "<Test Status=\"failed\">.*<Labels>.*<Label>MyExperimentalFeature</Label>.*<Label>NotASubproject</Label>.*</Labels>") + set(TEST_PASSED_REGEX "<Test Status=\"passed\">.*<Labels>.*<Label>MyProductionCode</Label>.*</Labels>") + if(NOT test_xml MATCHES "${SUBPROJECTS_REGEX}.*<Testing>.*${TEST_FAILED_REGEX}.*${TEST_PASSED_REGEX}.*${TEST_NOTRUN_REGEX}.*</Testing>") + set(RunCMake_TEST_FAILED "Test.xml does not contain the expected list of subprojects and labels") + endif() +else() + set(RunCMake_TEST_FAILED "${CTEST_BINARY_DIRECTORY}/Testing/*/Test.xml not found") +endif() diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariable-stdout.txt b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariable-stdout.txt new file mode 100644 index 0000000..ae00e51 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariable-stdout.txt @@ -0,0 +1,7 @@ +17% tests passed, 5 tests failed out of 6 ++ +Subproject Time Summary: +MyExperimentalFeature += +[0-9.]+ sec \(5 tests\) +MyProductionCode += +[0-9.]+ sec \(1 test\) ++ +Total Test time \(real\) = +[0-9.]+ sec diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-check.cmake b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-check.cmake new file mode 100644 index 0000000..7beefba --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-check.cmake @@ -0,0 +1,34 @@ +set(THIRD_PARTY_REGEX "<Subproject name=\"MyThirdPartyDependency\">.*<Label>MyThirdPartyDependency</Label>.*</Subproject>") +set(SUBPROJECTS_REGEX "${THIRD_PARTY_REGEX}") + +file(GLOB configure_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Configure.xml") +if(configure_xml_file) + file(READ "${configure_xml_file}" configure_xml) + if(NOT configure_xml MATCHES "${SUBPROJECTS_REGEX}.*<Configure>") + set(RunCMake_TEST_FAILED "Configure.xml does not contain the expected list of subprojects") + endif() +else() + set(RunCMake_TEST_FAILED "Configure.xml not found") +endif() + +file(GLOB build_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Build.xml") +if(build_xml_file) + file(READ "${build_xml_file}" build_xml) + set(BUILD_ERROR_REGEX "<Failure type=\"Error\">.*<Labels>.*<Label>MyThirdPartyDependency</Label>.*<Label>NotASubproject</Label>.*</Labels>") + if(NOT build_xml MATCHES "${SUBPROJECTS_REGEX}.*<Build>.*${BUILD_ERROR_REGEX}.*</Build>") + set(RunCMake_TEST_FAILED "Build.xml does not contain the expected list of subprojects and labels") + endif() +else() + set(RunCMake_TEST_FAILED "Build.xml not found") +endif() + +file(GLOB test_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Test.xml") +if(test_xml_file) + file(READ "${test_xml_file}" test_xml) + set(TEST_NOTRUN_REGEX "<Test Status=\"notrun\">.*<Labels>.*<Label>MyThirdPartyDependency</Label>.*<Label>NotASubproject</Label>.*</Labels>") + if(NOT test_xml MATCHES "${SUBPROJECTS_REGEX}.*<Testing>.*${TEST_FAILED_REGEX}.*${TEST_PASSED_REGEX}.*${TEST_NOTRUN_REGEX}.*</Testing>") + set(RunCMake_TEST_FAILED "Test.xml does not contain the expected list of subprojects and labels") + endif() +else() + set(RunCMake_TEST_FAILED "${CTEST_BINARY_DIRECTORY}/Testing/*/Test.xml not found") +endif() diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-result.txt b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-stderr.txt b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-stderr.txt new file mode 100644 index 0000000..38566fb --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-stderr.txt @@ -0,0 +1 @@ +Unable to find executable:.*MyThirdPartyDependency/src/thirdparty diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-stdout.txt b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-stdout.txt new file mode 100644 index 0000000..a78a99a --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-stdout.txt @@ -0,0 +1,6 @@ +0% tests passed, 1 tests failed out of 1 ++ +Subproject Time Summary: +MyThirdPartyDependency += +[0-9.]+ sec \(1 test\) ++ +Total Test time \(real\) = +[0-9.]+ sec diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-result.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-result.txt new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-stderr.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-stderr.txt new file mode 100644 index 0000000..ba4235d --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-stderr.txt @@ -0,0 +1 @@ +Errors while running CTest diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-stdout.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-stdout.txt new file mode 100644 index 0000000..b5d76a9 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-stdout.txt @@ -0,0 +1,6 @@ +50% tests passed, 1 tests failed out of 2 ++ +Subproject Time Summary: +MySubproject += +[0-9.]+ sec \(2 tests\) ++ +Total Test time \(real\) = +[0-9.]+ sec diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-result.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-result.txt new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-stderr.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-stderr.txt new file mode 100644 index 0000000..ba4235d --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-stderr.txt @@ -0,0 +1 @@ +Errors while running CTest diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-stdout.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-stdout.txt new file mode 100644 index 0000000..01851fd --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-stdout.txt @@ -0,0 +1,6 @@ +67% tests passed, 1 tests failed out of 3 ++ +Subproject Time Summary: +MySubproject += +[0-9.]+ sec \(2 tests\) ++ +Total Test time \(real\) = +[0-9.]+ sec diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-result.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-result.txt new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-stderr.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-stderr.txt new file mode 100644 index 0000000..ba4235d --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-stderr.txt @@ -0,0 +1 @@ +Errors while running CTest diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-stdout.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-stdout.txt new file mode 100644 index 0000000..0209bfe --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-stdout.txt @@ -0,0 +1,7 @@ +67% tests passed, 1 tests failed out of 3 ++ +Label Time Summary: +MySubproject += +[0-9.]+ sec \(2 tests\) +NotASubproject += +[0-9.]+ sec \(1 test\) ++ +Total Test time \(real\) = +[0-9.]+ sec diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-result.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-result.txt new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-stderr.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-stderr.txt new file mode 100644 index 0000000..ba4235d --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-stderr.txt @@ -0,0 +1 @@ +Errors while running CTest diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-stdout.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-stdout.txt new file mode 100644 index 0000000..b5d76a9 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-stdout.txt @@ -0,0 +1,6 @@ +50% tests passed, 1 tests failed out of 2 ++ +Subproject Time Summary: +MySubproject += +[0-9.]+ sec \(2 tests\) ++ +Total Test time \(real\) = +[0-9.]+ sec diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/MyExperimentalFeature/CMakeLists.txt b/Tests/RunCMake/ctest_labels_for_subprojects/MyExperimentalFeature/CMakeLists.txt new file mode 100644 index 0000000..cc07a07 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/MyExperimentalFeature/CMakeLists.txt @@ -0,0 +1,33 @@ +project(MyExperimentalFeature) +cmake_minimum_required(VERSION 3.8) + +include(CTest) + +set(CMAKE_DIRECTORY_LABELS "MyExperimentalFeature;NotASubproject") + +add_executable(testapp experimental.c) + +add_test(experimentalFail1 testapp 5) +set_tests_properties (experimentalFail1 + PROPERTIES PASS_REGULAR_EXPRESSION "Test!" + ) + +add_test(experimentalFail2 testapp -5) +set_tests_properties (experimentalFail2 + PROPERTIES PASS_REGULAR_EXPRESSION "Test!" + ) + +add_test(experimentalFail3 testapp -5) +set_tests_properties (experimentalFail3 + PROPERTIES PASS_REGULAR_EXPRESSION "Test!" + ) + +add_test(experimentalFail4 testapp -5) +set_tests_properties (experimentalFail4 + PROPERTIES PASS_REGULAR_EXPRESSION "Test!" + ) + +add_test(experimentalFail5 testapp -5) +set_tests_properties (experimentalFail5 + PROPERTIES PASS_REGULAR_EXPRESSION "Test!" + ) diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/MyExperimentalFeature/experimental.c b/Tests/RunCMake/ctest_labels_for_subprojects/MyExperimentalFeature/experimental.c new file mode 100644 index 0000000..7cb11ae --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/MyExperimentalFeature/experimental.c @@ -0,0 +1,16 @@ +#include <stdio.h> + +int main(void) +{ + int i = 0; + if (i > 0) { + printf("This doesn't happen.\n"); + printf("Neither does this.\n"); + } + i = i + 1; + if (i > 0) { + printf("This does happen.\n"); + } + + return 0; +} diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/MyProductionCode/CMakeLists.txt b/Tests/RunCMake/ctest_labels_for_subprojects/MyProductionCode/CMakeLists.txt new file mode 100644 index 0000000..c2ee673 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/MyProductionCode/CMakeLists.txt @@ -0,0 +1,12 @@ +project(MyProductionCode) +cmake_minimum_required(VERSION 3.8) + +include(CTest) + +add_executable(production production.c) +add_test(NAME production COMMAND production) + +set_property(TARGET production PROPERTY LABELS MyProductionCode) +set_property(TEST production PROPERTY LABELS MyProductionCode) + +set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY LABELS "NotASubproject") diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/MyProductionCode/production.c b/Tests/RunCMake/ctest_labels_for_subprojects/MyProductionCode/production.c new file mode 100644 index 0000000..54dc2be --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/MyProductionCode/production.c @@ -0,0 +1,16 @@ +#include <stdio.h> + +int main(void) +{ + int j = 0; + if (j > 0) { + printf("This doesn't happen.\n"); + printf("Neither does this.\n"); + } + j = j + 1; + if (j > 0) { + printf("This does happen.\n"); + } + + return 0; +} diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/CMakeLists.txt b/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/CMakeLists.txt new file mode 100644 index 0000000..d5b9c2f --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/CMakeLists.txt @@ -0,0 +1,7 @@ +project(MyThirdPartyDependency) +cmake_minimum_required(VERSION 3.8) + +include(CTest) + +set_directory_properties(PROPERTIES LABELS "NotASubproject;MyThirdPartyDependency") +add_subdirectory(src) diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/src/CMakeLists.txt b/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/src/CMakeLists.txt new file mode 100644 index 0000000..dc6cb2a --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/src/CMakeLists.txt @@ -0,0 +1,10 @@ +project(MyThirdPartyDependency) +cmake_minimum_required(VERSION 3.8) + +include(CTest) + +add_executable(thirdparty thirdparty.c) +add_test(NAME thirdparty COMMAND thirdparty) + +set_property(TARGET thirdparty PROPERTY LABELS NotASubproject) +set_property(TEST thirdparty PROPERTY LABELS NotASubproject) diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/src/thirdparty.c b/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/src/thirdparty.c new file mode 100644 index 0000000..babe82d --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/src/thirdparty.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +int main(void) +{ + printf(This function has an error!\n"); + n = 5; + return 0; +} + +int notcalled() +{ + printf(This function doesn't get called.\n"); + return 0; +} diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/RunCMakeTest.cmake b/Tests/RunCMake/ctest_labels_for_subprojects/RunCMakeTest.cmake new file mode 100644 index 0000000..dbe7bf8 --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/RunCMakeTest.cmake @@ -0,0 +1,185 @@ +include(RunCTest) + + +# 1. Specify subprojects in the CTest script +function(run_CTestScriptVariable) + set(CTEST_EXTRA_CONFIG "set(CTEST_USE_LAUNCHERS 1)") + set(CASE_TEST_PREFIX_CODE [[ +file(COPY "${CTEST_RUNCMAKE_SOURCE_DIRECTORY}/MyProductionCode" + DESTINATION ${CTEST_SOURCE_DIRECTORY}) +file(COPY "${CTEST_RUNCMAKE_SOURCE_DIRECTORY}/MyExperimentalFeature" + DESTINATION ${CTEST_SOURCE_DIRECTORY}) + +set(CTEST_LABELS_FOR_SUBPROJECTS "MyProductionCode;MyExperimentalFeature") + ]]) + set(CASE_CMAKELISTS_SUFFIX_CODE [[ +add_subdirectory(MyExperimentalFeature) +add_subdirectory(MyProductionCode) + ]]) + + run_ctest(CTestScriptVariable) + + unset(CTEST_EXTRA_CONFIG) + unset(CASE_TEST_PREFIX_CODE) + unset(CASE_CMAKELISTS_SUFFIX_CODE) +endfunction() +run_CTestScriptVariable() + +# 2. Specify subprojects via a CTest script variable on the command line e.g. +# ctest -S test.cmake -DCTEST_LABELS_FOR_SUBPROJECTS:STRING="MySubproject" +# Note: This test includes a failing build +function(run_CTestScriptVariableCommandLine) + set(CTEST_EXTRA_CONFIG "set(CTEST_USE_LAUNCHERS 1)") + set(CASE_TEST_PREFIX_CODE [[ +file(COPY "${CTEST_RUNCMAKE_SOURCE_DIRECTORY}/MyThirdPartyDependency" + DESTINATION ${CTEST_SOURCE_DIRECTORY}) + ]]) + set(CASE_CMAKELISTS_SUFFIX_CODE [[ +add_subdirectory(MyThirdPartyDependency) + ]]) + + run_ctest(CTestScriptVariableCommandLine "-DCTEST_LABELS_FOR_SUBPROJECTS:STRING=MyThirdPartyDependency") + + unset(CTEST_EXTRA_CONFIG) + unset(CASE_TEST_PREFIX_CODE) + unset(CASE_CMAKELISTS_SUFFIX_CODE) +endfunction() +run_CTestScriptVariableCommandLine() + +# 3. Set subprojects via a CTest module variable on the command line +# (will populate DartConfiguration.tcl) +function(run_ModuleVariableCommandLine) + set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/ModuleVariableCommandLine") + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/ModuleVariableCommandLine-build") + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_SOURCE_DIR}") + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + set(CASE_CMAKELISTS_SUFFIX_CODE [[ +set(someFile "${CMAKE_CURRENT_SOURCE_DIR}/test.cmake") +add_test(NAME SuccessfulTest COMMAND "${CMAKE_COMMAND}" --version) +set_property(TEST SuccessfulTest PROPERTY LABELS MySubproject) +add_test(NAME FailingTest + COMMAND ${CMAKE_COMMAND} -E compare_files "${someFile}" "${someFile}xxx") +set_property(TEST FailingTest PROPERTY LABELS MySubproject) + ]]) + configure_file(${RunCMake_SOURCE_DIR}/CMakeLists.txt.in + ${RunCMake_TEST_SOURCE_DIR}/CMakeLists.txt @ONLY) + + set(RunCMake_TEST_OPTIONS "-DCTEST_LABELS_FOR_SUBPROJECTS:STRING=MySubproject") + run_cmake(ModuleVariableCommandLine-cmake) + unset(RunCMake_TEST_OPTIONS) + run_cmake_command(ModuleVariableCommandLine ${CMAKE_CTEST_COMMAND} -C Debug -V) + + unset(RunCMake_TEST_SOURCE_DIR) + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(CASE_CMAKELISTS_SUFFIX_CODE) +endfunction() +run_ModuleVariableCommandLine() + +# 4. Set subprojects via a CTest module variable in CMakeLists.txt +# (will populate DartConfiguration.tcl) +function(run_ModuleVariableCMakeLists) + set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/ModuleVariableCMakeLists") + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/ModuleVariableCMakeLists-build") + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_SOURCE_DIR}") + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + set(CASE_CMAKELISTS_PREFIX_CODE [[ +set(CTEST_LABELS_FOR_SUBPROJECTS MySubproject) +]]) + + set(CASE_CMAKELISTS_SUFFIX_CODE [[ +set(someFile "${CMAKE_CURRENT_SOURCE_DIR}/test.cmake") +add_test(NAME SuccessfulTest COMMAND "${CMAKE_COMMAND}" --version) +set_property(TEST SuccessfulTest PROPERTY LABELS MySubproject) +add_test(NAME FailingTest + COMMAND ${CMAKE_COMMAND} -E compare_files "${someFile}" "${someFile}xxx") +set_property(TEST FailingTest PROPERTY LABELS MySubproject) + ]]) + configure_file(${RunCMake_SOURCE_DIR}/CMakeLists.txt.in + ${RunCMake_TEST_SOURCE_DIR}/CMakeLists.txt @ONLY) + + run_cmake(ModuleVariableCMakeLists-cmake) + run_cmake_command(ModuleVariableCMakeLists ${CMAKE_CTEST_COMMAND} -C Debug -V) + + unset(RunCMake_TEST_SOURCE_DIR) + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(CASE_CMAKELISTS_SUFFIX_CODE) + unset(CASE_CMAKELISTS_SUFFIX_CODE) +endfunction() +run_ModuleVariableCMakeLists() + +# The remaining tests set subprojects in CTestConfig.cmake. Settings in this +# config file are shared by both the CTest module and the ctest command line +# `Dashboard Client` mode (e.g. ctest -S). + +function(run_ModuleVariableCTestConfig CASE_NAME) + set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/${CASE_NAME}") + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${CASE_NAME}-build") + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_SOURCE_DIR}") + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + set(CTEST_EXTRA_CONFIG "set(CTEST_LABELS_FOR_SUBPROJECTS \"MySubproject\")") + configure_file(${RunCMake_SOURCE_DIR}/CTestConfig.cmake.in + ${RunCMake_TEST_SOURCE_DIR}/CTestConfig.cmake @ONLY) + + set(CASE_CMAKELISTS_SUFFIX_CODE [[ +set(someFile "${CMAKE_CURRENT_SOURCE_DIR}/test.cmake") +add_test(NAME SuccessfulTest COMMAND "${CMAKE_COMMAND}" --version) +set_property(TEST SuccessfulTest PROPERTY LABELS MySubproject) +add_test(NAME FailingTest + COMMAND ${CMAKE_COMMAND} -E compare_files "${someFile}" "${someFile}xxx") +set_property(TEST FailingTest PROPERTY LABELS MySubproject) +add_test(NAME AnotherSuccessfulTest COMMAND "${CMAKE_COMMAND}" --version) +set_property(TEST AnotherSuccessfulTest PROPERTY LABELS NotASubproject) + ]]) + configure_file(${RunCMake_SOURCE_DIR}/CMakeLists.txt.in + ${RunCMake_TEST_SOURCE_DIR}/CMakeLists.txt @ONLY) + + run_cmake(${CASE_NAME}-cmake) + run_cmake_command(${CASE_NAME} ${CMAKE_CTEST_COMMAND} -C Debug -V ${ARGN}) + + unset(RunCMake_TEST_SOURCE_DIR) + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(CTEST_EXTRA_CONFIG) + unset(CASE_CMAKELISTS_SUFFIX_CODE) +endfunction() + +# 5. Check that the Subproject timing Summary is printed +run_ModuleVariableCTestConfig(ModuleVariableCTestConfig) + +# 6. Use --no-subproject-summary to disable the Subproject timing summary. +run_ModuleVariableCTestConfig(ModuleVariableCTestConfigNoSummary --no-subproject-summary) + +# 7. Verify that subprojects are sent to CDash when running a CTest script +function(run_CTestConfigCTestScript) + set(CTEST_EXTRA_CONFIG [[ +set(CTEST_USE_LAUNCHERS 1) +set(CTEST_LABELS_FOR_SUBPROJECTS "MyProductionCode;MyExperimentalFeature") + ]]) + set(CASE_TEST_PREFIX_CODE [[ +file(COPY "${CTEST_RUNCMAKE_SOURCE_DIRECTORY}/MyProductionCode" + DESTINATION ${CTEST_SOURCE_DIRECTORY}) +file(COPY "${CTEST_RUNCMAKE_SOURCE_DIRECTORY}/MyExperimentalFeature" + DESTINATION ${CTEST_SOURCE_DIRECTORY}) + ]]) + set(CASE_CMAKELISTS_SUFFIX_CODE [[ +add_subdirectory(MyExperimentalFeature) +add_subdirectory(MyProductionCode) + ]]) + run_ctest(CTestConfigCTestScript) + + unset(CTEST_EXTRA_CONFIG) + unset(CASE_TEST_PREFIX_CODE) + unset(CASE_CMAKELISTS_SUFFIX_CODE) +endfunction() +run_CTestConfigCTestScript() diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/test.cmake.in b/Tests/RunCMake/ctest_labels_for_subprojects/test.cmake.in new file mode 100644 index 0000000..8cec08d --- /dev/null +++ b/Tests/RunCMake/ctest_labels_for_subprojects/test.cmake.in @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.7) + +# Settings: + +set(CTEST_SITE "test-site") +set(CTEST_BUILD_NAME "test-build-name") +set(CTEST_SOURCE_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@") +set(CTEST_BINARY_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@-build") +set(CTEST_CMAKE_GENERATOR "@RunCMake_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@") +set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +set(CTEST_RUNCMAKE_SOURCE_DIRECTORY "@RunCMake_SOURCE_DIR@") + +@CASE_TEST_PREFIX_CODE@ + +set(ctest_test_args "@CASE_CTEST_TEST_ARGS@") +ctest_start(Experimental) +ctest_configure() +ctest_build() +ctest_test(${ctest_test_args}) |