OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2014 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 for TranslationUnitGenerator tool.""" | 6 """Test for TranslationUnitGenerator tool.""" |
7 | 7 |
8 import difflib | 8 import difflib |
9 import glob | 9 import glob |
10 import json | 10 import json |
(...skipping 10 matching lines...) Expand all Loading... |
21 return fh.read().replace('$test_files_dir', test_files_dir) | 21 return fh.read().replace('$test_files_dir', test_files_dir) |
22 | 22 |
23 | 23 |
24 def _NumberOfTestsToString(tests): | 24 def _NumberOfTestsToString(tests): |
25 """Returns an English sentence describing the number of tests.""" | 25 """Returns an English sentence describing the number of tests.""" |
26 return "%d test%s" % (tests, 's' if tests != 1 else '') | 26 return "%d test%s" % (tests, 's' if tests != 1 else '') |
27 | 27 |
28 | 28 |
29 # Before running this test script, please build the translation_unit clang tool | 29 # Before running this test script, please build the translation_unit clang tool |
30 # first. This is explained here: | 30 # first. This is explained here: |
31 # https://code.google.com/p/chromium/wiki/ClangToolRefactoring | 31 # https://chromium.googlesource.com/chromium/src/+/master/docs/clang_tool_refact
oring.md |
32 def main(): | 32 def main(): |
33 tools_clang_directory = os.path.dirname(os.path.dirname( | 33 tools_clang_directory = os.path.dirname(os.path.dirname( |
34 os.path.realpath(__file__))) | 34 os.path.realpath(__file__))) |
35 tools_clang_scripts_directory = os.path.join(tools_clang_directory, 'scripts') | 35 tools_clang_scripts_directory = os.path.join(tools_clang_directory, 'scripts') |
36 test_directory_for_tool = os.path.join( | 36 test_directory_for_tool = os.path.join( |
37 tools_clang_directory, 'translation_unit', 'test_files') | 37 tools_clang_directory, 'translation_unit', 'test_files') |
38 compile_database = os.path.join(test_directory_for_tool, | 38 compile_database = os.path.join(test_directory_for_tool, |
39 'compile_commands.json') | 39 'compile_commands.json') |
40 compile_database_template = compile_database + '.template' | 40 compile_database_template = compile_database + '.template' |
41 source_files = glob.glob(os.path.join(test_directory_for_tool, '*.cc')) | 41 source_files = glob.glob(os.path.join(test_directory_for_tool, '*.cc')) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 print '[==========] %s ran.' % _NumberOfTestsToString(len(source_files)) | 97 print '[==========] %s ran.' % _NumberOfTestsToString(len(source_files)) |
98 if passed > 0: | 98 if passed > 0: |
99 print '[ PASSED ] %s.' % _NumberOfTestsToString(passed) | 99 print '[ PASSED ] %s.' % _NumberOfTestsToString(passed) |
100 if failed > 0: | 100 if failed > 0: |
101 print '[ FAILED ] %s.' % _NumberOfTestsToString(failed) | 101 print '[ FAILED ] %s.' % _NumberOfTestsToString(failed) |
102 | 102 |
103 | 103 |
104 if __name__ == '__main__': | 104 if __name__ == '__main__': |
105 sys.exit(main()) | 105 sys.exit(main()) |
OLD | NEW |