Tests: Improve RunCMake.add_test error formatting

This commit is contained in:
Brad King
2024-01-27 11:32:52 -05:00
parent b440e0af3f
commit c5b58b0842

View File

@@ -2,27 +2,33 @@ set(testfile "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake")
if(EXISTS "${testfile}")
file(READ "${testfile}" testfile_contents)
else()
message(FATAL_ERROR "Could not find expected CTestTestfile.cmake.")
set(RunCMake_TEST_FAILED "Could not find expected CTestTestfile.cmake.")
return()
endif()
set(error_details "There is a problem with generated test file: ${testfile}")
set(error_details "There is a problem with generated test file:\n ${testfile}")
if(testfile_contents MATCHES "add_test[(]DoesNotUseTestLauncher [^\n]+pseudo_test_launcher[^\n]+\n")
message(SEND_ERROR "Used test launcher when it should not be used. ${error_details}")
set(RunCMake_TEST_FAILED "Used test launcher when it should not be used. ${error_details}")
return()
endif()
if(NOT testfile_contents MATCHES "add_test[(]UsesTestLauncher [^\n]+pseudo_test_launcher[^\n]+\n")
message(SEND_ERROR "Did not use test launcher when it should be used. ${error_details}")
set(RunCMake_TEST_FAILED "Did not use test launcher when it should be used. ${error_details}")
return()
endif()
if(testfile_contents MATCHES "add_test[(]DoesNotUseTestLauncherWithGenex [^\n]+pseudo_test_launcher[^\n]+\n")
message(SEND_ERROR "Used test launcher when it should not be used. ${error_details}")
set(RunCMake_TEST_FAILED "Used test launcher when it should not be used. ${error_details}")
return()
endif()
if(NOT testfile_contents MATCHES "add_test[(]UsesTestLauncherWithExecTargetFromSubdirAddedWithoutGenex [^\n]+pseudo_test_launcher[^\n]+\n")
message(SEND_ERROR "Did not use test launcher when it should be used. ${error_details}")
set(RunCMake_TEST_FAILED "Did not use test launcher when it should be used. ${error_details}")
return()
endif()
if(testfile_contents MATCHES "add_test[(]DoesNotUseTestLauncherWithExecTargetFromSubdirAddedWithGenex [^\n]+pseudo_test_launcher[^\n]+\n")
message(SEND_ERROR "Used test launcher when it should not be used. ${error_details}")
set(RunCMake_TEST_FAILED "Used test launcher when it should not be used. ${error_details}")
return()
endif()