Removes the Windows golden file (by Vlad Losev); implements test result streaming (by Nikhil Jindal and cleaned up by Zhanyong Wan).
This commit is contained in:
@@ -52,10 +52,8 @@ CATCH_EXCEPTIONS_ENV_VAR_NAME = 'GTEST_CATCH_EXCEPTIONS'
|
||||
|
||||
IS_WINDOWS = os.name == 'nt'
|
||||
|
||||
if IS_WINDOWS:
|
||||
GOLDEN_NAME = 'gtest_output_test_golden_win.txt'
|
||||
else:
|
||||
GOLDEN_NAME = 'gtest_output_test_golden_lin.txt'
|
||||
# TODO(vladl@google.com): remove the _lin suffix.
|
||||
GOLDEN_NAME = 'gtest_output_test_golden_lin.txt'
|
||||
|
||||
PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath('gtest_output_test_')
|
||||
|
||||
@@ -138,6 +136,20 @@ def RemoveTypeInfoDetails(test_output):
|
||||
return re.sub(r'unsigned int', 'unsigned', test_output)
|
||||
|
||||
|
||||
def NormalizeToCurrentPlatform(test_output):
|
||||
"""Normalizes platform specific output details for easier comparison."""
|
||||
|
||||
if IS_WINDOWS:
|
||||
# Removes the color information that is not present on Windows.
|
||||
test_output = re.sub('\x1b\\[(0;3\d)?m', '', test_output)
|
||||
# Changes failure message headers into the Windows format.
|
||||
test_output = re.sub(r': Failure\n', r': error: ', test_output)
|
||||
# Changes file(line_number) to file:line_number.
|
||||
test_output = re.sub(r'((\w|\.)+)\((\d+)\):', r'\1:\3:', test_output)
|
||||
|
||||
return test_output
|
||||
|
||||
|
||||
def RemoveTestCounts(output):
|
||||
"""Removes test counts from a Google Test program's output."""
|
||||
|
||||
@@ -240,7 +252,7 @@ SUPPORTS_STACK_TRACES = False
|
||||
|
||||
CAN_GENERATE_GOLDEN_FILE = (SUPPORTS_DEATH_TESTS and
|
||||
SUPPORTS_TYPED_TESTS and
|
||||
(SUPPORTS_THREADS or IS_WINDOWS))
|
||||
SUPPORTS_THREADS)
|
||||
|
||||
|
||||
class GTestOutputTest(gtest_test_utils.TestCase):
|
||||
@@ -284,9 +296,10 @@ class GTestOutputTest(gtest_test_utils.TestCase):
|
||||
if CAN_GENERATE_GOLDEN_FILE:
|
||||
self.assertEqual(normalized_golden, normalized_actual)
|
||||
else:
|
||||
normalized_actual = RemoveTestCounts(normalized_actual)
|
||||
normalized_golden = RemoveTestCounts(self.RemoveUnsupportedTests(
|
||||
normalized_golden))
|
||||
normalized_actual = NormalizeToCurrentPlatform(
|
||||
RemoveTestCounts(normalized_actual))
|
||||
normalized_golden = NormalizeToCurrentPlatform(
|
||||
RemoveTestCounts(self.RemoveUnsupportedTests(normalized_golden)))
|
||||
|
||||
# This code is very handy when debugging golden file differences:
|
||||
if os.getenv('DEBUG_GTEST_OUTPUT_TEST'):
|
||||
@@ -312,14 +325,9 @@ if __name__ == '__main__':
|
||||
else:
|
||||
message = (
|
||||
"""Unable to write a golden file when compiled in an environment
|
||||
that does not support all the required features (death tests""")
|
||||
if IS_WINDOWS:
|
||||
message += (
|
||||
"""\nand typed tests). Please check that you are using VC++ 8.0 SP1
|
||||
or higher as your compiler.""")
|
||||
else:
|
||||
message += """\ntyped tests, and threads). Please generate the
|
||||
golden file using a binary built with those features enabled."""
|
||||
that does not support all the required features (death tests, typed tests,
|
||||
and multiple threads). Please generate the golden file using a binary built
|
||||
with those features enabled.""")
|
||||
|
||||
sys.stderr.write(message)
|
||||
sys.exit(1)
|
||||
|
||||
Reference in New Issue
Block a user