From 9aa9032266b0c4cd8219d637a97b527dc86e2f85 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 3 Mar 2023 10:30:59 -0500 Subject: GoogleTest: Restore suite name for type-parametrized tests Fix a regression from commit 073dd1bd81 (GoogleTest: Change format for typed tests, 2022-02-07, v3.23.0-rc1~4^2) in the suite name detection. Co-authored-by: Evgeniy Shcherbina Fixes: #24563 --- Modules/GoogleTestAddTests.cmake | 2 +- ...oogleTest-discovery-arg-change-typed-stdout.txt | 3 +++ .../GoogleTest/GoogleTest-test1-stdout.txt | 26 ++++++++++++++++++++++ .../GoogleTest/GoogleTest-test2-stdout.txt | 26 ++++++++++++++++++++++ .../GoogleTest/GoogleTest-test4-stdout.txt | 6 +++++ Tests/RunCMake/GoogleTest/fake_gtest.cpp | 9 +++++--- 6 files changed, 68 insertions(+), 4 deletions(-) diff --git a/Modules/GoogleTestAddTests.cmake b/Modules/GoogleTestAddTests.cmake index 2bd0cc9..de0f7d6 100644 --- a/Modules/GoogleTestAddTests.cmake +++ b/Modules/GoogleTestAddTests.cmake @@ -134,7 +134,7 @@ function(gtest_discover_tests_impl) # Module; remove trailing '.' to get just the name... string(REGEX REPLACE "\\.( *#.*)?$" "" suite "${line}") if(line MATCHES "#") - string(REGEX REPLACE "/.*" "" pretty_suite "${line}") + string(REGEX REPLACE "/[0-9].*" "" pretty_suite "${line}") if(NOT _NO_PRETTY_TYPES) string(REGEX REPLACE ".*/[0-9]+[ .#]+TypeParam = (.*)" "\\1" type_parameter "${line}") else() 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 c4545ca..d4b4fcf 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change-typed-stdout.txt +++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change-typed-stdout.txt @@ -5,5 +5,8 @@ Test project .*/Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change Test #[0-9]+: ns\.typed\.case Test #[0-9]+: ns\.typed\.case Test #[0-9]+: ns\.typed\.case + Test #[0-9]+: prefix/typed\.case + Test #[0-9]+: prefix/typed\.case + Test #[0-9]+: prefix/typed\.case Total Tests: [0-9]+ diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt index c462042..4fa2b5c 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt +++ b/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt @@ -31,6 +31,12 @@ Test project .* *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed\.case!1 \.+ +Passed +[0-9.]+ sec *Start +[0-9]+: TEST:ns\.typed\.case!1 *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed\.case!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/typed\.case!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/typed\.case!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/typed\.case!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/typed\.case!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/typed\.case!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/typed\.case!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 @@ -39,6 +45,10 @@ Test project .* *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.value/test\.case/1!1 \.+ +Passed +[0-9.]+ sec *Start +[0-9]+: TEST:ns\.value/test\.case/"foo"!1 *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.value/test\.case/"foo"!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/value/test\.case/1!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/value/test\.case/1!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/value/test\.case/"foo"!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/value/test\.case/"foo"!1 \.+ +Passed +[0-9.]+ sec *Start +[0-9]+: TEST:param/special\.case/"semicolon;"!1 *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:param/special\.case/"semicolon;"!1 \.+ +Passed +[0-9.]+ sec *Start +[0-9]+: TEST:param/special\.case/"backslash\\"!1 @@ -71,6 +81,22 @@ Test project .* *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.param/special\.case/"__csb___text"!1 \.+ +Passed +[0-9.]+ sec *Start +[0-9]+: TEST:ns\.param/special\.case/"S o m e "!1 *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.param/special\.case/"S o m e "!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/param/special\.case/"semicolon;"!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/param/special\.case/"semicolon;"!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/param/special\.case/"backslash\\"!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/param/special\.case/"backslash\\"!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/param/special\.case/"\${var}"!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/param/special\.case/"\${var}"!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/param/special\.case/'\['!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/param/special\.case/'\['!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/param/special\.case/"\]\]=\]"!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/param/special\.case/"\]\]=\]"!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/param/special\.case/"__osbtext"!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/param/special\.case/"__osbtext"!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/param/special\.case/"__csb___text"!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/param/special\.case/"__csb___text"!1 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/param/special\.case/"S o m e "!1 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/param/special\.case/"S o m e "!1 \.+ +Passed +[0-9.]+ sec 100% tests passed, 0 tests failed out of [0-9]+ diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt index 8cdd1a0..99b641b 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt +++ b/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt @@ -31,6 +31,12 @@ Test project .* *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed\.case!2 \.+ +Passed +[0-9.]+ sec *Start +[0-9]+: TEST:ns\.typed\.case!2 *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed\.case!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/typed\.case!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/typed\.case!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/typed\.case!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/typed\.case!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/typed\.case!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/typed\.case!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 @@ -39,6 +45,10 @@ Test project .* *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.value/test\.case/1!2 \.+ +Passed +[0-9.]+ sec *Start +[0-9]+: TEST:ns\.value/test\.case/"foo"!2 *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.value/test\.case/"foo"!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/value/test\.case/1!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/value/test\.case/1!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/value/test\.case/"foo"!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/value/test\.case/"foo"!2 \.+ +Passed +[0-9.]+ sec *Start +[0-9]+: TEST:param/special\.case/"semicolon;"!2 *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:param/special\.case/"semicolon;"!2 \.+ +Passed +[0-9.]+ sec *Start +[0-9]+: TEST:param/special\.case/"backslash\\"!2 @@ -71,6 +81,22 @@ Test project .* *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.param/special\.case/"__csb___text"!2 \.+ +Passed +[0-9.]+ sec *Start +[0-9]+: TEST:ns\.param/special\.case/"S o m e "!2 *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.param/special\.case/"S o m e "!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/param/special\.case/"semicolon;"!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/param/special\.case/"semicolon;"!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/param/special\.case/"backslash\\"!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/param/special\.case/"backslash\\"!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/param/special\.case/"\${var}"!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/param/special\.case/"\${var}"!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/param/special\.case/'\['!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/param/special\.case/'\['!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/param/special\.case/"\]\]=\]"!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/param/special\.case/"\]\]=\]"!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/param/special\.case/"__osbtext"!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/param/special\.case/"__osbtext"!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/param/special\.case/"__csb___text"!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/param/special\.case/"__csb___text"!2 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/param/special\.case/"S o m e "!2 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/param/special\.case/"S o m e "!2 \.+ +Passed +[0-9.]+ sec 100% tests passed, 0 tests failed out of [0-9]+ diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test4-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test4-stdout.txt index b0f70e7..d9203bc 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest-test4-stdout.txt +++ b/Tests/RunCMake/GoogleTest/GoogleTest-test4-stdout.txt @@ -11,6 +11,12 @@ Test project .* *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed\.case!4 \.+ +Passed +[0-9.]+ sec *Start +[0-9]+: TEST:ns\.typed\.case!4 *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:ns\.typed\.case!4 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/typed\.case!4 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/typed\.case!4 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/typed\.case!4 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/typed\.case!4 \.+ +Passed +[0-9.]+ sec + *Start +[0-9]+: TEST:prefix/typed\.case!4 + *[0-9]+/[0-9]+ +Test +#[0-9]+: TEST:prefix/typed\.case!4 \.+ +Passed +[0-9.]+ sec 100% tests passed, 0 tests failed out of [0-9]+ diff --git a/Tests/RunCMake/GoogleTest/fake_gtest.cpp b/Tests/RunCMake/GoogleTest/fake_gtest.cpp index e6f74aa..9236bd1 100644 --- a/Tests/RunCMake/GoogleTest/fake_gtest.cpp +++ b/Tests/RunCMake/GoogleTest/fake_gtest.cpp @@ -34,7 +34,8 @@ int main(int argc, char** argv) std::cout << " case" << std::endl; } if (!is_basic_only) { - const char* typed_suite_names[] = { "typed", "ns.typed" }; + const char* typed_suite_names[] = { "typed", "ns.typed", + "prefix/typed" }; for (size_t i = 0; i < ARRAY_SIZE(typed_suite_names); i++) { std::cout << typed_suite_names[i] << "/0. # TypeParam = short\n"; std::cout << " case" << std::endl; @@ -45,13 +46,15 @@ int main(int argc, char** argv) } } if (!is_basic_only && !is_typed_only) { - const char* value_suite_names[] = { "value", "ns.value" }; + const char* value_suite_names[] = { "value", "ns.value", + "prefix/value" }; for (size_t i = 0; i < ARRAY_SIZE(value_suite_names); i++) { std::cout << value_suite_names[i] << "/test." << std::endl; std::cout << " case/0 # GetParam() = 1" << std::endl; std::cout << " case/1 # GetParam() = \"foo\"" << std::endl; } - const char* param_suite_names[] = { "param", "ns.param" }; + const char* param_suite_names[] = { "param", "ns.param", + "prefix/param" }; for (size_t j = 0; j < ARRAY_SIZE(param_suite_names); j++) { std::cout << param_suite_names[j] << "/special." << std::endl; std::cout << " case/0 # GetParam() = \"semicolon;\"" << std::endl; -- cgit v0.12