| Index: tools/clang/translation_unit/test_translation_unit.py
|
| diff --git a/tools/clang/translation_unit/test_translation_unit.py b/tools/clang/translation_unit/test_translation_unit.py
|
| index a8e8f6865af2f9269420d1cb9683b7db14bb6d58..46576b03e35e981bfb547159a4d1f05de689cf8e 100755
|
| --- a/tools/clang/translation_unit/test_translation_unit.py
|
| +++ b/tools/clang/translation_unit/test_translation_unit.py
|
| @@ -15,11 +15,10 @@ import subprocess
|
| import sys
|
|
|
|
|
| -def _GenerateCompileCommands(files):
|
| +def _GenerateCompileCommands(template_path, test_files_dir):
|
| """Returns a JSON string containing a compilation database for the input."""
|
| - return json.dumps([{'directory': '.',
|
| - 'command': 'clang++ -fsyntax-only -std=c++11 -c %s' % f,
|
| - 'file': f} for f in files], indent=2)
|
| + with open(template_path) as fh:
|
| + return fh.read().replace('$test_files_dir', test_files_dir)
|
|
|
|
|
| def _NumberOfTestsToString(tests):
|
| @@ -38,11 +37,13 @@ def main():
|
| tools_clang_directory, 'translation_unit', 'test_files')
|
| compile_database = os.path.join(test_directory_for_tool,
|
| 'compile_commands.json')
|
| + compile_database_template = compile_database + '.template'
|
| source_files = glob.glob(os.path.join(test_directory_for_tool, '*.cc'))
|
|
|
| # Generate a temporary compilation database to run the tool over.
|
| with open(compile_database, 'w') as f:
|
| - f.write(_GenerateCompileCommands(source_files))
|
| + f.write(_GenerateCompileCommands(compile_database_template,
|
| + test_directory_for_tool))
|
|
|
| args = ['python',
|
| os.path.join(tools_clang_scripts_directory, 'run_tool.py'),
|
| @@ -68,13 +69,9 @@ def main():
|
| actual_output = f.readlines()
|
| has_same_filepaths = True
|
| for expected_line, actual_line in zip(expected_output, actual_output):
|
| - if '//' in actual_output:
|
| - if actual_output.split('//')[1] != expected_output:
|
| - sys.stdout.write('expected: %s' % expected_output)
|
| - sys.stdout.write('actual: %s' % actual_output.split('//')[1])
|
| - break
|
| - else:
|
| - continue
|
| + if '//' in actual_line:
|
| + actual_line = '//' + actual_line.split('//')[1]
|
| +
|
| if ntpath.basename(expected_line) != ntpath.basename(actual_line):
|
| sys.stdout.write('expected: %s' % ntpath.basename(expected_line))
|
| sys.stdout.write('actual: %s' % ntpath.basename(actual_line))
|
|
|