diff options
author | Evgeniy Shcherbina <ixsci@pm.me> | 2022-02-07 10:35:21 +0300 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-02-07 12:53:17 -0500 |
commit | 073dd1bd8131a337d3022a6bdc75af0114588093 (patch) | |
tree | 290facbaa5aecdec0537f357ae0be0760298f246 | |
parent | f28f738bd2be2ed790bb5b4c794773b7a627d3f2 (diff) | |
download | cmake-073dd1bd8131a337d3022a6bdc75af0114588093.tar.gz |
GoogleTest: Change format for typed tests
Before it would output a typed test as follows:
Suit/Type.Case
And now it would be:
Suit.Case<Type>
In case of NO_PRETTY_TYPES it would simply use the type number
instead of its text representation:
Suit.Case<0>
The change is introduced to make sure CTest outputs tests in a
similar fashion which is "*Suit.Case*" and angle brackets "<>"
emphasize that we are dealing with a typed (template) kind.
5 files changed, 52 insertions, 45 deletions
diff --git a/Modules/GoogleTestAddTests.cmake b/Modules/GoogleTestAddTests.cmake index 671127ad7e..cef2e8a407 100644 --- a/Modules/GoogleTestAddTests.cmake +++ b/Modules/GoogleTestAddTests.cmake @@ -135,10 +135,17 @@ function(gtest_discover_tests_impl) if(NOT line MATCHES "^ ") # Module; remove trailing '.' to get just the name... string(REGEX REPLACE "\\.( *#.*)?$" "" suite "${line}") - if(line MATCHES "#" AND NOT _NO_PRETTY_TYPES) - string(REGEX REPLACE "/[0-9]+\\.+ +#.*= +" "/" pretty_suite "${line}") + if(line MATCHES "#") + string(REGEX REPLACE "/.*" "" pretty_suite "${line}") + if(NOT _NO_PRETTY_TYPES) + string(REGEX REPLACE ".*/[0-9]+[ .#]+TypeParam = (.*)" "\\1" type_parameter "${line}") + else() + string(REGEX REPLACE ".*/([0-9]+)[ .#]+TypeParam = .*" "\\1" type_parameter "${line}") + endif() + set(test_name_template "@prefix@@pretty_suite@.@pretty_test@<@type_parameter@>@suffix@") else() set(pretty_suite "${suite}") + set(test_name_template "@prefix@@pretty_suite@.@pretty_test@@suffix@") endif() string(REGEX REPLACE "^DISABLED_" "" pretty_suite "${pretty_suite}") else() @@ -156,7 +163,7 @@ function(gtest_discover_tests_impl) unset(TEST_XML_OUTPUT_PARAM) endif() - set(testname "${prefix}${pretty_suite}.${pretty_test}${suffix}") + string(CONFIGURE "${test_name_template}" testname) # sanitize test name for further processing downstream # unescape [] if(open_sb) diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change-typed-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change-typed-stdout.txt index f21e579ad2..c4545caa65 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change-typed-stdout.txt +++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change-typed-stdout.txt @@ -1,9 +1,9 @@ Test project .*/Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change - Test #[0-9]+: typed/short\.case - Test #[0-9]+: typed/float\.case - Test #[0-9]+: typed/char\.case - Test #[0-9]+: ns\.typed/short\.case - Test #[0-9]+: ns\.typed/float\.case - Test #[0-9]+: ns\.typed/char\.case + Test #[0-9]+: typed\.case<short> + Test #[0-9]+: typed\.case<float> + Test #[0-9]+: typed\.case<char> + Test #[0-9]+: ns\.typed\.case<short> + Test #[0-9]+: ns\.typed\.case<float> + Test #[0-9]+: ns\.typed\.case<char> Total Tests: [0-9]+ diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt index e5b44a9482..c4620423d3 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt +++ b/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt @@ -19,18 +19,18 @@ Test project .* *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:disabled\.case!1 \.+\*+Not Run \(Disabled\) +[0-9.]+ sec *Start +[0-9]+: TEST:DISABLEDnotreally\.case!1 *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:DISABLEDnotreally\.case!1 \.+ +Passed +[0-9.]+ sec - *Start +[0-9]+: TEST:typed/short\.case!1 - *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed/short\.case!1 \.+ +Passed +[0-9.]+ sec - *Start +[0-9]+: TEST:typed/float\.case!1 - *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed/float\.case!1 \.+ +Passed +[0-9.]+ sec - *Start +[0-9]+: TEST:typed/char\.case!1 - *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed/char\.case!1 \.+ +Passed +[0-9.]+ sec - *Start +[0-9]+: TEST:ns\.typed/short\.case!1 - *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed/short\.case!1 \.+ +Passed +[0-9.]+ sec - *Start +[0-9]+: TEST:ns\.typed/float\.case!1 - *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed/float\.case!1 \.+ +Passed +[0-9.]+ sec - *Start +[0-9]+: TEST:ns\.typed/char\.case!1 - *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed/char\.case!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:typed\.case<short>!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed\.case<short>!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:typed\.case<float>!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed\.case<float>!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:typed\.case<char>!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed\.case<char>!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:ns\.typed\.case<short>!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed\.case<short>!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:ns\.typed\.case<float>!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed\.case<float>!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:ns\.typed\.case<char>!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed\.case<char>!1 \.+ +Passed +[0-9.]+ sec *Start +[0-9]+: TEST:value/test\.case/1!1 *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:value/test\.case/1!1 \.+ +Passed +[0-9.]+ sec *Start +[0-9]+: TEST:value/test\.case/"foo"!1 diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt index 71dba89493..8cdd1a0d81 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt +++ b/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt @@ -19,18 +19,18 @@ Test project .* *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:disabled\.case!2 \.+\*+Not Run \(Disabled\) +[0-9.]+ sec *Start +[0-9]+: TEST:DISABLEDnotreally\.case!2 *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:DISABLEDnotreally\.case!2 \.+ +Passed +[0-9.]+ sec - *Start +[0-9]+: TEST:typed/short\.case!2 - *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed/short\.case!2 \.+ +Passed +[0-9.]+ sec - *Start +[0-9]+: TEST:typed/float\.case!2 - *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed/float\.case!2 \.+ +Passed +[0-9.]+ sec - *Start +[0-9]+: TEST:typed/char\.case!2 - *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed/char\.case!2 \.+ +Passed +[0-9.]+ sec - *Start +[0-9]+: TEST:ns\.typed/short\.case!2 - *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed/short\.case!2 \.+ +Passed +[0-9.]+ sec - *Start +[0-9]+: TEST:ns\.typed/float\.case!2 - *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed/float\.case!2 \.+ +Passed +[0-9.]+ sec - *Start +[0-9]+: TEST:ns\.typed/char\.case!2 - *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed/char\.case!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:typed\.case<short>!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed\.case<short>!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:typed\.case<float>!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed\.case<float>!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:typed\.case<char>!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed\.case<char>!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:ns\.typed\.case<short>!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed\.case<short>!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:ns\.typed\.case<float>!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed\.case<float>!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:ns\.typed\.case<char>!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed\.case<char>!2 \.+ +Passed +[0-9.]+ sec *Start +[0-9]+: TEST:value/test\.case/1!2 *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:value/test\.case/1!2 \.+ +Passed +[0-9.]+ sec *Start +[0-9]+: TEST:value/test\.case/"foo"!2 diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test4-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test4-stdout.txt index 21f95e9ee9..b0f70e7391 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest-test4-stdout.txt +++ b/Tests/RunCMake/GoogleTest/GoogleTest-test4-stdout.txt @@ -1,16 +1,16 @@ Test project .* - *Start +[0-9]+: TEST:typed/short\.case!4 - *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed/short\.case!4 \.+ +Passed +[0-9.]+ sec - *Start +[0-9]+: TEST:typed/float\.case!4 - *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed/float\.case!4 \.+ +Passed +[0-9.]+ sec - *Start +[0-9]+: TEST:typed/char\.case!4 - *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed/char\.case!4 \.+ +Passed +[0-9.]+ sec - *Start +[0-9]+: TEST:ns\.typed/short\.case!4 - *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed/short\.case!4 \.+ +Passed +[0-9.]+ sec - *Start +[0-9]+: TEST:ns\.typed/float\.case!4 - *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed/float\.case!4 \.+ +Passed +[0-9.]+ sec - *Start +[0-9]+: TEST:ns\.typed/char\.case!4 - *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed/char\.case!4 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:typed\.case<short>!4 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed\.case<short>!4 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:typed\.case<float>!4 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed\.case<float>!4 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:typed\.case<char>!4 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:typed\.case<char>!4 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:ns\.typed\.case<short>!4 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed\.case<short>!4 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:ns\.typed\.case<float>!4 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed\.case<float>!4 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:ns\.typed\.case<char>!4 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed\.case<char>!4 \.+ +Passed +[0-9.]+ sec 100% tests passed, 0 tests failed out of [0-9]+ |