From 8de778118becd964310a4137e22baf9264c88627 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Mon, 18 Apr 2016 11:34:07 -0400 Subject: Tests: Cover genex behavior in CROSSCOMPILING_EMULATOR test case A `$` generator expression does not cause insertion of the emulator. Add a test covering this. While at it, extend the test case to cover executables in a subdirectory. Also make the test matching expressions more robust to support multiple add_test calls without mixing them while matching. --- .../CrosscompilingEmulator/AddTest-check.cmake | 24 ++++++++++++++++++---- .../RunCMake/CrosscompilingEmulator/AddTest.cmake | 12 +++++++++++ .../CrosscompilingEmulator/AddTest/CMakeLists.txt | 3 +++ 3 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 Tests/RunCMake/CrosscompilingEmulator/AddTest/CMakeLists.txt diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddTest-check.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddTest-check.cmake index 0aae06c..588b77b 100644 --- a/Tests/RunCMake/CrosscompilingEmulator/AddTest-check.cmake +++ b/Tests/RunCMake/CrosscompilingEmulator/AddTest-check.cmake @@ -4,9 +4,25 @@ if(EXISTS "${testfile}") else() message(FATAL_ERROR "Could not find expected CTestTestfile.cmake.") endif() -if(testfile_contents MATCHES "add_test[(]DoesNotUseEmulator ^(pseudo_emulator)+$") - message(SEND_ERROR "Used emulator when it should not be used.") + +set(error_details "There is a problem with generated test file: ${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}") endif() -if(NOT testfile_contents MATCHES "add_test[(]UsesEmulator .+pseudo_emulator.+$") - message(SEND_ERROR "Did not use emulator when it should be used.") + +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}") +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}") +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}") +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}") endif() diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddTest.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddTest.cmake index 41850f2..d304835 100644 --- a/Tests/RunCMake/CrosscompilingEmulator/AddTest.cmake +++ b/Tests/RunCMake/CrosscompilingEmulator/AddTest.cmake @@ -4,5 +4,17 @@ add_test(NAME DoesNotUseEmulator COMMAND ${CMAKE_COMMAND} -E echo "Hi") add_executable(generated_exe simple_src.cxx) + add_test(NAME UsesEmulator COMMAND generated_exe) + +add_test(NAME DoesNotUseEmulatorWithGenex + COMMAND $) + +add_subdirectory(AddTest) + +add_test(NAME UsesEmulatorWithExecTargetFromSubdirAddedWithoutGenex + COMMAND generated_exe_in_subdir_added_to_test_without_genex) + +add_test(NAME DoesNotUseEmulatorWithExecTargetFromSubdirAddedWithGenex + COMMAND $) diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddTest/CMakeLists.txt b/Tests/RunCMake/CrosscompilingEmulator/AddTest/CMakeLists.txt new file mode 100644 index 0000000..f3d11d5 --- /dev/null +++ b/Tests/RunCMake/CrosscompilingEmulator/AddTest/CMakeLists.txt @@ -0,0 +1,3 @@ +add_executable(generated_exe_in_subdir_added_to_test_without_genex ${CMAKE_CURRENT_SOURCE_DIR}/../simple_src.cxx) + +add_executable(generated_exe_in_subdir_added_to_test_with_genex ${CMAKE_CURRENT_SOURCE_DIR}/../simple_src.cxx) -- cgit v0.12 From eccfc0d185526b746b722ed3d3d1302515698c9e Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Mon, 2 May 2016 22:48:21 -0400 Subject: Tests: Improve source file name in RunCMake.CrosscompilingEmulator The test executable returns with an error, so indicate this in the source name. --- Tests/RunCMake/CrosscompilingEmulator/AddTest.cmake | 2 +- Tests/RunCMake/CrosscompilingEmulator/AddTest/CMakeLists.txt | 6 ++++-- .../CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake | 4 ++-- Tests/RunCMake/CrosscompilingEmulator/TryRun.cmake | 4 ++-- Tests/RunCMake/CrosscompilingEmulator/simple_src.cxx | 4 ---- Tests/RunCMake/CrosscompilingEmulator/simple_src_exiterror.cxx | 4 ++++ 6 files changed, 13 insertions(+), 11 deletions(-) delete mode 100644 Tests/RunCMake/CrosscompilingEmulator/simple_src.cxx create mode 100644 Tests/RunCMake/CrosscompilingEmulator/simple_src_exiterror.cxx diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddTest.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddTest.cmake index d304835..23e2e8d 100644 --- a/Tests/RunCMake/CrosscompilingEmulator/AddTest.cmake +++ b/Tests/RunCMake/CrosscompilingEmulator/AddTest.cmake @@ -3,7 +3,7 @@ enable_testing() add_test(NAME DoesNotUseEmulator COMMAND ${CMAKE_COMMAND} -E echo "Hi") -add_executable(generated_exe simple_src.cxx) +add_executable(generated_exe simple_src_exiterror.cxx) add_test(NAME UsesEmulator COMMAND generated_exe) diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddTest/CMakeLists.txt b/Tests/RunCMake/CrosscompilingEmulator/AddTest/CMakeLists.txt index f3d11d5..025b54c 100644 --- a/Tests/RunCMake/CrosscompilingEmulator/AddTest/CMakeLists.txt +++ b/Tests/RunCMake/CrosscompilingEmulator/AddTest/CMakeLists.txt @@ -1,3 +1,5 @@ -add_executable(generated_exe_in_subdir_added_to_test_without_genex ${CMAKE_CURRENT_SOURCE_DIR}/../simple_src.cxx) +add_executable(generated_exe_in_subdir_added_to_test_without_genex + ${CMAKE_CURRENT_SOURCE_DIR}/../simple_src_exiterror.cxx) -add_executable(generated_exe_in_subdir_added_to_test_with_genex ${CMAKE_CURRENT_SOURCE_DIR}/../simple_src.cxx) +add_executable(generated_exe_in_subdir_added_to_test_with_genex + ${CMAKE_CURRENT_SOURCE_DIR}/../simple_src_exiterror.cxx) diff --git a/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake b/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake index 22d537c..1aeb510 100644 --- a/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake +++ b/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake @@ -3,7 +3,7 @@ # -DCMAKE_CROSSCOMPILING_EMULATOR=/path/to/pseudo_emulator is passed to this # test -add_executable(target_with_emulator simple_src.cxx) +add_executable(target_with_emulator simple_src_exiterror.cxx) get_property(emulator TARGET target_with_emulator PROPERTY CROSSCOMPILING_EMULATOR) if(NOT "${emulator}" MATCHES "pseudo_emulator") @@ -20,7 +20,7 @@ if(NOT "${emulator}" MATCHES "another_emulator") endif() unset(CMAKE_CROSSCOMPILING_EMULATOR CACHE) -add_executable(target_without_emulator simple_src.cxx) +add_executable(target_without_emulator simple_src_exiterror.cxx) get_property(emulator TARGET target_without_emulator PROPERTY CROSSCOMPILING_EMULATOR) if(NOT "${emulator}" STREQUAL "") diff --git a/Tests/RunCMake/CrosscompilingEmulator/TryRun.cmake b/Tests/RunCMake/CrosscompilingEmulator/TryRun.cmake index 4851cc7..af3712c 100644 --- a/Tests/RunCMake/CrosscompilingEmulator/TryRun.cmake +++ b/Tests/RunCMake/CrosscompilingEmulator/TryRun.cmake @@ -2,7 +2,7 @@ set(CMAKE_CROSSCOMPILING 1) try_run(run_result compile_result ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/simple_src.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/simple_src_exiterror.cxx RUN_OUTPUT_VARIABLE run_output) message(STATUS "run_output: ${run_output}") @@ -13,6 +13,6 @@ set(CMAKE_CROSSCOMPILING_EMULATOR ${CMAKE_CROSSCOMPILING_EMULATOR} "multi arg") try_run(run_result compile_result ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/simple_src.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/simple_src_exiterror.cxx RUN_OUTPUT_VARIABLE run_output) message(STATUS "Emulator with arguments run_output: ${run_output}") diff --git a/Tests/RunCMake/CrosscompilingEmulator/simple_src.cxx b/Tests/RunCMake/CrosscompilingEmulator/simple_src.cxx deleted file mode 100644 index e5e94f2..0000000 --- a/Tests/RunCMake/CrosscompilingEmulator/simple_src.cxx +++ /dev/null @@ -1,4 +0,0 @@ -int main(int, char **) -{ - return 13; -} diff --git a/Tests/RunCMake/CrosscompilingEmulator/simple_src_exiterror.cxx b/Tests/RunCMake/CrosscompilingEmulator/simple_src_exiterror.cxx new file mode 100644 index 0000000..e5e94f2 --- /dev/null +++ b/Tests/RunCMake/CrosscompilingEmulator/simple_src_exiterror.cxx @@ -0,0 +1,4 @@ +int main(int, char **) +{ + return 13; +} -- cgit v0.12