| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 'compile_commands.json') | 112 'compile_commands.json') |
| 113 source_files = glob.glob(os.path.join(test_directory_for_tool, | 113 source_files = glob.glob(os.path.join(test_directory_for_tool, |
| 114 '*-original.cc')) | 114 '*-original.cc')) |
| 115 actual_files = ['-'.join([source_file.rsplit('-', 1)[0], 'actual.cc']) | 115 actual_files = ['-'.join([source_file.rsplit('-', 1)[0], 'actual.cc']) |
| 116 for source_file in source_files] | 116 for source_file in source_files] |
| 117 expected_files = ['-'.join([source_file.rsplit('-', 1)[0], 'expected.cc']) | 117 expected_files = ['-'.join([source_file.rsplit('-', 1)[0], 'expected.cc']) |
| 118 for source_file in source_files] | 118 for source_file in source_files] |
| 119 include_paths = [] | 119 include_paths = [] |
| 120 include_paths.append( | 120 include_paths.append( |
| 121 os.path.realpath(os.path.join(tools_clang_directory, '../..'))) | 121 os.path.realpath(os.path.join(tools_clang_directory, '../..'))) |
| 122 # Many gtest headers expect to have testing/gtest/include in the include | 122 # Many gtest and gmock headers expect to have testing/gtest/include and/or |
| 123 # search path. | 123 # testing/gmock/include in the include search path. |
| 124 include_paths.append( | 124 include_paths.append( |
| 125 os.path.realpath(os.path.join(tools_clang_directory, | 125 os.path.realpath(os.path.join(tools_clang_directory, |
| 126 '../..', | 126 '../..', |
| 127 'testing/gtest/include'))) | 127 'testing/gtest/include'))) |
| 128 include_paths.append( |
| 129 os.path.realpath(os.path.join(tools_clang_directory, |
| 130 '../..', |
| 131 'testing/gmock/include'))) |
| 128 | 132 |
| 129 if len(actual_files) == 0: | 133 if len(actual_files) == 0: |
| 130 print 'Tool "%s" does not have compatible test files.' % tool_to_test | 134 print 'Tool "%s" does not have compatible test files.' % tool_to_test |
| 131 return 1 | 135 return 1 |
| 132 | 136 |
| 133 # Set up the test environment. | 137 # Set up the test environment. |
| 134 for source, actual in zip(source_files, actual_files): | 138 for source, actual in zip(source_files, actual_files): |
| 135 shutil.copyfile(source, actual) | 139 shutil.copyfile(source, actual) |
| 136 # Generate a temporary compilation database to run the tool over. | 140 # Generate a temporary compilation database to run the tool over. |
| 137 with open(compile_database, 'w') as f: | 141 with open(compile_database, 'w') as f: |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 print '[==========] %s ran.' % _NumberOfTestsToString(len(source_files)) | 177 print '[==========] %s ran.' % _NumberOfTestsToString(len(source_files)) |
| 174 if passed > 0: | 178 if passed > 0: |
| 175 print '[ PASSED ] %s.' % _NumberOfTestsToString(passed) | 179 print '[ PASSED ] %s.' % _NumberOfTestsToString(passed) |
| 176 if failed > 0: | 180 if failed > 0: |
| 177 print '[ FAILED ] %s.' % _NumberOfTestsToString(failed) | 181 print '[ FAILED ] %s.' % _NumberOfTestsToString(failed) |
| 178 return 1 | 182 return 1 |
| 179 | 183 |
| 180 | 184 |
| 181 if __name__ == '__main__': | 185 if __name__ == '__main__': |
| 182 sys.exit(main(sys.argv[1:])) | 186 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |