mirror of
https://github.com/google/googletest.git
synced 2025-12-21 11:04:54 +08:00
Merge branch 'google:main' into master
This commit is contained in:
commit
c19db21570
@ -274,8 +274,8 @@ First, define a fixture class. By convention, you should give it the name
|
||||
class QueueTest : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
q0_.Enqueue(1);
|
||||
q1_.Enqueue(2);
|
||||
q1_.Enqueue(1);
|
||||
q2_.Enqueue(2);
|
||||
q2_.Enqueue(3);
|
||||
}
|
||||
|
||||
|
||||
@ -154,10 +154,6 @@ function(cxx_library_with_type name type cxx_flags)
|
||||
set_target_properties(${name}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "${cxx_flags}")
|
||||
# Generate debug library name with a postfix.
|
||||
set_target_properties(${name}
|
||||
PROPERTIES
|
||||
DEBUG_POSTFIX "d")
|
||||
# Set the output directory for build artifacts
|
||||
set_target_properties(${name}
|
||||
PROPERTIES
|
||||
|
||||
@ -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. "
|
||||
|
||||
@ -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)*'
|
||||
|
||||
@ -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_
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user