Commit adcbdb14 authored by Stephen Manz's avatar Stephen Manz

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.
parent 8a42cd15
......@@ -85,27 +85,30 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
if (pass.first.find(this->ProcessOutput)) {
found = true;
reason = "Required regular expression found.";
reason += " Regex=[";
reason += pass.second;
reason += "]";
break;
}
}
if (!found) {
reason = "Required regular expression not found.";
reason += " Regex=[";
for (auto& pass : this->TestProperties->RequiredRegularExpressions) {
reason += pass.second;
reason += "\n";
}
reason += "]";
forceFail = true;
}
reason += "Regex=[";
for (auto& pass : this->TestProperties->RequiredRegularExpressions) {
reason += pass.second;
reason += "\n";
}
reason += "]";
}
if (!this->TestProperties->ErrorRegularExpressions.empty() &&
this->FailedDependencies.empty()) {
for (auto& pass : this->TestProperties->ErrorRegularExpressions) {
if (pass.first.find(this->ProcessOutput)) {
for (auto& fail : this->TestProperties->ErrorRegularExpressions) {
if (fail.first.find(this->ProcessOutput)) {
reason = "Error regular expression found in output.";
reason += " Regex=[";
reason += pass.second;
reason += fail.second;
reason += "]";
forceFail = true;
break;
......
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()
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()
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()
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment