summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-07-11 12:50:26 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-07-11 12:50:36 (GMT)
commit6e4e79e1b054fd7f9f697e67136dc2c4ef405dc8 (patch)
treea40cf975a191d37b538ab05875856683c27500bf /Tests
parent01a8b89f292c031e7a35bedf92b7cda98bef7f6d (diff)
parentadcbdb143cfd302c6b3ae6da9b53f469e01a900b (diff)
downloadCMake-6e4e79e1b054fd7f9f697e67136dc2c4ef405dc8.zip
CMake-6e4e79e1b054fd7f9f697e67136dc2c4ef405dc8.tar.gz
CMake-6e4e79e1b054fd7f9f697e67136dc2c4ef405dc8.tar.bz2
Merge topic 'fix_ctest_output'
adcbdb143c CTest: Clean up stdout and logfile output for Pass/Fail regex Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3509
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)