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

Side by Side Diff: testing/buildbot/manage.py

Issue 1169923008: Add support for GN's --runtime-deps-list-file flag to MB. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge to HEAD, add nacl_helper_nonsfi_unittests to fix presubmit failure Created 5 years, 6 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
« no previous file with comments | « no previous file | testing/buildbot/ninja_to_gn.pyl » ('j') | testing/buildbot/ninja_to_gn.pyl » ('J')
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 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 """Toolbox to manage all the json files in this directory. 6 """Toolbox to manage all the json files in this directory.
7 7
8 It can reformat them in their canonical format or ensures they are well 8 It can reformat them in their canonical format or ensures they are well
9 formatted. 9 formatted.
10 """ 10 """
11 11
12 import argparse 12 import argparse
13 import ast
13 import collections 14 import collections
14 import glob 15 import glob
15 import json 16 import json
16 import os 17 import os
17 import subprocess 18 import subprocess
18 import sys 19 import sys
19 20
20 21
21 THIS_DIR = os.path.dirname(os.path.abspath(__file__)) 22 THIS_DIR = os.path.dirname(os.path.abspath(__file__))
22 SRC_DIR = os.path.dirname(os.path.dirname(THIS_DIR)) 23 SRC_DIR = os.path.dirname(os.path.dirname(THIS_DIR))
(...skipping 21 matching lines...) Expand all
44 'ClangToTMac', 45 'ClangToTMac',
45 'ClangToTMacASan', 46 'ClangToTMacASan',
46 47
47 # One off builders. Note that Swarming does support ARM. 48 # One off builders. Note that Swarming does support ARM.
48 'Linux ARM Cross-Compile', 49 'Linux ARM Cross-Compile',
49 'Site Isolation Linux', 50 'Site Isolation Linux',
50 'Site Isolation Win', 51 'Site Isolation Win',
51 } 52 }
52 53
53 54
55 # TODO(GYP): These targets have not been ported to GN yet.
56 SKIP_NINJA_TO_GN_TARGETS = {
57 'cast_media_unittests',
58 'cast_shell_browser_test',
59 'chromevox_tests',
60 'nacl_helper_nonsfi_unittests',
61 }
62
63
54 class Error(Exception): 64 class Error(Exception):
55 """Processing error.""" 65 """Processing error."""
56 66
57 67
58 def get_isolates(): 68 def get_isolates():
59 """Returns the list of all isolate files.""" 69 """Returns the list of all isolate files."""
60 files = subprocess.check_output(['git', 'ls-files'], cwd=SRC_DIR).splitlines() 70 files = subprocess.check_output(['git', 'ls-files'], cwd=SRC_DIR).splitlines()
61 return [os.path.basename(f) for f in files if f.endswith('.isolate')] 71 return [os.path.basename(f) for f in files if f.endswith('.isolate')]
62 72
63 73
(...skipping 19 matching lines...) Expand all
83 for test in data['gtest_tests']: 93 for test in data['gtest_tests']:
84 name = test['test'] 94 name = test['test']
85 if test.get('swarming', {}).get('can_use_on_swarming_builders'): 95 if test.get('swarming', {}).get('can_use_on_swarming_builders'):
86 tests_location[name]['count_run_on_swarming'] += 1 96 tests_location[name]['count_run_on_swarming'] += 1
87 else: 97 else:
88 tests_location[name]['count_run_local'] += 1 98 tests_location[name]['count_run_local'] += 1
89 tests_location[name]['local_configs'].setdefault( 99 tests_location[name]['local_configs'].setdefault(
90 filename, []).append(builder) 100 filename, []).append(builder)
91 101
92 102
93 def process_file(mode, test_name, tests_location, filepath): 103 def process_file(mode, test_name, tests_location, filepath, ninja_targets,
104 ninja_targets_seen):
94 """Processes a file. 105 """Processes a file.
95 106
96 The action depends on mode. Updates tests_location. 107 The action depends on mode. Updates tests_location.
97 108
98 Return False if the process exit code should be 1. 109 Return False if the process exit code should be 1.
99 """ 110 """
100 filename = os.path.basename(filepath) 111 filename = os.path.basename(filepath)
101 with open(filepath) as f: 112 with open(filepath) as f:
102 content = f.read() 113 content = f.read()
103 try: 114 try:
104 config = json.loads(content) 115 config = json.loads(content)
105 except ValueError as e: 116 except ValueError as e:
106 raise Error('Exception raised while checking %s: %s' % (filepath, e)) 117 raise Error('Exception raised while checking %s: %s' % (filepath, e))
107 118
108 for builder, data in sorted(config.iteritems()): 119 for builder, data in sorted(config.iteritems()):
109 if builder in SKIP: 120 if builder in SKIP:
110 # Oddities. 121 # Oddities.
111 continue 122 continue
112 if not isinstance(data, dict): 123 if not isinstance(data, dict):
113 raise Error('%s: %s is broken: %s' % (filename, builder, data)) 124 raise Error('%s: %s is broken: %s' % (filename, builder, data))
114 if 'gtest_tests' not in data: 125 if 'gtest_tests' not in data:
115 continue 126 continue
116 if not isinstance(data['gtest_tests'], list): 127 if not isinstance(data['gtest_tests'], list):
117 raise Error( 128 raise Error(
118 '%s: %s is broken: %s' % (filename, builder, data['gtest_tests'])) 129 '%s: %s is broken: %s' % (filename, builder, data['gtest_tests']))
119 if not all(isinstance(g, dict) for g in data['gtest_tests']): 130 if not all(isinstance(g, dict) for g in data['gtest_tests']):
120 raise Error( 131 raise Error(
121 '%s: %s is broken: %s' % (filename, builder, data['gtest_tests'])) 132 '%s: %s is broken: %s' % (filename, builder, data['gtest_tests']))
122 133
134 for d in data['gtest_tests']:
135 if (d['test'] not in ninja_targets and
136 d['test'] not in SKIP_NINJA_TO_GN_TARGETS):
137 raise Error('%s: %s / %s is not listed in ninja_to_gn.pyl.' %
138 (filename, builder, d['test']))
139 elif d['test'] in ninja_targets:
140 ninja_targets_seen.add(d['test'])
141
123 config[builder]['gtest_tests'] = sorted( 142 config[builder]['gtest_tests'] = sorted(
124 data['gtest_tests'], key=lambda x: x['test']) 143 data['gtest_tests'], key=lambda x: x['test'])
125 if mode == 'remaining': 144 if mode == 'remaining':
126 process_builder_remaining(data, filename, builder, tests_location) 145 process_builder_remaining(data, filename, builder, tests_location)
127 elif mode == 'convert': 146 elif mode == 'convert':
128 process_builder_convert(data, filename, builder, test_name) 147 process_builder_convert(data, filename, builder, test_name)
129 148
130 expected = json.dumps( 149 expected = json.dumps(
131 config, sort_keys=True, indent=2, separators=(',', ': ')) + '\n' 150 config, sort_keys=True, indent=2, separators=(',', ': ')) + '\n'
132 if content != expected: 151 if content != expected:
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 parser.error('A test name is required with --convert') 234 parser.error('A test name is required with --convert')
216 if args.test_name + '.isolate' not in get_isolates(): 235 if args.test_name + '.isolate' not in get_isolates():
217 parser.error('Create %s.isolate first' % args.test_name) 236 parser.error('Create %s.isolate first' % args.test_name)
218 237
219 # Stats when running in --remaining mode; 238 # Stats when running in --remaining mode;
220 tests_location = collections.defaultdict( 239 tests_location = collections.defaultdict(
221 lambda: { 240 lambda: {
222 'count_run_local': 0, 'count_run_on_swarming': 0, 'local_configs': {} 241 'count_run_local': 0, 'count_run_on_swarming': 0, 'local_configs': {}
223 }) 242 })
224 243
244 with open(os.path.join(THIS_DIR, "ninja_to_gn.pyl")) as fp:
245 ninja_targets = ast.literal_eval(fp.read())
246
225 try: 247 try:
226 result = 0 248 result = 0
249 ninja_targets_seen = set()
227 for filepath in glob.glob(os.path.join(THIS_DIR, '*.json')): 250 for filepath in glob.glob(os.path.join(THIS_DIR, '*.json')):
228 if not process_file(args.mode, args.test_name, tests_location, filepath): 251 if not process_file(args.mode, args.test_name, tests_location, filepath,
252 ninja_targets, ninja_targets_seen):
229 result = 1 253 result = 1
230 254
255 extra_targets = set(ninja_targets) - ninja_targets_seen
256 if extra_targets:
257 if len(extra_targets) > 1:
258 extra_targets_str = ', '.join(extra_targets) + ' are'
259 else:
260 extra_targets_str = list(extra_targets)[0] + ' is'
261 raise Error('%s listed in ninja_to_gn.pyl but not in any .json files' %
262 extra_targets_str)
263
231 if args.mode == 'remaining': 264 if args.mode == 'remaining':
232 print_remaining(args.test_name, tests_location) 265 print_remaining(args.test_name, tests_location)
233 return result 266 return result
234 except Error as e: 267 except Error as e:
235 sys.stderr.write('%s\n' % e) 268 sys.stderr.write('%s\n' % e)
236 return 1 269 return 1
237 270
238 271
239 if __name__ == "__main__": 272 if __name__ == "__main__":
240 sys.exit(main()) 273 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | testing/buildbot/ninja_to_gn.pyl » ('j') | testing/buildbot/ninja_to_gn.pyl » ('J')

Powered by Google App Engine
This is Rietveld 408576698