summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/add_test
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-01-26 19:04:42 (GMT)
committerBrad King <brad.king@kitware.com>2024-01-27 16:34:35 (GMT)
commitfb766ff638c31264ca70f588c26a38ea365668a0 (patch)
tree9650a5bc6f0e30f8735bc06f2a0e53ebfbbb92d0 /Tests/RunCMake/add_test
parentc5b58b0842925b7de0e36dfb30cfc47383f4d5c6 (diff)
downloadCMake-fb766ff638c31264ca70f588c26a38ea365668a0.zip
CMake-fb766ff638c31264ca70f588c26a38ea365668a0.tar.gz
CMake-fb766ff638c31264ca70f588c26a38ea365668a0.tar.bz2
Tests: Improve RunCMake.add_test TEST_LAUNCHER coverage
Verify that ctest actually runs the test command lines as expected.
Diffstat (limited to 'Tests/RunCMake/add_test')
-rw-r--r--Tests/RunCMake/add_test/RunCMakeTest.cmake19
-rw-r--r--Tests/RunCMake/add_test/TestLauncher-check.cmake10
-rw-r--r--Tests/RunCMake/add_test/TestLauncher-test-stdout.txt48
-rw-r--r--Tests/RunCMake/add_test/TestLauncher.cmake15
-rw-r--r--Tests/RunCMake/add_test/TestLauncher/CMakeLists.txt11
-rw-r--r--Tests/RunCMake/add_test/TestLauncherProperty.cmake17
-rw-r--r--Tests/RunCMake/add_test/main.c4
-rw-r--r--Tests/RunCMake/add_test/simple_src_exiterror.cxx4
8 files changed, 88 insertions, 40 deletions
diff --git a/Tests/RunCMake/add_test/RunCMakeTest.cmake b/Tests/RunCMake/add_test/RunCMakeTest.cmake
index 8b5c915..6e7d53a 100644
--- a/Tests/RunCMake/add_test/RunCMakeTest.cmake
+++ b/Tests/RunCMake/add_test/RunCMakeTest.cmake
@@ -42,8 +42,19 @@ block()
run_cmake_command(EmptyArgument-ctest ${CMAKE_CTEST_COMMAND} -C Debug)
endblock()
-set(RunCMake_TEST_OPTIONS
- "-DCMAKE_TEST_LAUNCHER=/path/to/pseudo_test_launcher")
-
+set(RunCMake_TEST_OPTIONS "-DCMAKE_TEST_LAUNCHER=${PSEUDO_EMULATOR}")
run_cmake(TestLauncherProperty)
-run_cmake(TestLauncher)
+block()
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/TestLauncher-build)
+
+ run_cmake(TestLauncher)
+ unset(RunCMake_TEST_OPTIONS)
+
+ set(RunCMake_TEST_NO_CLEAN 1)
+ set(RunCMake_TEST_OUTPUT_MERGE 1)
+ run_cmake_command(TestLauncher-build ${CMAKE_COMMAND} --build . --config Debug)
+ unset(RunCMake_TEST_OUTPUT_MERGE)
+
+ run_cmake_command(TestLauncher-test ${CMAKE_CTEST_COMMAND} -C Debug -V)
+endblock()
+unset(RunCMake_TEST_OPTIONS)
diff --git a/Tests/RunCMake/add_test/TestLauncher-check.cmake b/Tests/RunCMake/add_test/TestLauncher-check.cmake
index d6e795c..add1105 100644
--- a/Tests/RunCMake/add_test/TestLauncher-check.cmake
+++ b/Tests/RunCMake/add_test/TestLauncher-check.cmake
@@ -8,27 +8,27 @@ endif()
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")
+if(testfile_contents MATCHES "add_test[(]DoesNotUseTestLauncher [^\n]+pseudo_emulator[^\n]+\n")
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")
+if(NOT testfile_contents MATCHES "add_test[(]UsesTestLauncher [^\n]+pseudo_emulator[^\n]+\n")
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")
+if(testfile_contents MATCHES "add_test[(]DoesNotUseTestLauncherWithGenex [^\n]+pseudo_emulator[^\n]+\n")
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")
+if(NOT testfile_contents MATCHES "add_test[(]UsesTestLauncherWithExecTargetFromSubdirAddedWithoutGenex [^\n]+pseudo_emulator[^\n]+\n")
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")
+if(testfile_contents MATCHES "add_test[(]DoesNotUseTestLauncherWithExecTargetFromSubdirAddedWithGenex [^\n]+pseudo_emulator[^\n]+\n")
set(RunCMake_TEST_FAILED "Used test launcher when it should not be used. ${error_details}")
return()
endif()
diff --git a/Tests/RunCMake/add_test/TestLauncher-test-stdout.txt b/Tests/RunCMake/add_test/TestLauncher-test-stdout.txt
new file mode 100644
index 0000000..10d79d4
--- /dev/null
+++ b/Tests/RunCMake/add_test/TestLauncher-test-stdout.txt
@@ -0,0 +1,48 @@
+test 1
+ Start 1: DoesNotUseLauncher
++
+1: Test command: "?[^
+]*[/\]cmake(\.exe)?"? "-E" "echo" "Hi"
+1: Working Directory: [^
+]*/Tests/RunCMake/add_test/TestLauncher-build
+1: Test timeout computed to be: [0-9]+
+1: Hi
+1/5 Test #1: DoesNotUseLauncher [.]* +Passed +[0-9.]+ sec
+test 2
+ Start 2: UsesTestLauncher
++
+2: Test command: "?[^
+]*[/\]Tests[/\]RunCMake([/\][^/\]+)?[/\]pseudo_emulator(\.exe)?"? "[^"]*/Tests/RunCMake/add_test/TestLauncher-build(/Debug)?/exe(\.exe)?"
+2: Working Directory: [^
+]*Tests/RunCMake/add_test/TestLauncher-build
+2: Test timeout computed to be: [0-9]+
+2: Command: "[^"]*/Tests/RunCMake/add_test/TestLauncher-build(/Debug)?/exe(\.exe)?"
+2/5 Test #2: UsesTestLauncher [.]* +Passed +[0-9.]+ sec
+test 3
+ Start 3: DoesNotUseTestLauncherWithGenex
++
+3: Test command: "?[^
+]*[/\]Tests[/\]RunCMake[/\]add_test[/\]TestLauncher-build([/\]Debug)?[/\]exe(\.exe)?"?
+3: Working Directory: [^
+]*Tests/RunCMake/add_test/TestLauncher-build
+3: Test timeout computed to be: [0-9]+
+3/5 Test #3: DoesNotUseTestLauncherWithGenex [.]* +Passed +[0-9.]+ sec
+test 4
+ Start 4: UsesTestLauncherWithExecTargetFromSubdirAddedWithoutGenex
++
+4: Test command: "?[^
+]*[/\]Tests[/\]RunCMake([/\][^/\]+)?[/\]pseudo_emulator(\.exe)?"? "[^"]*/Tests/RunCMake/add_test/TestLauncher-build/TestLauncher(/Debug)?/subdir_exe_no_genex(\.exe)?"
+4: Working Directory: [^
+]*Tests/RunCMake/add_test/TestLauncher-build
+4: Test timeout computed to be: [0-9]+
+4: Command: "[^"]*/Tests/RunCMake/add_test/TestLauncher-build/TestLauncher(/Debug)?/subdir_exe_no_genex(\.exe)?"
+4/5 Test #4: UsesTestLauncherWithExecTargetFromSubdirAddedWithoutGenex [.]* +Passed +[0-9.]+ sec
+test 5
+ Start 5: DoesNotUseTestLauncherWithExecTargetFromSubdirAddedWithGenex
++
+5: Test command: "?[^
+]*[/\]Tests[/\]RunCMake[/\]add_test[/\]TestLauncher-build[/\]TestLauncher([/\]Debug)?[/\]subdir_exe_with_genex(\.exe)?"?
+5: Working Directory: [^
+]*Tests/RunCMake/add_test/TestLauncher-build
+5: Test timeout computed to be: [0-9]+
+5/5 Test #5: DoesNotUseTestLauncherWithExecTargetFromSubdirAddedWithGenex [.]* +Passed +[0-9.]+ sec
diff --git a/Tests/RunCMake/add_test/TestLauncher.cmake b/Tests/RunCMake/add_test/TestLauncher.cmake
index 8ad3be9..023b663 100644
--- a/Tests/RunCMake/add_test/TestLauncher.cmake
+++ b/Tests/RunCMake/add_test/TestLauncher.cmake
@@ -1,22 +1,21 @@
-project(test_launcher LANGUAGES C)
-
+enable_language(C)
enable_testing()
+
add_test(NAME DoesNotUseLauncher
COMMAND ${CMAKE_COMMAND} -E echo "Hi")
-add_executable(generated_exe simple_src_exiterror.cxx)
-set_target_properties(generated_exe PROPERTIES LINKER_LANGUAGE C)
+add_executable(exe main.c)
add_test(NAME UsesTestLauncher
- COMMAND generated_exe)
+ COMMAND exe)
add_test(NAME DoesNotUseTestLauncherWithGenex
- COMMAND $<TARGET_FILE:generated_exe>)
+ COMMAND $<TARGET_FILE:exe>)
add_subdirectory(TestLauncher)
add_test(NAME UsesTestLauncherWithExecTargetFromSubdirAddedWithoutGenex
- COMMAND generated_exe_in_subdir_added_to_test_without_genex)
+ COMMAND subdir_exe_no_genex)
add_test(NAME DoesNotUseTestLauncherWithExecTargetFromSubdirAddedWithGenex
- COMMAND $<TARGET_FILE:generated_exe_in_subdir_added_to_test_with_genex>)
+ COMMAND $<TARGET_FILE:subdir_exe_with_genex>)
diff --git a/Tests/RunCMake/add_test/TestLauncher/CMakeLists.txt b/Tests/RunCMake/add_test/TestLauncher/CMakeLists.txt
index fb40a59..fa20ae9 100644
--- a/Tests/RunCMake/add_test/TestLauncher/CMakeLists.txt
+++ b/Tests/RunCMake/add_test/TestLauncher/CMakeLists.txt
@@ -1,9 +1,2 @@
-add_executable(generated_exe_in_subdir_added_to_test_without_genex
- ${CMAKE_CURRENT_SOURCE_DIR}/../simple_src_exiterror.cxx)
-set_target_properties(generated_exe_in_subdir_added_to_test_without_genex
- PROPERTIES LINKER_LANGUAGE C)
-
-add_executable(generated_exe_in_subdir_added_to_test_with_genex
- ${CMAKE_CURRENT_SOURCE_DIR}/../simple_src_exiterror.cxx)
-set_target_properties(generated_exe_in_subdir_added_to_test_with_genex
- PROPERTIES LINKER_LANGUAGE C)
+add_executable(subdir_exe_no_genex ../main.c)
+add_executable(subdir_exe_with_genex ../main.c)
diff --git a/Tests/RunCMake/add_test/TestLauncherProperty.cmake b/Tests/RunCMake/add_test/TestLauncherProperty.cmake
index e86f42b..3bc49e6 100644
--- a/Tests/RunCMake/add_test/TestLauncherProperty.cmake
+++ b/Tests/RunCMake/add_test/TestLauncherProperty.cmake
@@ -2,16 +2,15 @@
# This tests setting the TEST_LAUNCHER target property from the
# CMAKE_TEST_LAUNCHER variable.
-# -DCMAKE_TEST_LAUNCHER=/path/to/pseudo_test_launcher is passed to this
-# test
+enable_language(C)
-project(test_launcher LANGUAGES C)
+# -DCMAKE_TEST_LAUNCHER=/path/to/pseudo_emulator is passed to this
+# test
-add_executable(target_with_test_launcher simple_src_exiterror.cxx)
-set_target_properties(target_with_test_launcher PROPERTIES LINKER_LANGUAGE C)
+add_executable(target_with_test_launcher main.c)
get_property(launcher TARGET target_with_test_launcher
PROPERTY TEST_LAUNCHER)
-if(NOT "${launcher}" MATCHES "pseudo_test_launcher")
+if(NOT "${launcher}" MATCHES "pseudo_emulator")
message(SEND_ERROR "Default TEST_LAUNCHER property not set")
endif()
@@ -25,16 +24,14 @@ if(NOT "${launcher}" MATCHES "another_test_launcher")
endif()
unset(CMAKE_TEST_LAUNCHER CACHE)
-add_executable(target_without_test_launcher simple_src_exiterror.cxx)
-set_target_properties(target_without_test_launcher PROPERTIES LINKER_LANGUAGE C)
+add_executable(target_without_test_launcher main.c)
get_property(launcher TARGET target_without_test_launcher
PROPERTY TEST_LAUNCHER)
if(NOT "${launcher}" STREQUAL "")
message(SEND_ERROR "Default TEST_LAUNCHER property not set to null")
endif()
-add_executable(target_with_empty_test_launcher simple_src_exiterror.cxx)
-set_target_properties(target_with_empty_test_launcher PROPERTIES LINKER_LANGUAGE C)
+add_executable(target_with_empty_test_launcher main.c)
set_property(TARGET target_with_empty_test_launcher PROPERTY TEST_LAUNCHER "")
enable_testing()
diff --git a/Tests/RunCMake/add_test/main.c b/Tests/RunCMake/add_test/main.c
new file mode 100644
index 0000000..8488f4e
--- /dev/null
+++ b/Tests/RunCMake/add_test/main.c
@@ -0,0 +1,4 @@
+int main(void)
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/add_test/simple_src_exiterror.cxx b/Tests/RunCMake/add_test/simple_src_exiterror.cxx
deleted file mode 100644
index 6ce7183..0000000
--- a/Tests/RunCMake/add_test/simple_src_exiterror.cxx
+++ /dev/null
@@ -1,4 +0,0 @@
-int main(int, char**)
-{
- return 13;
-}