diff options
author | zhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925> | 2010-08-19 22:16:00 +0000 |
---|---|---|
committer | zhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925> | 2010-08-19 22:16:00 +0000 |
commit | a9f380f5c7ff75cd715c58e11885dddc54baef02 (patch) | |
tree | 8cf27e0b642c7ad8eeb97858369d237fe104eb41 /test/gtest_output_test.py | |
parent | b83585c4de97ee0b6e797836b17b701947dfea93 (diff) | |
download | googletest-a9f380f5c7ff75cd715c58e11885dddc54baef02.tar.gz googletest-a9f380f5c7ff75cd715c58e11885dddc54baef02.tar.bz2 googletest-a9f380f5c7ff75cd715c58e11885dddc54baef02.zip |
Removes the Windows golden file (by Vlad Losev); implements test result streaming (by Nikhil Jindal and cleaned up by Zhanyong Wan).
Diffstat (limited to 'test/gtest_output_test.py')
-rwxr-xr-x | test/gtest_output_test.py | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/test/gtest_output_test.py b/test/gtest_output_test.py index 425d9da4..f409e2a7 100755 --- a/test/gtest_output_test.py +++ b/test/gtest_output_test.py @@ -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) |