aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDino Radakovic <dinor@google.com>2023-06-14 06:40:34 -0700
committerCopybara-Service <copybara-worker@google.com>2023-06-14 06:41:11 -0700
commit4c7aee827e16aa338189b88f6e3aa6d3d927dba4 (patch)
tree774787f82888ff578ee8d0fb88ca1e92b2e696fe
parente9078161e6d35e31535b3d76086ffd5714050a1b (diff)
downloadgoogletest-4c7aee827e16aa338189b88f6e3aa6d3d927dba4.zip
googletest-4c7aee827e16aa338189b88f6e3aa6d3d927dba4.tar.gz
googletest-4c7aee827e16aa338189b88f6e3aa6d3d927dba4.tar.bz2
Skip entire test suite with `GTEST_SKIP()` in `SetUpTestSuite`
Fixes #4273 PiperOrigin-RevId: 540254167 Change-Id: I2555740d10284223539035bf73f88554fcf73f8a
-rw-r--r--googletest/src/gtest.cc3
-rw-r--r--googletest/test/googletest-output-test-golden-lin.txt16
-rw-r--r--googletest/test/googletest-output-test_.cc6
3 files changed, 21 insertions, 4 deletions
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index fb7512c..a88ac25 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -3019,7 +3019,8 @@ void TestSuite::Run() {
internal::HandleExceptionsInMethodIfSupported(
this, &TestSuite::RunSetUpTestSuite, "SetUpTestSuite()");
- const bool skip_all = ad_hoc_test_result().Failed();
+ const bool skip_all =
+ ad_hoc_test_result().Failed() || ad_hoc_test_result().Skipped();
start_timestamp_ = internal::GetTimeInMillis();
internal::Timer timer;
diff --git a/googletest/test/googletest-output-test-golden-lin.txt b/googletest/test/googletest-output-test-golden-lin.txt
index 1f24fb7..6ddf822 100644
--- a/googletest/test/googletest-output-test-golden-lin.txt
+++ b/googletest/test/googletest-output-test-golden-lin.txt
@@ -12,7 +12,7 @@ Expected equality of these values:
3
Stack trace: (omitted)
-[==========] Running 89 tests from 42 test suites.
+[==========] Running 90 tests from 43 test suites.
[----------] Global test environment set-up.
FooEnvironment::SetUp() called.
BarEnvironment::SetUp() called.
@@ -967,6 +967,15 @@ Stack trace: (omitted)
googletest-output-test_.cc:#: Skipped
[ SKIPPED ] TestSuiteThatFailsToSetUp.ShouldNotRun
+[----------] 1 test from TestSuiteThatSkipsInSetUp
+googletest-output-test_.cc:#: Skipped
+Skip entire test suite
+Stack trace: (omitted)
+
+[ RUN ] TestSuiteThatSkipsInSetUp.ShouldNotRun
+googletest-output-test_.cc:#: Skipped
+
+[ SKIPPED ] TestSuiteThatSkipsInSetUp.ShouldNotRun
[----------] 1 test from PrintingFailingParams/FailingParamTest
[ RUN ] PrintingFailingParams/FailingParamTest.Fails/0
googletest-output-test_.cc:#: Failure
@@ -1043,10 +1052,11 @@ Failed
Expected fatal failure.
Stack trace: (omitted)
-[==========] 89 tests from 42 test suites ran.
+[==========] 90 tests from 43 test suites ran.
[ PASSED ] 31 tests.
-[ SKIPPED ] 1 test, listed below:
+[ SKIPPED ] 2 tests, listed below:
[ SKIPPED ] TestSuiteThatFailsToSetUp.ShouldNotRun
+[ SKIPPED ] TestSuiteThatSkipsInSetUp.ShouldNotRun
[ FAILED ] 57 tests, listed below:
[ FAILED ] NonfatalFailureTest.EscapesStringOperands
[ FAILED ] NonfatalFailureTest.DiffForLongStrings
diff --git a/googletest/test/googletest-output-test_.cc b/googletest/test/googletest-output-test_.cc
index f1facf5..e3560c0 100644
--- a/googletest/test/googletest-output-test_.cc
+++ b/googletest/test/googletest-output-test_.cc
@@ -1007,6 +1007,12 @@ class TestSuiteThatFailsToSetUp : public testing::Test {
};
TEST_F(TestSuiteThatFailsToSetUp, ShouldNotRun) { std::abort(); }
+class TestSuiteThatSkipsInSetUp : public testing::Test {
+ public:
+ static void SetUpTestSuite() { GTEST_SKIP() << "Skip entire test suite"; }
+};
+TEST_F(TestSuiteThatSkipsInSetUp, ShouldNotRun) { std::abort(); }
+
// The main function.
//
// The idea is to use Google Test to run all the tests we have defined (some