Minor refactoring.
This commit is contained in:
parent
38dd7485c0
commit
80167de705
|
@ -40,6 +40,7 @@ SYNOPSIS
|
||||||
|
|
||||||
__author__ = 'wan@google.com (Zhanyong Wan)'
|
__author__ = 'wan@google.com (Zhanyong Wan)'
|
||||||
|
|
||||||
|
import difflib
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
@ -58,22 +59,22 @@ GOLDEN_NAME = 'gtest_output_test_golden_lin.txt'
|
||||||
PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath('gtest_output_test_')
|
PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath('gtest_output_test_')
|
||||||
|
|
||||||
# At least one command we exercise must not have the
|
# 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_LIST_TESTS = ({}, [PROGRAM_PATH, '--gtest_list_tests'])
|
||||||
COMMAND_WITH_COLOR = ({}, [PROGRAM_PATH, '--gtest_color=yes'])
|
COMMAND_WITH_COLOR = ({}, [PROGRAM_PATH, '--gtest_color=yes'])
|
||||||
COMMAND_WITH_TIME = ({}, [PROGRAM_PATH,
|
COMMAND_WITH_TIME = ({}, [PROGRAM_PATH,
|
||||||
'--gtest_print_time',
|
'--gtest_print_time',
|
||||||
'--gtest_internal_skip_environment_and_ad_hoc_tests',
|
'internal_skip_environment_and_ad_hoc_tests',
|
||||||
'--gtest_filter=FatalFailureTest.*:LoggingTest.*'])
|
'--gtest_filter=FatalFailureTest.*:LoggingTest.*'])
|
||||||
COMMAND_WITH_DISABLED = (
|
COMMAND_WITH_DISABLED = (
|
||||||
{}, [PROGRAM_PATH,
|
{}, [PROGRAM_PATH,
|
||||||
'--gtest_also_run_disabled_tests',
|
'--gtest_also_run_disabled_tests',
|
||||||
'--gtest_internal_skip_environment_and_ad_hoc_tests',
|
'internal_skip_environment_and_ad_hoc_tests',
|
||||||
'--gtest_filter=*DISABLED_*'])
|
'--gtest_filter=*DISABLED_*'])
|
||||||
COMMAND_WITH_SHARDING = (
|
COMMAND_WITH_SHARDING = (
|
||||||
{'GTEST_SHARD_INDEX': '1', 'GTEST_TOTAL_SHARDS': '2'},
|
{'GTEST_SHARD_INDEX': '1', 'GTEST_TOTAL_SHARDS': '2'},
|
||||||
[PROGRAM_PATH,
|
[PROGRAM_PATH,
|
||||||
'--gtest_internal_skip_environment_and_ad_hoc_tests',
|
'internal_skip_environment_and_ad_hoc_tests',
|
||||||
'--gtest_filter=PassingTest.*'])
|
'--gtest_filter=PassingTest.*'])
|
||||||
|
|
||||||
GOLDEN_PATH = os.path.join(gtest_test_utils.GetSourceDir(), GOLDEN_NAME)
|
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)
|
normalized_golden = RemoveTypeInfoDetails(golden)
|
||||||
|
|
||||||
if CAN_GENERATE_GOLDEN_FILE:
|
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:
|
else:
|
||||||
normalized_actual = NormalizeToCurrentPlatform(
|
normalized_actual = NormalizeToCurrentPlatform(
|
||||||
RemoveTestCounts(normalized_actual))
|
RemoveTestCounts(normalized_actual))
|
||||||
|
|
|
@ -990,8 +990,6 @@ class BarEnvironment : public testing::Environment {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
bool GTEST_FLAG(internal_skip_environment_and_ad_hoc_tests) = false;
|
|
||||||
|
|
||||||
// The main function.
|
// The main function.
|
||||||
//
|
//
|
||||||
// The idea is to use Google Test to run all the tests we have defined (some
|
// 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
|
// global side effects. The following line serves as a sanity test
|
||||||
// for it.
|
// for it.
|
||||||
testing::InitGoogleTest(&argc, argv);
|
testing::InitGoogleTest(&argc, argv);
|
||||||
if (argc >= 2 &&
|
bool internal_skip_environment_and_ad_hoc_tests =
|
||||||
(std::string(argv[1]) ==
|
std::count(argv, argv + argc,
|
||||||
"--gtest_internal_skip_environment_and_ad_hoc_tests"))
|
std::string("internal_skip_environment_and_ad_hoc_tests")) > 0;
|
||||||
GTEST_FLAG(internal_skip_environment_and_ad_hoc_tests) = true;
|
|
||||||
|
|
||||||
#if GTEST_HAS_DEATH_TEST
|
#if GTEST_HAS_DEATH_TEST
|
||||||
if (testing::internal::GTEST_FLAG(internal_run_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
|
#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();
|
return RUN_ALL_TESTS();
|
||||||
|
|
||||||
// Registers two global test environments.
|
// Registers two global test environments.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user