summaryrefslogtreecommitdiffstats
path: root/googletest
diff options
context:
space:
mode:
Diffstat (limited to 'googletest')
-rw-r--r--googletest/src/gtest.cc2
-rw-r--r--googletest/test/googletest-global-environment-unittest.py16
-rw-r--r--googletest/test/googletest-listener-test.cc1
-rw-r--r--googletest/test/gtest_repeat_test.cc4
4 files changed, 15 insertions, 8 deletions
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index f8a291a..04266dc 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -317,7 +317,7 @@ GTEST_DEFINE_int32_(
GTEST_DEFINE_bool_(
recreate_environments_when_repeating,
testing::internal::BoolFromGTestEnv("recreate_environments_when_repeating",
- true),
+ false),
"Controls whether global test environments are recreated for each repeat "
"of the tests. If set to false the global test environments are only set "
"up once, for the first iteration, and only torn down once, for the last. "
diff --git a/googletest/test/googletest-global-environment-unittest.py b/googletest/test/googletest-global-environment-unittest.py
index ef2cfb8..2657934 100644
--- a/googletest/test/googletest-global-environment-unittest.py
+++ b/googletest/test/googletest-global-environment-unittest.py
@@ -71,10 +71,13 @@ class GTestGlobalEnvironmentUnitTest(gtest_test_utils.TestCase):
def testEnvironmentSetUpAndTornDownForEachRepeat(self):
"""Tests the behavior of test environments and gtest_repeat."""
- txt = RunAndReturnOutput(['--gtest_repeat=2'])
+ # When --gtest_recreate_environments_when_repeating is true, the global test
+ # environment should be set up and torn down for each iteration.
+ txt = RunAndReturnOutput([
+ '--gtest_repeat=2',
+ '--gtest_recreate_environments_when_repeating=true',
+ ])
- # By default, with gtest_repeat=2, the global test environment should be set
- # up and torn down for each iteration.
expected_pattern = ('(.|\n)*'
r'Repeating all tests \(iteration 1\)'
'(.|\n)*'
@@ -97,13 +100,12 @@ class GTestGlobalEnvironmentUnitTest(gtest_test_utils.TestCase):
def testEnvironmentSetUpAndTornDownOnce(self):
"""Tests environment and --gtest_recreate_environments_when_repeating."""
+ # By default the environment should only be set up and torn down once, at
+ # the start and end of the test respectively.
txt = RunAndReturnOutput([
- '--gtest_repeat=2', '--gtest_recreate_environments_when_repeating=false'
+ '--gtest_repeat=2',
])
- # When --gtest_recreate_environments_when_repeating is false, the test
- # environment should only be set up and torn down once, at the start and
- # end of the test respectively.
expected_pattern = ('(.|\n)*'
r'Repeating all tests \(iteration 1\)'
'(.|\n)*'
diff --git a/googletest/test/googletest-listener-test.cc b/googletest/test/googletest-listener-test.cc
index 9d6c9ca..e7f9b13 100644
--- a/googletest/test/googletest-listener-test.cc
+++ b/googletest/test/googletest-listener-test.cc
@@ -285,6 +285,7 @@ int main(int argc, char **argv) {
<< "AddGlobalTestEnvironment should not generate any events itself.";
GTEST_FLAG_SET(repeat, 2);
+ GTEST_FLAG_SET(recreate_environments_when_repeating, true);
int ret_val = RUN_ALL_TESTS();
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
diff --git a/googletest/test/gtest_repeat_test.cc b/googletest/test/gtest_repeat_test.cc
index c7af3ef..6b10048 100644
--- a/googletest/test/gtest_repeat_test.cc
+++ b/googletest/test/gtest_repeat_test.cc
@@ -142,6 +142,7 @@ void TestRepeatUnspecified() {
// Tests the behavior of Google Test when --gtest_repeat has the given value.
void TestRepeat(int repeat) {
GTEST_FLAG_SET(repeat, repeat);
+ GTEST_FLAG_SET(recreate_environments_when_repeating, true);
ResetCounts();
GTEST_CHECK_INT_EQ_(repeat > 0 ? 1 : 0, RUN_ALL_TESTS());
@@ -152,6 +153,7 @@ void TestRepeat(int repeat) {
// set of tests.
void TestRepeatWithEmptyFilter(int repeat) {
GTEST_FLAG_SET(repeat, repeat);
+ GTEST_FLAG_SET(recreate_environments_when_repeating, true);
GTEST_FLAG_SET(filter, "None");
ResetCounts();
@@ -163,6 +165,7 @@ void TestRepeatWithEmptyFilter(int repeat) {
// successful tests.
void TestRepeatWithFilterForSuccessfulTests(int repeat) {
GTEST_FLAG_SET(repeat, repeat);
+ GTEST_FLAG_SET(recreate_environments_when_repeating, true);
GTEST_FLAG_SET(filter, "*-*ShouldFail");
ResetCounts();
@@ -179,6 +182,7 @@ void TestRepeatWithFilterForSuccessfulTests(int repeat) {
// failed tests.
void TestRepeatWithFilterForFailedTests(int repeat) {
GTEST_FLAG_SET(repeat, repeat);
+ GTEST_FLAG_SET(recreate_environments_when_repeating, true);
GTEST_FLAG_SET(filter, "*ShouldFail");
ResetCounts();