diff options
author | Zack Galbreath <zack.galbreath@kitware.com> | 2021-06-08 14:48:57 -0400 |
---|---|---|
committer | Zack Galbreath <zack.galbreath@kitware.com> | 2021-06-09 08:31:32 -0400 |
commit | 02f1271bdf810107ad5d3c0cffb74b472d706054 (patch) | |
tree | 64c61a8d698537524000ff115ffdfffd823c09d7 /Tests | |
parent | 5e26887c35be116a83ba049098f5780309ced073 (diff) | |
download | cmake-02f1271bdf810107ad5d3c0cffb74b472d706054.tar.gz |
ctest: allow test output to override the 'details' field
Parse test output for <CTestDetails>...</CTestDetails>.
If found, use this value to override the default 'Details' string reported
to CDash.
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/ctest_test/RunCMakeTest.cmake | 12 | ||||
-rw-r--r-- | Tests/RunCMake/ctest_test/TestCompletionStatus-check.cmake | 16 |
2 files changed, 28 insertions, 0 deletions
diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake index 76a63f0114..f07a12b773 100644 --- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake @@ -169,3 +169,15 @@ add_test( run_ctest(TestMeasurements) endfunction() run_measurements() + +# Verify that test output can override the Completion Status. +function(run_completion_status) + set(CASE_CMAKELISTS_SUFFIX_CODE [[ +add_test( + NAME custom_details + COMMAND ${CMAKE_COMMAND} -E + echo test output\n<CTestDetails>CustomDetails</CTestDetails>\nmore output) + ]]) + run_ctest(TestCompletionStatus) +endfunction() +run_completion_status() diff --git a/Tests/RunCMake/ctest_test/TestCompletionStatus-check.cmake b/Tests/RunCMake/ctest_test/TestCompletionStatus-check.cmake new file mode 100644 index 0000000000..10de2edf0d --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestCompletionStatus-check.cmake @@ -0,0 +1,16 @@ +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) + +# Check custom completion status. +if(NOT _test_contents MATCHES [[<Value>CustomDetails</Value>]]) + string(APPEND RunCMake_TEST_FAILED + "Could not find expected <Value>CustomDetails</Value> in Test.xml") +endif() +# Check test output. +if(NOT _test_contents MATCHES "test output") + string(APPEND RunCMake_TEST_FAILED "Could not find expected string 'test output' in Test.xml") +endif() +if(NOT _test_contents MATCHES "more output") + string(APPEND RunCMake_TEST_FAILED "Could not find expected string 'more output' in Test.xml") +endif() |