summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorStephen Manz <6985-SRManz@users.noreply.gitlab.kitware.com>2019-06-26 16:01:45 (GMT)
committerStephen Manz <6985-SRManz@users.noreply.gitlab.kitware.com>2019-07-09 16:01:04 (GMT)
commitadcbdb143cfd302c6b3ae6da9b53f469e01a900b (patch)
treee2190101349139d55675998cf1723a54df36c477 /Tests
parent8a42cd155f00d9418fa60f995b466fff7c1afaa5 (diff)
downloadCMake-adcbdb143cfd302c6b3ae6da9b53f469e01a900b.zip
CMake-adcbdb143cfd302c6b3ae6da9b53f469e01a900b.tar.gz
CMake-adcbdb143cfd302c6b3ae6da9b53f469e01a900b.tar.bz2
CTest: Clean up stdout and logfile output for Pass/Fail regex
For pass regex, display only the element that was found, rather than all elements Rename loop variable for fail regex, from pass to fail For consistency, add space in output for pass Add tests that find and don't find PASS_REGULAR_EXPRESSION, and a test that finds FAIL_REGULAR_EXPRESSION, whose LastTest.log files are checked using *-check.cmake.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/CTestCommandLine/FailRegexFound-check.cmake13
-rw-r--r--Tests/RunCMake/CTestCommandLine/RequiredRegexFound-check.cmake13
-rw-r--r--Tests/RunCMake/CTestCommandLine/RequiredRegexNotFound-check.cmake16
-rw-r--r--Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake42
4 files changed, 84 insertions, 0 deletions
diff --git a/Tests/RunCMake/CTestCommandLine/FailRegexFound-check.cmake b/Tests/RunCMake/CTestCommandLine/FailRegexFound-check.cmake
new file mode 100644
index 0000000..1097788
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/FailRegexFound-check.cmake
@@ -0,0 +1,13 @@
+set(last_test_log "${RunCMake_TEST_BINARY_DIR}/Testing/Temporary/LastTest.log")
+if(EXISTS "${last_test_log}")
+ file(READ "${last_test_log}" last_test_log_content)
+ string(REGEX REPLACE "\n+$" "" last_test_log_content "${last_test_log_content}")
+ if(NOT last_test_log_content MATCHES "
+Test Pass Reason:
+Error regular expression found in output. Regex=[[]test1]")
+ string(REPLACE "\n" "\n " last_test_log_content " ${last_test_log_content}")
+ set(RunCMake_TEST_FAILED "LastTest.log does not have expected content:\n${last_test_log_content}")
+ endif()
+else()
+ set(RunCMake_TEST_FAILED "LastTest.log missing:\n ${last_test_log}")
+endif()
diff --git a/Tests/RunCMake/CTestCommandLine/RequiredRegexFound-check.cmake b/Tests/RunCMake/CTestCommandLine/RequiredRegexFound-check.cmake
new file mode 100644
index 0000000..bde60d1
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/RequiredRegexFound-check.cmake
@@ -0,0 +1,13 @@
+set(last_test_log "${RunCMake_TEST_BINARY_DIR}/Testing/Temporary/LastTest.log")
+if(EXISTS "${last_test_log}")
+ file(READ "${last_test_log}" last_test_log_content)
+ string(REGEX REPLACE "\n+$" "" last_test_log_content "${last_test_log_content}")
+ if(NOT last_test_log_content MATCHES "
+Test Pass Reason:
+Required regular expression found. Regex=[[]test1]")
+ string(REPLACE "\n" "\n " last_test_log_content " ${last_test_log_content}")
+ set(RunCMake_TEST_FAILED "LastTest.log does not have expected content:\n${last_test_log_content}")
+ endif()
+else()
+ set(RunCMake_TEST_FAILED "LastTest.log missing:\n ${last_test_log}")
+endif()
diff --git a/Tests/RunCMake/CTestCommandLine/RequiredRegexNotFound-check.cmake b/Tests/RunCMake/CTestCommandLine/RequiredRegexNotFound-check.cmake
new file mode 100644
index 0000000..6d420f3
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/RequiredRegexNotFound-check.cmake
@@ -0,0 +1,16 @@
+set(last_test_log "${RunCMake_TEST_BINARY_DIR}/Testing/Temporary/LastTest.log")
+if(EXISTS "${last_test_log}")
+ file(READ "${last_test_log}" last_test_log_content)
+ string(REGEX REPLACE "\n+$" "" last_test_log_content "${last_test_log_content}")
+ if(NOT last_test_log_content MATCHES "
+Test Pass Reason:
+Required regular expression not found. Regex=[[]foo
+toast1
+bar
+]")
+ string(REPLACE "\n" "\n " last_test_log_content " ${last_test_log_content}")
+ set(RunCMake_TEST_FAILED "LastTest.log does not have expected content:\n${last_test_log_content}")
+ endif()
+else()
+ set(RunCMake_TEST_FAILED "LastTest.log missing:\n ${last_test_log}")
+endif()
diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
index d524f41..f417db0 100644
--- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
@@ -78,6 +78,48 @@ endfunction()
run_LabelCount()
+function(run_RequiredRegexFoundTest)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/RequiredRegexFound)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" "
+add_test(test1 \"${CMAKE_COMMAND}\" -E echo \"test1\")
+set_tests_properties(test1 PROPERTIES PASS_REGULAR_EXPRESSION \"foo;test1;bar\")
+")
+
+ run_cmake_command(RequiredRegexFound ${CMAKE_CTEST_COMMAND} -V)
+endfunction()
+run_RequiredRegexFoundTest()
+
+function(run_RequiredRegexNotFoundTest)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/RequiredRegexNotFound)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" "
+add_test(test1 \"${CMAKE_COMMAND}\" -E echo \"test1\")
+set_tests_properties(test1 PROPERTIES PASS_REGULAR_EXPRESSION \"foo;toast1;bar\" WILL_FAIL True)
+")
+
+ run_cmake_command(RequiredRegexNotFound ${CMAKE_CTEST_COMMAND} -V)
+endfunction()
+run_RequiredRegexNotFoundTest()
+
+function(run_FailRegexFoundTest)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/FailRegexFound)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" "
+add_test(test1 \"${CMAKE_COMMAND}\" -E echo \"test1\")
+set_tests_properties(test1 PROPERTIES FAIL_REGULAR_EXPRESSION \"foo;test1;bar\" WILL_FAIL True)
+")
+
+ run_cmake_command(FailRegexFound ${CMAKE_CTEST_COMMAND} -V)
+endfunction()
+run_FailRegexFoundTest()
+
function(run_SerialFailed)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SerialFailed)
set(RunCMake_TEST_NO_CLEAN 1)