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

Side by Side Diff: testing/scripts/checkdeps.py

Issue 655843004: Revert of Add src-side launcher for telemetry_unittests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « no previous file | testing/scripts/common.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 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
7 import contextlib
6 import json 8 import json
7 import os 9 import os
10 import subprocess
8 import sys 11 import sys
12 import tempfile
9 13
10 14
11 import common 15 SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__))
16 SRC_DIR = os.path.abspath(
17 os.path.join(SCRIPT_DIR, os.path.pardir, os.path.pardir))
12 18
13 19
14 def main_run(args): 20 def run_command(argv):
15 with common.temporary_file() as tempfile_path: 21 print 'Running %r' % argv
16 rc = common.run_command([ 22 rc = subprocess.call(argv)
17 os.path.join(common.SRC_DIR, 'buildtools', 'checkdeps', 'checkdeps.py'), 23 print 'Command %r returned exit code %d' % (argv, rc)
24 return rc
25
26
27 @contextlib.contextmanager
28 def temporary_file():
29 fd, path = tempfile.mkstemp()
30 os.close(fd)
31 try:
32 yield path
33 finally:
34 os.remove(path)
35
36
37 def mode_run(args):
38 with temporary_file() as tempfile_path:
39 rc = run_command([
40 os.path.join(SRC_DIR, 'buildtools', 'checkdeps', 'checkdeps.py'),
18 '--json', tempfile_path 41 '--json', tempfile_path
19 ]) 42 ])
20 43
21 with open(tempfile_path) as f: 44 with open(tempfile_path) as f:
22 checkdeps_results = json.load(f) 45 checkdeps_results = json.load(f)
23 46
24 result_set = set() 47 result_set = set()
25 for result in checkdeps_results: 48 for result in checkdeps_results:
26 for violation in result['violations']: 49 for violation in result['violations']:
27 result_set.add((result['dependee_path'], violation['include_path'])) 50 result_set.add((result['dependee_path'], violation['include_path']))
28 51
29 json.dump({ 52 with open(args.output, 'w') as f:
30 'valid': True, 53 json.dump({
31 'failures': ['%s: %s' % (r[0], r[1]) for r in result_set], 54 'valid': True,
32 }, args.output) 55 'failures': ['%s: %s' % (r[0], r[1]) for r in result_set],
56 }, f)
33 57
34 return rc 58 return rc
35 59
36 60
37 def main_compile_targets(args): 61 def main(argv):
38 json.dump([], args.output) 62 parser = argparse.ArgumentParser()
63
64 subparsers = parser.add_subparsers()
65
66 run_parser = subparsers.add_parser('run')
67 run_parser.add_argument('--output', required=True)
68 run_parser.set_defaults(func=mode_run)
69
70 args = parser.parse_args(argv)
71 return args.func(args)
39 72
40 73
41 if __name__ == '__main__': 74 if __name__ == '__main__':
42 funcs = { 75 sys.exit(main(sys.argv[1:]))
43 'run': main_run,
44 'compile_targets': main_compile_targets,
45 }
46 sys.exit(common.run_script(sys.argv[1:], funcs))
OLDNEW
« no previous file with comments | « no previous file | testing/scripts/common.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698