diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2020-05-18 15:52:38 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2020-05-19 14:26:57 (GMT) |
commit | a1612af7497ca8496f216d95e25e4809da7c7c99 (patch) | |
tree | c90a9b926e50ccc78e36ad9366b27a35afee6bc7 /Tests/RunCMake/ctest_test | |
parent | 6d9bc2d8cf41d651a6e8c9f6e3e6f5ab384d1f6a (diff) | |
download | CMake-a1612af7497ca8496f216d95e25e4809da7c7c99.zip CMake-a1612af7497ca8496f216d95e25e4809da7c7c99.tar.gz CMake-a1612af7497ca8496f216d95e25e4809da7c7c99.tar.bz2 |
CTest: Log environment variables as a test measurement
Diffstat (limited to 'Tests/RunCMake/ctest_test')
-rw-r--r-- | Tests/RunCMake/ctest_test/RunCMakeTest.cmake | 11 | ||||
-rw-r--r-- | Tests/RunCMake/ctest_test/TestEnvironment-check.cmake | 10 |
2 files changed, 21 insertions, 0 deletions
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() |