summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-03-12 22:55:57 (GMT)
committerBrad King <brad.king@kitware.com>2024-03-18 18:04:17 (GMT)
commit7cc09d8859396d543da039ded772030aa4cfb80b (patch)
treedc22647c320b988893a1d98de4917f188f006f24
parentfce0617408add95d184c573714960a5b6020bde1 (diff)
downloadCMake-7cc09d8859396d543da039ded772030aa4cfb80b.zip
CMake-7cc09d8859396d543da039ded772030aa4cfb80b.tar.gz
CMake-7cc09d8859396d543da039ded772030aa4cfb80b.tar.bz2
Tests/RunCMake: Add option to print custom details in failure output
-rw-r--r--Tests/RunCMake/README.rst2
-rw-r--r--Tests/RunCMake/RunCMake.cmake4
2 files changed, 6 insertions, 0 deletions
diff --git a/Tests/RunCMake/README.rst b/Tests/RunCMake/README.rst
index d8cae8b..e726864 100644
--- a/Tests/RunCMake/README.rst
+++ b/Tests/RunCMake/README.rst
@@ -71,6 +71,8 @@ but do not actually build anything. To add a test:
Top of test binary tree
and an failure must store a message in ``RunCMake_TEST_FAILED``.
+ The check script may optionally set ``RunCMake_TEST_FAILURE_MESSAGE``
+ with additional text to be included in the message if the test fails.
To speed up local testing, you can choose to run only a subset of
``run_cmake()`` tests in a ``RunCMakeTest.cmake`` script by using the
diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake
index ecd7fad..ea3099f 100644
--- a/Tests/RunCMake/RunCMake.cmake
+++ b/Tests/RunCMake/RunCMake.cmake
@@ -248,6 +248,7 @@ function(run_cmake test)
endif()
endforeach()
unset(RunCMake_TEST_FAILED)
+ unset(RunCMake_TEST_FAILURE_MESSAGE)
if(RunCMake-check-file AND EXISTS ${top_src}/${RunCMake-check-file})
include(${top_src}/${RunCMake-check-file})
else()
@@ -278,6 +279,9 @@ function(run_cmake test)
string(APPEND msg "Actual ${o}:\n${actual_${o}}\n")
endif()
endforeach()
+ if(RunCMake_TEST_FAILURE_MESSAGE)
+ string(APPEND msg "${RunCMake_TEST_FAILURE_MESSAGE}")
+ endif()
message(SEND_ERROR "${test}${RunCMake_TEST_VARIANT_DESCRIPTION} - FAILED:\n${msg}")
else()
message(STATUS "${test}${RunCMake_TEST_VARIANT_DESCRIPTION} - PASSED")