Skip to content

Commit

Permalink
Minor refactoring.
Browse files Browse the repository at this point in the history
git-svn-id: http://googletest.googlecode.com/svn/trunk@722 861a406c-534a-0410-8894-cb66d6ee9925
  • Loading branch information
kosak@google.com committed Jul 14, 2015
1 parent fb83793 commit eb80d05
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
15 changes: 10 additions & 5 deletions test/gtest_output_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

__author__ = 'wan@google.com (Zhanyong Wan)'

import difflib
import os
import re
import sys
Expand All @@ -58,22 +59,22 @@
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)
Expand Down Expand Up @@ -294,7 +295,11 @@ def testOutput(self):
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))
Expand Down
11 changes: 4 additions & 7 deletions test/gtest_output_test_.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) != "") {
Expand All @@ -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.
Expand Down

0 comments on commit eb80d05

Please sign in to comment.