I'd like to add a test via CMake in the following manner:
ADD_UNIT_TEST(MyTest)
set_tests_properties(
MyTest
PROPERTIES
PASS_REGULAR_EXPRESSION
"This matches the first line\n"
"This matches the second line"
)
Is this possible? How?
I've found this post and modified your example with the code suggested in the post:
\n
with [\r\n\t ]*
The following did work successfully with my CMake version 3.5.2:
cmake_minimum_required(VERSION 3.5)
project(RegExMultiLine)
enable_testing()
add_test(
NAME
MyTest
COMMAND
${CMAKE_COMMAND} -E echo
"Some other line\n"
"This matches the first line\n"
"This matches the second line\n"
"Another line"
)
set_tests_properties(
MyTest
PROPERTIES
PASS_REGULAR_EXPRESSION
"This matches the first line[\r\n\t ]*This matches the second line"
)
Would give:
> ctest -C Debug
[...]
Start 1: MyTest
1/1 Test #1: MyTest ........................... Passed 0.03 sec
Instead of (when using your original code):
> ctest -C Debug
[...]
Start 1: MyTest
1/1 Test #1: MyTest ...........................***Failed Required regular expression not found.Regex=[This matches the first line
This matches the second line
] 0.03 sec
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With