Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/google/googletest.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2021-09-20 19:34:56 +0300
committerdinord <dinor@google.com>2021-09-24 02:31:14 +0300
commit0570d97fb684452c96327e5e6e5ae02c14dbca29 (patch)
treeaad98d73fcbca4509d33eeaf0fb847c7677a1dbd
parentde34ef4e4c6cbfeff9310898d3a773f037ad46f0 (diff)
Googletest export
Do not attempt to continue running a test suite if it already failed during `SetUpTestSuite`. The suite already failed and running the tests might just add noise to the run, or even crash the process unnecessarily. Fixes #2187 PiperOrigin-RevId: 397770405
-rw-r--r--googletest/src/gtest.cc8
-rwxr-xr-xgoogletest/test/googletest-catch-exceptions-test.py10
-rw-r--r--googletest/test/googletest-output-test-golden-lin.txt20
-rw-r--r--googletest/test/googletest-output-test_.cc8
4 files changed, 38 insertions, 8 deletions
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index ece08817..44d5d5bf 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -3033,10 +3033,16 @@ void TestSuite::Run() {
internal::HandleExceptionsInMethodIfSupported(
this, &TestSuite::RunSetUpTestSuite, "SetUpTestSuite()");
+ const bool skip_all = ad_hoc_test_result().Failed();
+
start_timestamp_ = internal::GetTimeInMillis();
internal::Timer timer;
for (int i = 0; i < total_test_count(); i++) {
- GetMutableTestInfo(i)->Run();
+ if (skip_all) {
+ GetMutableTestInfo(i)->Skip();
+ } else {
+ GetMutableTestInfo(i)->Run();
+ }
if (GTEST_FLAG_GET(fail_fast) &&
GetMutableTestInfo(i)->result()->Failed()) {
for (int j = i + 1; j < total_test_count(); j++) {
diff --git a/googletest/test/googletest-catch-exceptions-test.py b/googletest/test/googletest-catch-exceptions-test.py
index 94a5b33f..442397a4 100755
--- a/googletest/test/googletest-catch-exceptions-test.py
+++ b/googletest/test/googletest-catch-exceptions-test.py
@@ -147,19 +147,19 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase):
self.assertTrue(
'CxxExceptionInConstructorTest::TearDownTestSuite() '
'called as expected.' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT)
- self.assertTrue(
+ self.assertFalse(
'CxxExceptionInSetUpTestSuiteTest constructor '
'called as expected.' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT)
- self.assertTrue(
+ self.assertFalse(
'CxxExceptionInSetUpTestSuiteTest destructor '
'called as expected.' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT)
- self.assertTrue(
+ self.assertFalse(
'CxxExceptionInSetUpTestSuiteTest::SetUp() '
'called as expected.' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT)
- self.assertTrue(
+ self.assertFalse(
'CxxExceptionInSetUpTestSuiteTest::TearDown() '
'called as expected.' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT)
- self.assertTrue(
+ self.assertFalse(
'CxxExceptionInSetUpTestSuiteTest test body '
'called as expected.' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT)
diff --git a/googletest/test/googletest-output-test-golden-lin.txt b/googletest/test/googletest-output-test-golden-lin.txt
index 3fab3b97..1f24fb79 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 88 tests from 41 test suites.
+[==========] Running 89 tests from 42 test suites.
[----------] Global test environment set-up.
FooEnvironment::SetUp() called.
BarEnvironment::SetUp() called.
@@ -956,6 +956,17 @@ Stack trace: (omitted)
~DynamicFixture()
[ FAILED ] BadDynamicFixture2.Derived
DynamicFixture::TearDownTestSuite
+[----------] 1 test from TestSuiteThatFailsToSetUp
+googletest-output-test_.cc:#: Failure
+Value of: false
+ Actual: false
+Expected: true
+Stack trace: (omitted)
+
+[ RUN ] TestSuiteThatFailsToSetUp.ShouldNotRun
+googletest-output-test_.cc:#: Skipped
+
+[ SKIPPED ] TestSuiteThatFailsToSetUp.ShouldNotRun
[----------] 1 test from PrintingFailingParams/FailingParamTest
[ RUN ] PrintingFailingParams/FailingParamTest.Fails/0
googletest-output-test_.cc:#: Failure
@@ -1032,8 +1043,10 @@ Failed
Expected fatal failure.
Stack trace: (omitted)
-[==========] 88 tests from 41 test suites ran.
+[==========] 89 tests from 42 test suites ran.
[ PASSED ] 31 tests.
+[ SKIPPED ] 1 test, listed below:
+[ SKIPPED ] TestSuiteThatFailsToSetUp.ShouldNotRun
[ FAILED ] 57 tests, listed below:
[ FAILED ] NonfatalFailureTest.EscapesStringOperands
[ FAILED ] NonfatalFailureTest.DiffForLongStrings
@@ -1094,6 +1107,9 @@ Stack trace: (omitted)
[ FAILED ] GoogleTestVerification.UninstantiatedTypeParameterizedTestSuite<DetectNotInstantiatedTypesTest>
57 FAILED TESTS
+[ FAILED ] TestSuiteThatFailsToSetUp: SetUpTestSuite or TearDownTestSuite
+
+ 1 FAILED TEST SUITE
 YOU HAVE 1 DISABLED TEST
Note: Google Test filter = FatalFailureTest.*:LoggingTest.*
diff --git a/googletest/test/googletest-output-test_.cc b/googletest/test/googletest-output-test_.cc
index 9e5465c9..b0ad52ca 100644
--- a/googletest/test/googletest-output-test_.cc
+++ b/googletest/test/googletest-output-test_.cc
@@ -1060,6 +1060,14 @@ class BarEnvironment : public testing::Environment {
}
};
+class TestSuiteThatFailsToSetUp : public testing::Test {
+ public:
+ static void SetUpTestSuite() { EXPECT_TRUE(false); }
+};
+TEST_F(TestSuiteThatFailsToSetUp, ShouldNotRun) {
+ std::abort();
+}
+
// The main function.
//
// The idea is to use Google Test to run all the tests we have defined (some