Runs all tests in this UnitTest object, prints the result, and returns true if all tests are successful. If any exception is thrown during a test, the test is considered to be failed, but the rest of the tests will still be run. When parameterized tests are enabled, it expands and registers parameterized tests first in RegisterParameterizedTests(). All other functions called from RunAllTests() m
| 6655 | // All other functions called from RunAllTests() may safely assume that |
| 6656 | // parameterized tests are ready to be counted and run. |
| 6657 | bool UnitTestImpl::RunAllTests() { |
| 6658 | // True iff Google Test is initialized before RUN_ALL_TESTS() is called. |
| 6659 | const bool gtest_is_initialized_before_run_all_tests = GTestIsInitialized(); |
| 6660 | |
| 6661 | // Do not run any test if the --help flag was specified. |
| 6662 | if (g_help_flag) |
| 6663 | return true; |
| 6664 | |
| 6665 | // Repeats the call to the post-flag parsing initialization in case the |
| 6666 | // user didn't call InitGoogleTest. |
| 6667 | PostFlagParsingInit(); |
| 6668 | |
| 6669 | // Even if sharding is not on, test runners may want to use the |
| 6670 | // GTEST_SHARD_STATUS_FILE to query whether the test supports the sharding |
| 6671 | // protocol. |
| 6672 | internal::WriteToShardStatusFileIfNeeded(); |
| 6673 | |
| 6674 | // True iff we are in a subprocess for running a thread-safe-style |
| 6675 | // death test. |
| 6676 | bool in_subprocess_for_death_test = false; |
| 6677 | |
| 6678 | #if GTEST_HAS_DEATH_TEST |
| 6679 | in_subprocess_for_death_test = |
| 6680 | (internal_run_death_test_flag_.get() != nullptr); |
| 6681 | # if defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_) |
| 6682 | if (in_subprocess_for_death_test) { |
| 6683 | GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_(); |
| 6684 | } |
| 6685 | # endif // defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_) |
| 6686 | #endif // GTEST_HAS_DEATH_TEST |
| 6687 | |
| 6688 | const bool should_shard = ShouldShard(kTestTotalShards, kTestShardIndex, |
| 6689 | in_subprocess_for_death_test); |
| 6690 | |
| 6691 | // Compares the full test names with the filter to decide which |
| 6692 | // tests to run. |
| 6693 | const bool has_tests_to_run = FilterTests(should_shard |
| 6694 | ? HONOR_SHARDING_PROTOCOL |
| 6695 | : IGNORE_SHARDING_PROTOCOL) > 0; |
| 6696 | |
| 6697 | // Lists the tests and exits if the --gtest_list_tests flag was specified. |
| 6698 | if (GTEST_FLAG(list_tests)) { |
| 6699 | // This must be called *after* FilterTests() has been called. |
| 6700 | ListTestsMatchingFilter(); |
| 6701 | return true; |
| 6702 | } |
| 6703 | |
| 6704 | random_seed_ = GTEST_FLAG(shuffle) ? |
| 6705 | GetRandomSeedFromFlag(GTEST_FLAG(random_seed)) : 0; |
| 6706 | |
| 6707 | // True iff at least one test has failed. |
| 6708 | bool failed = false; |
| 6709 | |
| 6710 | TestEventListener* repeater = listeners()->repeater(); |
| 6711 | |
| 6712 | start_timestamp_ = GetTimeInMillis(); |
| 6713 | repeater->OnTestProgramStart(*parent_); |
| 6714 |
nothing calls this directly
no test coverage detected