From f28f738bd2be2ed790bb5b4c794773b7a627d3f2 Mon Sep 17 00:00:00 2001 From: Evgeniy Shcherbina Date: Fri, 4 Feb 2022 13:03:30 +0300 Subject: GoogleTest: Fix type param tests for suites with many cases When there were many cases (two digits or more) the "prettier" would fail to recognize the pretty part leaving the test name unprocessed. The fix made sure the processing would work correctly, irrespective of the case number. Before the fix, for the following input: TypedSuite/1. # TypeParam = int case TypedSuite/10. # TypeParam = char case The output would be: TypedSuite/int.case TypedSuite/10. # TypeParam = char.case Now the output will be: TypedSuite/int.case TypedSuite/char.case --- Modules/GoogleTestAddTests.cmake | 2 +- .../GoogleTest-discovery-arg-change-typed-stdout.txt | 12 +++++++----- Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt | 4 ++++ Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt | 4 ++++ Tests/RunCMake/GoogleTest/GoogleTest-test4-stdout.txt | 4 ++++ Tests/RunCMake/GoogleTest/fake_gtest.cpp | 8 ++++---- 6 files changed, 24 insertions(+), 10 deletions(-) diff --git a/Modules/GoogleTestAddTests.cmake b/Modules/GoogleTestAddTests.cmake index a10b5d0..671127a 100644 --- a/Modules/GoogleTestAddTests.cmake +++ b/Modules/GoogleTestAddTests.cmake @@ -136,7 +136,7 @@ function(gtest_discover_tests_impl) # 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}") + string(REGEX REPLACE "/[0-9]+\\.+ +#.*= +" "/" pretty_suite "${line}") else() set(pretty_suite "${suite}") endif() 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 fe8f273..f21e579 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change-typed-stdout.txt +++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change-typed-stdout.txt @@ -1,7 +1,9 @@ Test project .*/Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change - Test #1: typed/short\.case - Test #2: typed/float\.case - Test #3: ns\.typed/short\.case - Test #4: ns\.typed/float\.case + 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 -Total Tests: 4 +Total Tests: [0-9]+ diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt index 01b39c3..e5b44a9 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt +++ b/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt @@ -23,10 +23,14 @@ Test project .* *[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: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 796e20c..71dba89 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt +++ b/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt @@ -23,10 +23,14 @@ Test project .* *[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: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 0f7dde7..21f95e9 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest-test4-stdout.txt +++ b/Tests/RunCMake/GoogleTest/GoogleTest-test4-stdout.txt @@ -3,10 +3,14 @@ Test project .* *[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 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 183e106..e6f74aa 100644 --- a/Tests/RunCMake/GoogleTest/fake_gtest.cpp +++ b/Tests/RunCMake/GoogleTest/fake_gtest.cpp @@ -36,11 +36,11 @@ int main(int argc, char** argv) if (!is_basic_only) { const char* typed_suite_names[] = { "typed", "ns.typed" }; for (size_t i = 0; i < ARRAY_SIZE(typed_suite_names); i++) { - std::cout << typed_suite_names[i] << "/0. # TypeParam = short" - << std::endl; + std::cout << typed_suite_names[i] << "/0. # TypeParam = short\n"; std::cout << " case" << std::endl; - std::cout << typed_suite_names[i] << "/1. # TypeParam = float" - << std::endl; + std::cout << typed_suite_names[i] << "/1. # TypeParam = float\n"; + std::cout << " case" << std::endl; + std::cout << typed_suite_names[i] << "/42. # TypeParam = char\n"; std::cout << " case" << std::endl; } } -- cgit v0.12