diff options
author | Brad King <brad.king@kitware.com> | 2020-05-20 13:10:53 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-05-20 13:11:03 (GMT) |
commit | 00d6e41a07adb815768bc6dbb4b29582d6264be9 (patch) | |
tree | 59dd4dba0d9f512f93674b7bf8d5eab6f8d6d017 /Tests | |
parent | e4b095268b31d59d31072b9913e3014824a144e8 (diff) | |
parent | a1612af7497ca8496f216d95e25e4809da7c7c99 (diff) | |
download | CMake-00d6e41a07adb815768bc6dbb4b29582d6264be9.zip CMake-00d6e41a07adb815768bc6dbb4b29582d6264be9.tar.gz CMake-00d6e41a07adb815768bc6dbb4b29582d6264be9.tar.bz2 |
Merge topic 'ctest-log-environment'
a1612af749 CTest: Log environment variables as a test measurement
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4760
Diffstat (limited to 'Tests')
5 files changed, 40 insertions, 0 deletions
diff --git a/Tests/RunCMake/CTestResourceAllocation/RunCMakeTest.cmake b/Tests/RunCMake/CTestResourceAllocation/RunCMakeTest.cmake index 777f192..e9aa3a4 100644 --- a/Tests/RunCMake/CTestResourceAllocation/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTestResourceAllocation/RunCMakeTest.cmake @@ -38,6 +38,13 @@ function(run_ctresalloc_verify name tests) run_cmake_command(${name} "${CTRESALLOC_COMMAND}" verify "${RunCMake_SOURCE_DIR}/${name}.log" "${CMAKE_CURRENT_LIST_DIR}/resspec.json" "${tests}") endfunction() +function(read_testing_file filename variable) + file(READ "${RunCMake_TEST_BINARY_DIR}/Testing/TAG" _tag) + string(REGEX REPLACE "^([^\n]*)\n.*$" "\\1" _date "${_tag}") + file(READ "${RunCMake_TEST_BINARY_DIR}/Testing/${_date}/${filename}" _contents) + set("${variable}" "${_contents}" PARENT_SCOPE) +endfunction() + unset(ENV{CTEST_RESOURCE_GROUP_COUNT}) set(RunCMake_TEST_NO_CLEAN 1) file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/ctresalloc-write-proc-good1-build") diff --git a/Tests/RunCMake/CTestResourceAllocation/process_count-ctest-s-nores-check.cmake b/Tests/RunCMake/CTestResourceAllocation/process_count-ctest-s-nores-check.cmake new file mode 100644 index 0000000..c6e72bd --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/process_count-ctest-s-nores-check.cmake @@ -0,0 +1,4 @@ +read_testing_file("Test.xml" _test_contents) +if(NOT _test_contents MATCHES "#CTEST_RESOURCE_GROUP_COUNT=") + string(APPEND RunCMake_TEST_FAILED "Could not find unset variable CTEST_RESOURCE_GROUP_COUNT in test measurements\n") +endif() diff --git a/Tests/RunCMake/CTestResourceAllocation/process_count-ctest-s-res-check.cmake b/Tests/RunCMake/CTestResourceAllocation/process_count-ctest-s-res-check.cmake index ceda72e..585c36b 100644 --- a/Tests/RunCMake/CTestResourceAllocation/process_count-ctest-s-res-check.cmake +++ b/Tests/RunCMake/CTestResourceAllocation/process_count-ctest-s-res-check.cmake @@ -1 +1,9 @@ verify_ctest_resources() + +read_testing_file("Test.xml" _test_contents) +if(NOT _test_contents MATCHES "\nCTEST_RESOURCE_GROUP_0=widgets") + string(APPEND RunCMake_TEST_FAILED "Could not find variable CTEST_RESOURCE_GROUP_0 in test measurements\n") +endif() +if(NOT _test_contents MATCHES "\nCTEST_RESOURCE_GROUP_0_WIDGETS=id:") + string(APPEND RunCMake_TEST_FAILED "Could not find variable CTEST_RESOURCE_GROUP_0_WIDGETS in test measurements\n") +endif() diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake index 34d4020..18ae793 100644 --- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake @@ -107,3 +107,14 @@ add_test(NAME NotRunTest COMMAND ${CMAKE_COMMAND} -E true) run_ctest_test(stop-on-failure STOP_ON_FAILURE) endfunction() run_stop_on_failure() + +# Make sure environment gets logged +function(run_environment) + set(ENV{BAD_ENVIRONMENT_VARIABLE} "Bad environment variable") + set(CASE_CMAKELISTS_SUFFIX_CODE [[ +set_property(TEST RunCMakeVersion PROPERTY ENVIRONMENT "ENV1=env1;ENV2=env2") + ]]) + + run_ctest(TestEnvironment) +endfunction() +run_environment() diff --git a/Tests/RunCMake/ctest_test/TestEnvironment-check.cmake b/Tests/RunCMake/ctest_test/TestEnvironment-check.cmake new file mode 100644 index 0000000..91c9731 --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestEnvironment-check.cmake @@ -0,0 +1,10 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/Testing/TAG" _tag) +string(REGEX REPLACE "^([^\n]*)\n.*$" "\\1" _date "${_tag}") +file(READ "${RunCMake_TEST_BINARY_DIR}/Testing/${_date}/Test.xml" _test_contents) + +if(NOT _test_contents MATCHES "<Value>ENV1=env1\nENV2=env2\n#CTEST_RESOURCE_GROUP_COUNT=</Value>") + string(APPEND RunCMake_TEST_FAILED "Could not find expected environment variables in Test.xml") +endif() +if(_test_contents MATCHES "BAD_ENVIRONMENT_VARIABLE") + string(APPEND RunCMake_TEST_FAILED "Found BAD_ENVIRONMENT_VARIABLE in Test.xml") +endif() |