Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(428)

Unified Diff: tools/clang/translation_unit/test_translation_unit.py

Issue 1658553002: Check for system include paths by looking at clang's HeaderSearchOptions, (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add helpful comments Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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))

Powered by Google App Engine
This is Rietveld 408576698