| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 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 """Test harness for chromium clang tools.""" | 6 """Test harness for chromium clang tools.""" |
| 7 | 7 |
| 8 import difflib | 8 import difflib |
| 9 import glob | 9 import glob |
| 10 import json | 10 import json |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 tool_to_test = argv[0] | 39 tool_to_test = argv[0] |
| 40 tools_clang_scripts_directory = os.path.dirname(os.path.realpath(__file__)) | 40 tools_clang_scripts_directory = os.path.dirname(os.path.realpath(__file__)) |
| 41 tools_clang_directory = os.path.dirname(tools_clang_scripts_directory) | 41 tools_clang_directory = os.path.dirname(tools_clang_scripts_directory) |
| 42 test_directory_for_tool = os.path.join( | 42 test_directory_for_tool = os.path.join( |
| 43 tools_clang_directory, tool_to_test, 'tests') | 43 tools_clang_directory, tool_to_test, 'tests') |
| 44 compile_database = os.path.join(test_directory_for_tool, | 44 compile_database = os.path.join(test_directory_for_tool, |
| 45 'compile_commands.json') | 45 'compile_commands.json') |
| 46 source_files = glob.glob(os.path.join(test_directory_for_tool, | 46 source_files = glob.glob(os.path.join(test_directory_for_tool, |
| 47 '*-original.cc')) | 47 '*-original.cc')) |
| 48 actual_files = ['-'.join([source_file.rsplit('-', 2)[0], 'actual.cc']) | 48 actual_files = ['-'.join([source_file.rsplit('-', 1)[0], 'actual.cc']) |
| 49 for source_file in source_files] | 49 for source_file in source_files] |
| 50 expected_files = ['-'.join([source_file.rsplit('-', 2)[0], 'expected.cc']) | 50 expected_files = ['-'.join([source_file.rsplit('-', 1)[0], 'expected.cc']) |
| 51 for source_file in source_files] | 51 for source_file in source_files] |
| 52 include_paths = [] | 52 include_paths = [] |
| 53 include_paths.append( | 53 include_paths.append( |
| 54 os.path.realpath(os.path.join(tools_clang_directory, '../..'))) | 54 os.path.realpath(os.path.join(tools_clang_directory, '../..'))) |
| 55 | 55 |
| 56 try: | 56 try: |
| 57 # Set up the test environment. | 57 # Set up the test environment. |
| 58 for source, actual in zip(source_files, actual_files): | 58 for source, actual in zip(source_files, actual_files): |
| 59 shutil.copyfile(source, actual) | 59 shutil.copyfile(source, actual) |
| 60 # Stage the test files in the git index. If they aren't staged, then | 60 # Stage the test files in the git index. If they aren't staged, then |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 finally: | 111 finally: |
| 112 # No matter what, unstage the git changes we made earlier to avoid polluting | 112 # No matter what, unstage the git changes we made earlier to avoid polluting |
| 113 # the index. | 113 # the index. |
| 114 args = ['git', 'reset', '--quiet', 'HEAD'] | 114 args = ['git', 'reset', '--quiet', 'HEAD'] |
| 115 args.extend(actual_files) | 115 args.extend(actual_files) |
| 116 subprocess.call(args) | 116 subprocess.call(args) |
| 117 | 117 |
| 118 | 118 |
| 119 if __name__ == '__main__': | 119 if __name__ == '__main__': |
| 120 sys.exit(main(sys.argv[1:])) | 120 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |