Minor refactoring.

This commit is contained in:
kosak 2015-07-14 22:29:59 +00:00
parent 38dd7485c0
commit 80167de705
2 changed files with 14 additions and 12 deletions

View File

@ -40,6 +40,7 @@ SYNOPSIS
__author__ = 'wan@google.com (Zhanyong Wan)'
import difflib
import os
import re
import sys
@ -58,22 +59,22 @@ GOLDEN_NAME = 'gtest_output_test_golden_lin.txt'
PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath('gtest_output_test_')
# At least one command we exercise must not have the
# --gtest_internal_skip_environment_and_ad_hoc_tests flag.
# 'internal_skip_environment_and_ad_hoc_tests' argument.
COMMAND_LIST_TESTS = ({}, [PROGRAM_PATH, '--gtest_list_tests'])
COMMAND_WITH_COLOR = ({}, [PROGRAM_PATH, '--gtest_color=yes'])
COMMAND_WITH_TIME = ({}, [PROGRAM_PATH,
'--gtest_print_time',
'--gtest_internal_skip_environment_and_ad_hoc_tests',
'internal_skip_environment_and_ad_hoc_tests',
'--gtest_filter=FatalFailureTest.*:LoggingTest.*'])
COMMAND_WITH_DISABLED = (
{}, [PROGRAM_PATH,
'--gtest_also_run_disabled_tests',
'--gtest_internal_skip_environment_and_ad_hoc_tests',
'internal_skip_environment_and_ad_hoc_tests',
'--gtest_filter=*DISABLED_*'])
COMMAND_WITH_SHARDING = (
{'GTEST_SHARD_INDEX': '1', 'GTEST_TOTAL_SHARDS': '2'},
[PROGRAM_PATH,
'--gtest_internal_skip_environment_and_ad_hoc_tests',
'internal_skip_environment_and_ad_hoc_tests',
'--gtest_filter=PassingTest.*'])
GOLDEN_PATH = os.path.join(gtest_test_utils.GetSourceDir(), GOLDEN_NAME)
@ -294,7 +295,11 @@ class GTestOutputTest(gtest_test_utils.TestCase):
normalized_golden = RemoveTypeInfoDetails(golden)
if CAN_GENERATE_GOLDEN_FILE:
self.assertEqual(normalized_golden, normalized_actual)
self.assertEqual(normalized_golden, normalized_actual,
'\n'.join(difflib.unified_diff(
normalized_golden.split('\n'),
normalized_actual.split('\n'),
'golden', 'actual')))
else:
normalized_actual = NormalizeToCurrentPlatform(
RemoveTestCounts(normalized_actual))

View File

@ -990,8 +990,6 @@ class BarEnvironment : public testing::Environment {
}
};
bool GTEST_FLAG(internal_skip_environment_and_ad_hoc_tests) = false;
// The main function.
//
// The idea is to use Google Test to run all the tests we have defined (some
@ -1008,10 +1006,9 @@ int main(int argc, char **argv) {
// global side effects. The following line serves as a sanity test
// for it.
testing::InitGoogleTest(&argc, argv);
if (argc >= 2 &&
(std::string(argv[1]) ==
"--gtest_internal_skip_environment_and_ad_hoc_tests"))
GTEST_FLAG(internal_skip_environment_and_ad_hoc_tests) = true;
bool internal_skip_environment_and_ad_hoc_tests =
std::count(argv, argv + argc,
std::string("internal_skip_environment_and_ad_hoc_tests")) > 0;
#if GTEST_HAS_DEATH_TEST
if (testing::internal::GTEST_FLAG(internal_run_death_test) != "") {
@ -1026,7 +1023,7 @@ int main(int argc, char **argv) {
}
#endif // GTEST_HAS_DEATH_TEST
if (GTEST_FLAG(internal_skip_environment_and_ad_hoc_tests))
if (internal_skip_environment_and_ad_hoc_tests)
return RUN_ALL_TESTS();
// Registers two global test environments.