summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Stein <alexander.stein@mailbox.org>2020-04-08 18:40:00 (GMT)
committerBrad King <brad.king@kitware.com>2020-04-10 13:43:39 (GMT)
commit89a843d6ea35a2d0704a5fbc13858e5b84546744 (patch)
tree2d8b45174e81adc93650e3dd767f0ac53caae99d
parent98868dad1c00ceb60eec81b9e20d684ff3c61a85 (diff)
downloadCMake-89a843d6ea35a2d0704a5fbc13858e5b84546744.zip
CMake-89a843d6ea35a2d0704a5fbc13858e5b84546744.tar.gz
CMake-89a843d6ea35a2d0704a5fbc13858e5b84546744.tar.bz2
GoogleTest: Add testcase for skipped tests
This simply runs a mocked test case which uses the prefix for signaling a skipped test. CTest's output is checked for a skipped test result.
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-skip-timeout-stdout.txt10
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest.cmake6
-rw-r--r--Tests/RunCMake/GoogleTest/RunCMakeTest.cmake14
-rw-r--r--Tests/RunCMake/GoogleTest/skip_test.cpp18
4 files changed, 48 insertions, 0 deletions
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-skip-timeout-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-skip-timeout-stdout.txt
new file mode 100644
index 0000000..eeecb6a
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-skip-timeout-stdout.txt
@@ -0,0 +1,10 @@
+Test project .*
+ Start 20: skip_test.test1
+1/1 Test #20: skip_test.test1 \.+\*\*\*Skipped +[0-9.]+ sec
+
+100% tests passed, 0 tests failed out of 1
+
+Total Test time \(real\) = +[0-9.]+ sec
+
+The following tests did not run:
+.*20 - skip_test\.test1 \(Skipped\)
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest.cmake b/Tests/RunCMake/GoogleTest/GoogleTest.cmake
index 4bc6b9d..fca292a 100644
--- a/Tests/RunCMake/GoogleTest/GoogleTest.cmake
+++ b/Tests/RunCMake/GoogleTest/GoogleTest.cmake
@@ -49,3 +49,9 @@ gtest_discover_tests(
DISCOVERY_TIMEOUT 20
PROPERTIES TIMEOUT 2
)
+
+add_executable(skip_test skip_test.cpp)
+
+gtest_discover_tests(
+ skip_test
+)
diff --git a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake
index 6b9d458..efd22be 100644
--- a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake
+++ b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake
@@ -60,6 +60,20 @@ function(run_GoogleTest DISCOVERY_MODE)
-R property_timeout\\.case_with_discovery
--no-label-summary
)
+
+ run_cmake_command(GoogleTest-build
+ ${CMAKE_COMMAND}
+ --build .
+ --config Debug
+ --target skip_test
+ )
+
+ run_cmake_command(GoogleTest-skip-test
+ ${CMAKE_CTEST_COMMAND}
+ -C Debug
+ -R skip_test
+ --no-label-summary
+ )
endfunction()
function(run_GoogleTestXML DISCOVERY_MODE)
diff --git a/Tests/RunCMake/GoogleTest/skip_test.cpp b/Tests/RunCMake/GoogleTest/skip_test.cpp
new file mode 100644
index 0000000..2bc9fe1
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/skip_test.cpp
@@ -0,0 +1,18 @@
+#include <iostream>
+#include <string>
+
+int main(int argc, char** argv)
+{
+ // Note: GoogleTest.cmake doesn't actually depend on Google Test as such;
+ // it only requires that we produces output in the expected format when
+ // invoked with --gtest_list_tests. Thus, we fake that here. This allows us
+ // to test the module without actually needing Google Test.
+ if (argc > 1 && std::string(argv[1]) == "--gtest_list_tests") {
+ std::cout << "skip_test." << std::endl;
+ std::cout << " test1" << std::endl;
+ return 0;
+ }
+
+ std::cout << "[ SKIPPED ] skip_test.test1" << std::endl;
+ return 0;
+}