Tests: Improve RunCMake.CrosscompilingEmulator error formatting

This commit is contained in:
Brad King
2024-01-26 14:42:01 -05:00
parent 2b5447d4a8
commit 54edf3471e
5 changed files with 45 additions and 24 deletions

View File

@@ -1,5 +1,6 @@
foreach(output IN ITEMS output1 output2 output3 output4)
if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/${output}")
message(FATAL_ERROR "Failed to create output: ${RunCMake_TEST_BINARY_DIR}/${output}")
set(RunCMake_TEST_FAILED "Failed to create output:\n ${RunCMake_TEST_BINARY_DIR}/${output}")
return()
endif()
endforeach()

View File

@@ -1,3 +1,4 @@
if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/output")
message(FATAL_ERROR "Failed to create output: ${RunCMake_TEST_BINARY_DIR}/output")
set(RunCMake_TEST_FAILED "Failed to create output:\n ${RunCMake_TEST_BINARY_DIR}/output")
return()
endif()

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[(]DoesNotUseEmulator [^\n]+pseudo_emulator[^\n]+\n")
message(SEND_ERROR "Used emulator when it should not be used. ${error_details}")
set(RunCMake_TEST_FAILED "Used emulator when it should not be used. ${error_details}")
return()
endif()
if(testfile_contents MATCHES "add_test[(]ShouldNotUseEmulator [^\n]+pseudo_emulator[^\n]+\n")
message(SEND_ERROR "Used emulator when it should be used. ${error_details}")
set(RunCMake_TEST_FAILED "Used emulator when it should be used. ${error_details}")
return()
endif()
if(testfile_contents MATCHES "add_test[(]DoesNotUseEmulatorWithGenex [^\n]+pseudo_emulator[^\n]+\n")
message(SEND_ERROR "Used emulator when it should not be used. ${error_details}")
set(RunCMake_TEST_FAILED "Used emulator when it should not be used. ${error_details}")
return()
endif()
if(testfile_contents MATCHES "add_test[(]ShouldNotUseEmulatorWithExecTargetFromSubdirAddedWithoutGenex [^\n]+pseudo_emulator[^\n]+\n")
message(SEND_ERROR "Used emulator when it should be used. ${error_details}")
set(RunCMake_TEST_FAILED "Used emulator when it should be used. ${error_details}")
return()
endif()
if(testfile_contents MATCHES "add_test[(]DoesNotUseEmulatorWithExecTargetFromSubdirAddedWithGenex [^\n]+pseudo_emulator[^\n]+\n")
message(SEND_ERROR "Used emulator when it should not be used. ${error_details}")
set(RunCMake_TEST_FAILED "Used emulator when it should not be used. ${error_details}")
return()
endif()

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[(]DoesNotUseEmulator [^\n]+pseudo_emulator[^\n]+\n")
message(SEND_ERROR "Used emulator when it should not be used. ${error_details}")
set(RunCMake_TEST_FAILED "Used emulator when it should not be used. ${error_details}")
return()
endif()
if(NOT testfile_contents MATCHES "add_test[(]UsesEmulator [^\n]+pseudo_emulator[^\n]+\n")
message(SEND_ERROR "Did not use emulator when it should be used. ${error_details}")
set(RunCMake_TEST_FAILED "Did not use emulator when it should be used. ${error_details}")
return()
endif()
if(testfile_contents MATCHES "add_test[(]DoesNotUseEmulatorWithGenex [^\n]+pseudo_emulator[^\n]+\n")
message(SEND_ERROR "Used emulator when it should not be used. ${error_details}")
set(RunCMake_TEST_FAILED "Used emulator when it should not be used. ${error_details}")
return()
endif()
if(NOT testfile_contents MATCHES "add_test[(]UsesEmulatorWithExecTargetFromSubdirAddedWithoutGenex [^\n]+pseudo_emulator[^\n]+\n")
message(SEND_ERROR "Did not use emulator when it should be used. ${error_details}")
set(RunCMake_TEST_FAILED "Did not use emulator when it should be used. ${error_details}")
return()
endif()
if(testfile_contents MATCHES "add_test[(]DoesNotUseEmulatorWithExecTargetFromSubdirAddedWithGenex [^\n]+pseudo_emulator[^\n]+\n")
message(SEND_ERROR "Used emulator when it should not be used. ${error_details}")
set(RunCMake_TEST_FAILED "Used emulator when it should not be used. ${error_details}")
return()
endif()

View File

@@ -2,31 +2,38 @@ 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[(]DoesNotUseEmulator [^\n]+pseudo_emulator[^\n]+\n")
message(SEND_ERROR "Used emulator when it should not be used. ${error_details}")
set(RunCMake_TEST_FAILED "Used emulator when it should not be used. ${error_details}")
return()
endif()
if(NOT testfile_contents MATCHES "add_test[(]UsesEmulator [^\n]+pseudo_emulator[^\n]+\n")
message(SEND_ERROR "Did not use emulator when it should be used. ${error_details}")
set(RunCMake_TEST_FAILED "Did not use emulator when it should be used. ${error_details}")
return()
endif()
if(testfile_contents MATCHES "add_test[(]DoesNotUseEmulatorWithGenex [^\n]+pseudo_emulator[^\n]+\n")
message(SEND_ERROR "Used emulator when it should not be used. ${error_details}")
set(RunCMake_TEST_FAILED "Used emulator when it should not be used. ${error_details}")
return()
endif()
if(NOT testfile_contents MATCHES "add_test[(]UsesEmulatorWithExecTargetFromSubdirAddedWithoutGenex [^\n]+pseudo_emulator[^\n]+\n")
message(SEND_ERROR "Did not use emulator when it should be used. ${error_details}")
set(RunCMake_TEST_FAILED "Did not use emulator when it should be used. ${error_details}")
return()
endif()
if(testfile_contents MATCHES "add_test[(]DoesNotUseEmulatorWithExecTargetFromSubdirAddedWithGenex [^\n]+pseudo_emulator[^\n]+\n")
message(SEND_ERROR "Used emulator when it should not be used. ${error_details}")
set(RunCMake_TEST_FAILED "Used emulator when it should not be used. ${error_details}")
return()
endif()
if(NOT testfile_contents MATCHES "add_test[(]UsesTestLauncherAndEmulator[^\n]+pseudo_test_launcher.*pseudo_emulator[^\n]+\n")
message(SEND_ERROR "Did not use test launcher and emulator when they should be used. ${error_details}")
set(RunCMake_TEST_FAILED "Did not use test launcher and emulator when they should be used. ${error_details}")
return()
endif()