| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 'compile_commands.json') | 58 'compile_commands.json') |
| 59 source_files = glob.glob(os.path.join(test_directory_for_tool, | 59 source_files = glob.glob(os.path.join(test_directory_for_tool, |
| 60 '*-original.cc')) | 60 '*-original.cc')) |
| 61 actual_files = ['-'.join([source_file.rsplit('-', 1)[0], 'actual.cc']) | 61 actual_files = ['-'.join([source_file.rsplit('-', 1)[0], 'actual.cc']) |
| 62 for source_file in source_files] | 62 for source_file in source_files] |
| 63 expected_files = ['-'.join([source_file.rsplit('-', 1)[0], 'expected.cc']) | 63 expected_files = ['-'.join([source_file.rsplit('-', 1)[0], 'expected.cc']) |
| 64 for source_file in source_files] | 64 for source_file in source_files] |
| 65 include_paths = [] | 65 include_paths = [] |
| 66 include_paths.append( | 66 include_paths.append( |
| 67 os.path.realpath(os.path.join(tools_clang_directory, '../..'))) | 67 os.path.realpath(os.path.join(tools_clang_directory, '../..'))) |
| 68 # Many gtest headers expect to have testing/gtest/include in the include | 68 # Many gtest and gmock headers expect to have testing/gtest/include and/or |
| 69 # search path. | 69 # testing/gmock/include in the include search path. |
| 70 include_paths.append( | 70 include_paths.append( |
| 71 os.path.realpath(os.path.join(tools_clang_directory, | 71 os.path.realpath(os.path.join(tools_clang_directory, |
| 72 '../..', | 72 '../..', |
| 73 'testing/gtest/include'))) | 73 'testing/gtest/include'))) |
| 74 include_paths.append( |
| 75 os.path.realpath(os.path.join(tools_clang_directory, |
| 76 '../..', |
| 77 'testing/gmock/include'))) |
| 74 | 78 |
| 75 if len(actual_files) == 0: | 79 if len(actual_files) == 0: |
| 76 print 'Tool "%s" does not have compatible test files.' % tool_to_test | 80 print 'Tool "%s" does not have compatible test files.' % tool_to_test |
| 77 return 1 | 81 return 1 |
| 78 | 82 |
| 79 try: | 83 try: |
| 80 # Set up the test environment. | 84 # Set up the test environment. |
| 81 for source, actual in zip(source_files, actual_files): | 85 for source, actual in zip(source_files, actual_files): |
| 82 shutil.copyfile(source, actual) | 86 shutil.copyfile(source, actual) |
| 83 # Stage the test files in the git index. If they aren't staged, then | 87 # Stage the test files in the git index. If they aren't staged, then |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 finally: | 143 finally: |
| 140 # No matter what, unstage the git changes we made earlier to avoid polluting | 144 # No matter what, unstage the git changes we made earlier to avoid polluting |
| 141 # the index. | 145 # the index. |
| 142 args = ['reset', '--quiet', 'HEAD'] | 146 args = ['reset', '--quiet', 'HEAD'] |
| 143 args.extend(actual_files) | 147 args.extend(actual_files) |
| 144 _RunGit(args) | 148 _RunGit(args) |
| 145 | 149 |
| 146 | 150 |
| 147 if __name__ == '__main__': | 151 if __name__ == '__main__': |
| 148 sys.exit(main(sys.argv[1:])) | 152 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |