| Index: tools/clang/blink_gc_plugin/tests/test.py
|
| diff --git a/tools/clang/blink_gc_plugin/tests/test.py b/tools/clang/blink_gc_plugin/tests/test.py
|
| index 5ade032313d9645879455d5f00587fd0159930df..acb7e74ac82801640b80b9b45d07632675443c1e 100755
|
| --- a/tools/clang/blink_gc_plugin/tests/test.py
|
| +++ b/tools/clang/blink_gc_plugin/tests/test.py
|
| @@ -4,20 +4,18 @@
|
| # found in the LICENSE file.
|
|
|
|
|
| -import argparse
|
| import glob
|
| import os
|
| import subprocess
|
| import sys
|
|
|
|
|
| -def run_test(test_base_name, cmd, reset_results):
|
| +def run_test(test_base_name, cmd):
|
| """Run a test case.
|
|
|
| Args:
|
| test_base_name: The name for the test C++ source file without the extension.
|
| cmd: The actual command to run for the test.
|
| - reset_results: True if the results should be overwritten in place.
|
|
|
| Returns:
|
| None on pass, or a str with the description of the failure.
|
| @@ -49,31 +47,31 @@ def run_test(test_base_name, cmd, reset_results):
|
| # from a previous run.
|
| os.remove('%s.graph.json' % test_base_name)
|
|
|
| + # TODO(dcheng): Remove the rstrip() and just rebaseline the tests to match.
|
| + actual = actual.rstrip()
|
| +
|
| # On Windows, clang emits CRLF as the end of line marker. Normalize it to LF
|
| # to match posix systems.
|
| actual = actual.replace('\r\n', '\n')
|
|
|
| - result_file = '%s.txt%s' % (
|
| - test_base_name, '' if reset_results else '.actual')
|
| try:
|
| - expected = open('%s.txt' % test_base_name).read()
|
| + expected = open('%s.txt' % test_base_name).read().rstrip()
|
| except IOError:
|
| - open(result_file, 'w').write(actual)
|
| + open('%s.txt.actual' % test_base_name, 'w').write(actual)
|
| return 'no expected file found'
|
|
|
| if expected != actual:
|
| - open(result_file, 'w').write(actual)
|
| + open('%s.txt.actual' % test_base_name, 'w').write(actual)
|
| return 'expected and actual differed'
|
|
|
|
|
| -def run_tests(clang_path, plugin_path, reset_results):
|
| +def run_tests(clang_path, plugin_path):
|
| """Runs the tests.
|
|
|
| Args:
|
| clang_path: The path to the clang binary to be tested.
|
| plugin_path: An optional path to the plugin to test. This may be None, if
|
| plugin is built directly into clang, like on Windows.
|
| - reset_results: True if the results should be overwritten in place.
|
|
|
| Returns:
|
| (passing, failing): Two lists containing the base names of the passing and
|
| @@ -103,7 +101,7 @@ def run_tests(clang_path, plugin_path, reset_results):
|
| pass
|
| cmd.append(test)
|
|
|
| - failure_message = run_test(test_base_name, cmd, reset_results)
|
| + failure_message = run_test(test_base_name, cmd)
|
| if failure_message:
|
| print 'failed: %s' % failure_message
|
| failing.append(test_base_name)
|
| @@ -115,23 +113,18 @@ def run_tests(clang_path, plugin_path, reset_results):
|
|
|
|
|
| def main():
|
| - parser = argparse.ArgumentParser()
|
| - parser.add_argument(
|
| - '--reset-results', action='store_true',
|
| - help='If specified, overwrites the expected results in place.')
|
| - parser.add_argument('clang_path', help='The path to the clang binary.')
|
| - parser.add_argument('plugin_path', nargs='?',
|
| - help='The path to the plugin library, if any.')
|
| - args = parser.parse_args()
|
| + if len(sys.argv) < 2:
|
| + print 'Usage: <path to clang>[ <path to plugin>]'
|
| + return -1
|
|
|
| os.chdir(os.path.dirname(os.path.realpath(__file__)))
|
|
|
| - print 'Using clang %s...' % args.clang_path
|
| - print 'Using plugin %s...' % args.plugin_path
|
| + clang_path = sys.argv[1]
|
| + plugin_path = sys.argv[2] if len(sys.argv) > 2 else None
|
| + print 'Using clang %s...' % clang_path
|
| + print 'Using plugin %s...' % plugin_path
|
|
|
| - passing, failing = run_tests(args.clang_path,
|
| - args.plugin_path,
|
| - args.reset_results)
|
| + passing, failing = run_tests(clang_path, plugin_path)
|
| print 'Ran %d tests: %d succeeded, %d failed' % (
|
| len(passing) + len(failing), len(passing), len(failing))
|
| for test in failing:
|
|
|