diff options
author | Brad King <brad.king@kitware.com> | 2020-05-06 13:31:42 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-05-06 13:31:53 (GMT) |
commit | b86dfa205686a13550cac0ab89b4f27951229f4d (patch) | |
tree | 3aa472a172d7975913d497c0adff0df00052a2fe | |
parent | f6178df27dfbf535e3eabdbe2e57649a989169aa (diff) | |
parent | 839a1010a3e2123e197e2c9e0ed8e5ad58988622 (diff) | |
download | CMake-b86dfa205686a13550cac0ab89b4f27951229f4d.zip CMake-b86dfa205686a13550cac0ab89b4f27951229f4d.tar.gz CMake-b86dfa205686a13550cac0ab89b4f27951229f4d.tar.bz2 |
Merge topic 'gtest-space-in-parameter'
839a1010a3 GoogleTestAddTests: Fix output processing
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4694
-rw-r--r-- | Modules/GoogleTestAddTests.cmake | 20 | ||||
-rw-r--r-- | Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt | 40 | ||||
-rw-r--r-- | Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt | 44 | ||||
-rw-r--r-- | Tests/RunCMake/GoogleTest/fake_gtest.cpp | 4 |
4 files changed, 68 insertions, 40 deletions
diff --git a/Modules/GoogleTestAddTests.cmake b/Modules/GoogleTestAddTests.cmake index 499332f..4af62ed 100644 --- a/Modules/GoogleTestAddTests.cmake +++ b/Modules/GoogleTestAddTests.cmake @@ -83,6 +83,8 @@ function(gtest_discover_tests_impl) ) endif() + # Preserve semicolon in test-parameters + string(REPLACE [[;]] [[\;]] output "${output}") string(REPLACE "\n" ";" output "${output}") # Parse output @@ -114,9 +116,19 @@ function(gtest_discover_tests_impl) else() unset(TEST_XML_OUTPUT_PARAM) endif() + + # sanitize test name for further processing downstream + set(testname "${prefix}${pretty_suite}.${pretty_test}${suffix}") + # escape \ + string(REPLACE [[\]] [[\\]] testname "${testname}") + # escape ; + string(REPLACE [[;]] [[\;]] testname "${testname}") + # escape $ + string(REPLACE [[$]] [[\$]] testname "${testname}") + # ...and add to script add_command(add_test - "${prefix}${pretty_suite}.${pretty_test}${suffix}" + "${testname}" ${_TEST_EXECUTOR} "${_TEST_EXECUTABLE}" "--gtest_filter=${suite}.${test}" @@ -126,18 +138,18 @@ function(gtest_discover_tests_impl) ) if(suite MATCHES "^DISABLED" OR test MATCHES "^DISABLED") add_command(set_tests_properties - "${prefix}${pretty_suite}.${pretty_test}${suffix}" + "${testname}" PROPERTIES DISABLED TRUE ) endif() add_command(set_tests_properties - "${prefix}${pretty_suite}.${pretty_test}${suffix}" + "${testname}" PROPERTIES WORKING_DIRECTORY "${_TEST_WORKING_DIR}" SKIP_REGULAR_EXPRESSION "\\\\[ SKIPPED \\\\]" ${properties} ) - list(APPEND tests_buffer "${prefix}${pretty_suite}.${pretty_test}${suffix}") + list(APPEND tests_buffer "${testname}") list(LENGTH tests_buffer tests_buffer_length) if(${tests_buffer_length} GREATER "250") flush_tests_buffer() diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt index 5f7753d..7fb3919 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt +++ b/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt @@ -1,22 +1,28 @@ Test project .* - Start 1: TEST:basic\.case_foo!1 -1/8 Test #1: TEST:basic\.case_foo!1 \.+ +Passed +[0-9.]+ sec - Start 2: TEST:basic\.case_bar!1 -2/8 Test #2: TEST:basic\.case_bar!1 \.+ +Passed +[0-9.]+ sec - Start 3: TEST:basic\.disabled_case!1 -3/8 Test #3: TEST:basic\.disabled_case!1 \.+\*+Not Run \(Disabled\) +[0-9.]+ sec - Start 4: TEST:disabled\.case!1 -4/8 Test #4: TEST:disabled\.case!1 \.+\*+Not Run \(Disabled\) +[0-9.]+ sec - Start 5: TEST:typed/short\.case!1 -5/8 Test #5: TEST:typed/short\.case!1 \.+ +Passed +[0-9.]+ sec - Start 6: TEST:typed/float\.case!1 -6/8 Test #6: TEST:typed/float\.case!1 \.+ +Passed +[0-9.]+ sec - Start 7: TEST:value/test\.case/1!1 -7/8 Test #7: TEST:value/test\.case/1!1 \.+ +Passed +[0-9.]+ sec - Start 8: TEST:value/test\.case/"foo"!1 -8/8 Test #8: TEST:value/test\.case/"foo"!1 \.+ +Passed +[0-9.]+ sec + Start 1: TEST:basic\.case_foo!1 + 1/11 Test #1: TEST:basic\.case_foo!1 \.+ +Passed +[0-9.]+ sec + Start 2: TEST:basic\.case_bar!1 + 2/11 Test #2: TEST:basic\.case_bar!1 \.+ +Passed +[0-9.]+ sec + Start 3: TEST:basic\.disabled_case!1 + 3/11 Test #3: TEST:basic\.disabled_case!1 \.+\*+Not Run \(Disabled\) +[0-9.]+ sec + Start 4: TEST:disabled\.case!1 + 4/11 Test #4: TEST:disabled\.case!1 \.+\*+Not Run \(Disabled\) +[0-9.]+ sec + Start 5: TEST:typed/short\.case!1 + 5/11 Test #5: TEST:typed/short\.case!1 \.+ +Passed +[0-9.]+ sec + Start 6: TEST:typed/float\.case!1 + 6/11 Test #6: TEST:typed/float\.case!1 \.+ +Passed +[0-9.]+ sec + Start 7: TEST:value/test\.case/1!1 + 7/11 Test #7: TEST:value/test\.case/1!1 \.+ +Passed +[0-9.]+ sec + Start 8: TEST:value/test\.case/"foo"!1 + 8/11 Test #8: TEST:value/test\.case/"foo"!1 \.+ +Passed +[0-9.]+ sec + Start 9: TEST:param/special\.case/"semicolon;"!1 + 9/11 Test #9: TEST:param/special\.case/"semicolon;"!1 \.+ +Passed +[0-9.]+ sec + Start 10: TEST:param/special\.case/"backslash\\"!1 +10/11 Test #10: TEST:param/special\.case/"backslash\\"!1 \.+ +Passed +[0-9.]+ sec + Start 11: TEST:param/special\.case/"\$\{var\}"!1 +11/11 Test #11: TEST:param/special\.case/"\$\{var\}"!1 \.+ +Passed +[0-9.]+ sec -100% tests passed, 0 tests failed out of 6 +100% tests passed, 0 tests failed out of 9 Total Test time \(real\) = +[0-9.]+ sec diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt index 960c0b9..58c4d10 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt +++ b/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt @@ -1,25 +1,31 @@ Test project .* - Start 9: TEST:basic\.case_foo!2 -1/8 Test #9: TEST:basic\.case_foo!2 \.+ +Passed +[0-9.]+ sec - Start 10: TEST:basic\.case_bar!2 -2/8 Test #10: TEST:basic\.case_bar!2 \.+ +Passed +[0-9.]+ sec - Start 11: TEST:basic\.disabled_case!2 -3/8 Test #11: TEST:basic\.disabled_case!2 \.+\*+Not Run \(Disabled\) +[0-9.]+ sec - Start 12: TEST:disabled\.case!2 -4/8 Test #12: TEST:disabled\.case!2 \.+\*+Not Run \(Disabled\) +[0-9.]+ sec - Start 13: TEST:typed/short\.case!2 -5/8 Test #13: TEST:typed/short\.case!2 \.+ +Passed +[0-9.]+ sec - Start 14: TEST:typed/float\.case!2 -6/8 Test #14: TEST:typed/float\.case!2 \.+ +Passed +[0-9.]+ sec - Start 15: TEST:value/test\.case/1!2 -7/8 Test #15: TEST:value/test\.case/1!2 \.+ +Passed +[0-9.]+ sec - Start 16: TEST:value/test\.case/"foo"!2 -8/8 Test #16: TEST:value/test\.case/"foo"!2 \.+ +Passed +[0-9.]+ sec + Start 12: TEST:basic\.case_foo!2 + 1/11 Test #12: TEST:basic\.case_foo!2 \.+ +Passed +[0-9.]+ sec + Start 13: TEST:basic\.case_bar!2 + 2/11 Test #13: TEST:basic\.case_bar!2 \.+ +Passed +[0-9.]+ sec + Start 14: TEST:basic\.disabled_case!2 + 3/11 Test #14: TEST:basic\.disabled_case!2 \.+\*+Not Run \(Disabled\) +[0-9.]+ sec + Start 15: TEST:disabled\.case!2 + 4/11 Test #15: TEST:disabled\.case!2 \.+\*+Not Run \(Disabled\) +[0-9.]+ sec + Start 16: TEST:typed/short\.case!2 + 5/11 Test #16: TEST:typed/short\.case!2 \.+ +Passed +[0-9.]+ sec + Start 17: TEST:typed/float\.case!2 + 6/11 Test #17: TEST:typed/float\.case!2 \.+ +Passed +[0-9.]+ sec + Start 18: TEST:value/test\.case/1!2 + 7/11 Test #18: TEST:value/test\.case/1!2 \.+ +Passed +[0-9.]+ sec + Start 19: TEST:value/test\.case/"foo"!2 + 8/11 Test #19: TEST:value/test\.case/"foo"!2 \.+ +Passed +[0-9.]+ sec + Start 20: TEST:param/special\.case/"semicolon;"!2 + 9/11 Test #20: TEST:param/special\.case/"semicolon;"!2 \.+ +Passed +[0-9.]+ sec + Start 21: TEST:param/special\.case/"backslash\\"!2 +10/11 Test #21: TEST:param/special\.case/"backslash\\"!2 \.+ +Passed +[0-9.]+ sec + Start 22: TEST:param/special\.case/"\$\{var\}"!2 +11/11 Test #22: TEST:param/special\.case/"\$\{var\}"!2 \.+ +Passed +[0-9.]+ sec -100% tests passed, 0 tests failed out of 6 +100% tests passed, 0 tests failed out of 9 Total Test time \(real\) = +[0-9.]+ sec The following tests did not run: -.*11 - TEST:basic\.disabled_case!2 \(Disabled\) -.*12 - TEST:disabled\.case!2 \(Disabled\) +.*14 - TEST:basic\.disabled_case!2 \(Disabled\) +.*15 - TEST:disabled\.case!2 \(Disabled\) diff --git a/Tests/RunCMake/GoogleTest/fake_gtest.cpp b/Tests/RunCMake/GoogleTest/fake_gtest.cpp index f1bd7ef..a8127bf 100644 --- a/Tests/RunCMake/GoogleTest/fake_gtest.cpp +++ b/Tests/RunCMake/GoogleTest/fake_gtest.cpp @@ -21,6 +21,10 @@ int main(int argc, char** argv) std::cout << "value/test." << std::endl; std::cout << " case/0 # GetParam() = 1" << std::endl; std::cout << " case/1 # GetParam() = \"foo\"" << std::endl; + std::cout << "param/special." << std::endl; + std::cout << " case/0 # GetParam() = \"semicolon;\"" << std::endl; + std::cout << " case/1 # GetParam() = \"backslash\\\"" << std::endl; + std::cout << " case/2 # GetParam() = \"${var}\"" << std::endl; return 0; } |