Tests/RunCMake: Add option to print custom details in failure output

This commit is contained in:
Brad King
2024-03-12 18:55:57 -04:00
parent fce0617408
commit 7cc09d8859
2 changed files with 6 additions and 0 deletions
+2
View File
@@ -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
+4
View File
@@ -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")