| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 | 6 |
| 7 import argparse | 7 import argparse |
| 8 import glob | 8 import glob |
| 9 import os | 9 import os |
| 10 import subprocess | 10 import subprocess |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 result_file = '%s.txt%s' % ( | 56 result_file = '%s.txt%s' % ( |
| 57 test_base_name, '' if reset_results else '.actual') | 57 test_base_name, '' if reset_results else '.actual') |
| 58 try: | 58 try: |
| 59 expected = open('%s.txt' % test_base_name).read() | 59 expected = open('%s.txt' % test_base_name).read() |
| 60 except IOError: | 60 except IOError: |
| 61 open(result_file, 'w').write(actual) | 61 open(result_file, 'w').write(actual) |
| 62 return 'no expected file found' | 62 return 'no expected file found' |
| 63 | 63 |
| 64 if expected != actual: | 64 if expected != actual: |
| 65 open(result_file, 'w').write(actual) | 65 open(result_file, 'w').write(actual) |
| 66 return 'expected and actual differed' | 66 error = 'expected and actual differed\n' |
| 67 error += 'Actual:\n' + actual |
| 68 error += 'Expected:\n' + expected |
| 69 return error |
| 67 | 70 |
| 68 | 71 |
| 69 def run_tests(clang_path, plugin_path, reset_results): | 72 def run_tests(clang_path, plugin_path, reset_results): |
| 70 """Runs the tests. | 73 """Runs the tests. |
| 71 | 74 |
| 72 Args: | 75 Args: |
| 73 clang_path: The path to the clang binary to be tested. | 76 clang_path: The path to the clang binary to be tested. |
| 74 plugin_path: An optional path to the plugin to test. This may be None, if | 77 plugin_path: An optional path to the plugin to test. This may be None, if |
| 75 plugin is built directly into clang, like on Windows. | 78 plugin is built directly into clang, like on Windows. |
| 76 reset_results: True if the results should be overwritten in place. | 79 reset_results: True if the results should be overwritten in place. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 args.reset_results) | 137 args.reset_results) |
| 135 print 'Ran %d tests: %d succeeded, %d failed' % ( | 138 print 'Ran %d tests: %d succeeded, %d failed' % ( |
| 136 len(passing) + len(failing), len(passing), len(failing)) | 139 len(passing) + len(failing), len(passing), len(failing)) |
| 137 for test in failing: | 140 for test in failing: |
| 138 print ' %s' % test | 141 print ' %s' % test |
| 139 return len(failing) | 142 return len(failing) |
| 140 | 143 |
| 141 | 144 |
| 142 if __name__ == '__main__': | 145 if __name__ == '__main__': |
| 143 sys.exit(main()) | 146 sys.exit(main()) |
| OLD | NEW |