OLD | NEW |
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 import argparse | 6 import argparse |
7 import os | 7 import os |
8 import subprocess | 8 import subprocess |
9 import sys | 9 import sys |
10 | 10 |
11 script_dir = os.path.dirname(os.path.realpath(__file__)) | 11 script_dir = os.path.dirname(os.path.realpath(__file__)) |
12 tool_dir = os.path.abspath(os.path.join(script_dir, '../../pylib')) | 12 tool_dir = os.path.abspath(os.path.join(script_dir, '../../../pylib')) |
13 sys.path.insert(0, tool_dir) | 13 sys.path.insert(0, tool_dir) |
14 | 14 |
15 from clang import plugin_testing | 15 from clang import plugin_testing |
16 | 16 |
17 | 17 |
18 class BlinkGcPluginTest(plugin_testing.ClangPluginTest): | 18 class BlinkGcPluginTest(plugin_testing.ClangPluginTest): |
19 """Test harness for the Blink GC plugin.""" | 19 """Test harness for the Blink GC plugin.""" |
20 | 20 |
21 def AdjustClangArguments(self, clang_cmd): | 21 def AdjustClangArguments(self, clang_cmd): |
22 clang_cmd.append('-Wno-inaccessible-base') | 22 clang_cmd.append('-Wno-inaccessible-base') |
23 | 23 |
24 def ProcessOneResult(self, test_name, actual): | 24 def ProcessOneResult(self, test_name, actual): |
25 # Some Blink GC plugins dump a JSON representation of the object graph, and | 25 # Some Blink GC plugins dump a JSON representation of the object graph, and |
26 # use the processed results as the actual results of the test. | 26 # use the processed results as the actual results of the test. |
27 if os.path.exists('%s.graph.json' % test_name): | 27 if os.path.exists('%s.graph.json' % test_name): |
28 try: | 28 try: |
29 actual = subprocess.check_output( | 29 actual = subprocess.check_output( |
30 ['python', '../process-graph.py', '-c', | 30 ['python', '../../process-graph.py', '-c', |
31 '%s.graph.json' % test_name], | 31 '%s.graph.json' % test_name], |
32 stderr=subprocess.STDOUT) | 32 stderr=subprocess.STDOUT) |
33 except subprocess.CalledProcessError, e: | 33 except subprocess.CalledProcessError, e: |
34 # The graph processing script returns a failure exit code if the graph | 34 # The graph processing script returns a failure exit code if the graph |
35 # is bad (e.g. it has a cycle). The output still needs to be captured in | 35 # is bad (e.g. it has a cycle). The output still needs to be captured in |
36 # that case, since the expected results capture the errors. | 36 # that case, since the expected results capture the errors. |
37 actual = e.output | 37 actual = e.output |
38 finally: | 38 finally: |
39 # Clean up the .graph.json file to prevent false passes from stale | 39 # Clean up the .graph.json file to prevent false passes from stale |
40 # results from a previous run. | 40 # results from a previous run. |
(...skipping 16 matching lines...) Expand all Loading... |
57 return BlinkGcPluginTest( | 57 return BlinkGcPluginTest( |
58 os.path.dirname(os.path.realpath(__file__)), | 58 os.path.dirname(os.path.realpath(__file__)), |
59 args.clang_path, | 59 args.clang_path, |
60 args.plugin_path, | 60 args.plugin_path, |
61 'blink-gc-plugin', | 61 'blink-gc-plugin', |
62 args.reset_results).Run() | 62 args.reset_results).Run() |
63 | 63 |
64 | 64 |
65 if __name__ == '__main__': | 65 if __name__ == '__main__': |
66 sys.exit(main()) | 66 sys.exit(main()) |
OLD | NEW |