4955 {
4956
4957 const bool gtest_is_initialized_before_run_all_tests = GTestIsInitialized();
4958
4959
4961 return true;
4962
4963
4964
4966
4967
4968
4969
4971
4972
4973
4974 bool in_subprocess_for_death_test = false;
4975
4976#if GTEST_HAS_DEATH_TEST
4977 in_subprocess_for_death_test = (internal_run_death_test_flag_.get() != NULL);
4978# if defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_)
4979 if (in_subprocess_for_death_test) {
4980 GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_();
4981 }
4982# endif
4983#endif
4984
4985 const bool should_shard =
ShouldShard(kTestTotalShards, kTestShardIndex,
4986 in_subprocess_for_death_test);
4987
4988
4989
4990 const bool has_tests_to_run =
FilterTests(should_shard
4993
4994
4996
4998 return true;
4999 }
5000
5003
5004
5005 bool failed = false;
5006
5007 TestEventListener* repeater =
listeners()->repeater();
5008
5010 repeater->OnTestProgramStart(*parent_);
5011
5012
5013
5014 const int repeat = in_subprocess_for_death_test ? 1 :
GTEST_FLAG(repeat);
5015
5016 const bool forever = repeat < 0;
5017 for (int i = 0; forever || i != repeat; i++) {
5018
5019
5021
5023
5024
5025 if (has_tests_to_run &&
GTEST_FLAG(shuffle)) {
5027
5028
5029
5031 }
5032
5033
5034 repeater->OnTestIterationStart(*parent_, i);
5035
5036
5037 if (has_tests_to_run) {
5038
5039 repeater->OnEnvironmentsSetUpStart(*parent_);
5040 ForEach(environments_, SetUpEnvironment);
5041 repeater->OnEnvironmentsSetUpEnd(*parent_);
5042
5043
5044
5047 test_index++) {
5049 }
5050 }
5051
5052
5053 repeater->OnEnvironmentsTearDownStart(*parent_);
5054 std::for_each(environments_.rbegin(), environments_.rend(),
5055 TearDownEnvironment);
5056 repeater->OnEnvironmentsTearDownEnd(*parent_);
5057 }
5058
5060
5061
5062 repeater->OnTestIterationEnd(*parent_, i);
5063
5064
5066 failed = true;
5067 }
5068
5069
5070
5071
5072
5073
5074
5076
5078
5080 }
5081 }
5082
5083 repeater->OnTestProgramEnd(*parent_);
5084
5085 if (!gtest_is_initialized_before_run_all_tests) {
5086 ColoredPrintf(
5088 "\nIMPORTANT NOTICE - DO NOT IGNORE:\n"
5090 "() before calling RUN_ALL_TESTS(). This is INVALID. Soon " GTEST_NAME_
5091 " will start to enforce the valid usage. "
5092 "Please fix it ASAP, or IT WILL START TO FAIL.\n");
5093#if GTEST_FOR_GOOGLE_
5095 "For more details, see http://wiki/Main/ValidGUnitMain.\n");
5096#endif
5097 }
5098
5099 return !failed;
5100}
static bool HasFatalFailure()
TestCase * GetMutableTestCase(int i)
internal::Random * random()
void PostFlagParsingInit()
void ClearNonAdHocTestResult()
int FilterTests(ReactionToSharding shard_tests)
int total_test_case_count() const
void ListTestsMatchingFilter()
#define GTEST_INIT_GOOGLE_TEST_NAME_
GTEST_API_ bool ShouldShard(const char *total_shards_str, const char *shard_index_str, bool in_subprocess_for_death_test)
void WriteToShardStatusFileIfNeeded()
TypeWithSize< 8 >::Int TimeInMillis
int GetNextRandomSeed(int seed)
GTEST_API_ bool g_help_flag
GTEST_API_ TimeInMillis GetTimeInMillis()
int GetRandomSeedFromFlag(Int32 random_seed_flag)