1#!/usr/bin/env python
2# Copyright 2016 The Chromium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6import argparse
7import os
8import subprocess
9import sys
10
11script_dir = os.path.dirname(os.path.realpath(__file__))
12tool_dir = os.path.abspath(os.path.join(script_dir, '../../pylib'))
13sys.path.insert(0, tool_dir)
14
15from clang import plugin_testing
16
17
18class ChromeStylePluginTest(plugin_testing.ClangPluginTest):
19  """Test harness for the Chrome style plugin."""
20
21  def AdjustClangArguments(self, clang_cmd):
22    clang_cmd.extend([
23        # Skip code generation
24        '-fsyntax-only',
25        # Fake system directory for tests
26        '-isystem', os.path.join(os.getcwd(), 'system'),
27        '-Wno-inconsistent-missing-override',
28    ])
29
30
31def main():
32  parser = argparse.ArgumentParser()
33  parser.add_argument(
34      '--reset-results',
35      action='store_true',
36      help='If specified, overwrites the expected results in place.')
37  parser.add_argument('clang_path', help='The path to the clang binary.')
38  parser.add_argument('plugin_path',
39                      nargs='?',
40                      help='The path to the plugin library, if any.')
41  args = parser.parse_args()
42
43  return ChromeStylePluginTest(
44      os.path.dirname(os.path.realpath(__file__)),
45      args.clang_path,
46      args.plugin_path,
47      'find-bad-constructs',
48      args.reset_results).Run()
49
50
51if __name__ == '__main__':
52  sys.exit(main())
53