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

Side by Side Diff: tools/clang/blink_gc_plugin/tests/test.py

Issue 1137373002: Enable blink_gc_plugin tests on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 7 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 unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 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 6
7 import glob 7 import glob
8 import os 8 import os
9 import subprocess 9 import subprocess
10 import sys 10 import sys
(...skipping 24 matching lines...) Expand all
35 try: 35 try:
36 actual = subprocess.check_output( 36 actual = subprocess.check_output(
37 ['python', '../process-graph.py', '-c', 37 ['python', '../process-graph.py', '-c',
38 '%s.graph.json' % test_base_name], 38 '%s.graph.json' % test_base_name],
39 stderr=subprocess.STDOUT) 39 stderr=subprocess.STDOUT)
40 except subprocess.CalledProcessError, e: 40 except subprocess.CalledProcessError, e:
41 # The graph processing script returns a failure exit code if the graph is 41 # The graph processing script returns a failure exit code if the graph is
42 # 'bad' (e.g. it has a cycle). The output still needs to be captured in 42 # 'bad' (e.g. it has a cycle). The output still needs to be captured in
43 # that case, since the expected results capture the errors. 43 # that case, since the expected results capture the errors.
44 actual = e.output 44 actual = e.output
45 finally:
46 # Clean up the .graph.json file to prevent false passes from stale results
47 # from a previous run.
48 os.remove('%s.graph.json' % test_base_name)
dcheng 2015/05/14 05:28:18 This caused me to miss that -fsyntax-only isn't ac
45 49
46 # TODO(dcheng): Remove the rstrip() and just rebaseline the tests to match. 50 # TODO(dcheng): Remove the rstrip() and just rebaseline the tests to match.
47 actual = actual.rstrip() 51 actual = actual.rstrip()
48 52
53 # On Windows, clang emits CRLF as the end of line marker. Normalize it to LF
54 # to match posix systems.
55 actual = actual.replace('\r\n', '\n')
56
49 try: 57 try:
50 expected = open('%s.txt' % test_base_name).read().rstrip() 58 expected = open('%s.txt' % test_base_name).read().rstrip()
51 except IOError: 59 except IOError:
52 open('%s.txt' % test_base_name, 'w').write(actual) 60 open('%s.txt.actual' % test_base_name, 'w').write(actual)
dcheng 2015/05/14 05:28:18 Somehow I checked in the wrong version of this fil
53 return 'no expected file found' 61 return 'no expected file found'
54 62
55 if expected != actual: 63 if expected != actual:
56 open('%s.txt' % test_base_name, 'w').write(actual) 64 open('%s.txt.actual' % test_base_name, 'w').write(actual)
57 return 'expected and actual differed' 65 return 'expected and actual differed'
58 66
59 67
60 def run_tests(clang_path, plugin_path): 68 def run_tests(clang_path, plugin_path):
61 """Runs the tests. 69 """Runs the tests.
62 70
63 Args: 71 Args:
64 clang_path: The path to the clang binary to be tested. 72 clang_path: The path to the clang binary to be tested.
65 plugin_path: An optional path to the plugin to test. This may be None, if 73 plugin_path: An optional path to the plugin to test. This may be None, if
66 plugin is built directly into clang, like on Windows. 74 plugin is built directly into clang, like on Windows.
67 75
68 Returns: 76 Returns:
69 (passing, failing): Two lists containing the base names of the passing and 77 (passing, failing): Two lists containing the base names of the passing and
70 failing tests respectively. 78 failing tests respectively.
71 """ 79 """
72 passing = [] 80 passing = []
73 failing = [] 81 failing = []
74 82
75 base_cmd = [clang_path, '-fsyntax-only', '-std=c++11'] 83 # The plugin option to dump the object graph is incompatible with
84 # -fsyntax-only. It generates the .graph.json file based on the name of the
85 # output file, but there is no output filename with -fsyntax-only.
86 base_cmd = [clang_path, '-c', '-std=c++11']
76 base_cmd.extend(['-Wno-inaccessible-base']) 87 base_cmd.extend(['-Wno-inaccessible-base'])
77 if plugin_path: 88 if plugin_path:
78 base_cmd.extend(['-Xclang', '-load', '-Xclang', plugin_path]) 89 base_cmd.extend(['-Xclang', '-load', '-Xclang', plugin_path])
79 base_cmd.extend(['-Xclang', '-add-plugin', '-Xclang', 'blink-gc-plugin']) 90 base_cmd.extend(['-Xclang', '-add-plugin', '-Xclang', 'blink-gc-plugin'])
80 91
81 tests = glob.glob('*.cpp') 92 tests = glob.glob('*.cpp')
82 for test in tests: 93 for test in tests:
83 sys.stdout.write('Testing %s... ' % test) 94 sys.stdout.write('Testing %s... ' % test)
84 test_base_name, _ = os.path.splitext(test) 95 test_base_name, _ = os.path.splitext(test)
85 96
(...skipping 25 matching lines...) Expand all
111 clang_path = sys.argv[1] 122 clang_path = sys.argv[1]
112 plugin_path = sys.argv[2] if len(sys.argv) > 2 else None 123 plugin_path = sys.argv[2] if len(sys.argv) > 2 else None
113 print 'Using clang %s...' % clang_path 124 print 'Using clang %s...' % clang_path
114 print 'Using plugin %s...' % plugin_path 125 print 'Using plugin %s...' % plugin_path
115 126
116 passing, failing = run_tests(clang_path, plugin_path) 127 passing, failing = run_tests(clang_path, plugin_path)
117 print 'Ran %d tests: %d succeeded, %d failed' % ( 128 print 'Ran %d tests: %d succeeded, %d failed' % (
118 len(passing) + len(failing), len(passing), len(failing)) 129 len(passing) + len(failing), len(passing), len(failing))
119 for test in failing: 130 for test in failing:
120 print ' %s' % test 131 print ' %s' % test
132 return len(failing)
121 133
122 134
123 if __name__ == '__main__': 135 if __name__ == '__main__':
124 sys.exit(main()) 136 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698