Skip to content

CTest: Clean up stdout and logfile output for Pass/Fail regex

Stephen Manz requested to merge SRManz/cmake:fix_ctest_output into master

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

It makes sense to me that finding the required regex should cause output of only the element that was found, not the entire list of regexes. In other words, handle it like finding the FAIL_REGULAR_EXPRESSION.

For testing, I created a small project with an executable that sends "Done" to stdout. I added 3 tests, one with PASS_REGULAR_EXPRESSION set to "Done;foo;bar", one with PASS_REGULAR_EXPRESSION set to "done;foo;bar", and one with FAIL_REGULAR_EXPRESSION set to "Done;foo;bar".

Without my changes, I get:

Test Pass Reason:
Required regular expression found.Regex=[Done
foo
bar
]

Test Fail Reason:
Required regular expression not found.Regex=[done
foo
bar
]

Test Fail Reason:
Error regular expression found in output. Regex=[Done]

Note, above, the missing space between "found." and "Regex" for the required regular expression, whether or not it was found.

With my changes, I get:

Test Pass Reason:
Required regular expression found. Regex=[Done]

Test Fail Reason:
Required regular expression not found. Regex=[done
foo
bar
]

Test Fail Reason:
Error regular expression found in output. Regex=[Done]
Edited by Stephen Manz

Merge request reports