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

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

Issue 1040083006: Converted accessibility_unittests to run on Swarming everywhere. (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Created 5 years, 8 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 | « testing/buildbot/chromium_trybot.json ('k') | testing/buildbot/trybot_analyze_config.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6 """Toolbox to manage all the json files in this directory.
7
8 It can reformat them in their canonical format or ensures they are well
9 formatted.
10 """
11
12 import argparse
13 import collections
14 import glob
15 import json
16 import os
17 import sys
18
19
20 THIS_DIR = os.path.dirname(os.path.abspath(__file__))
21 sys.path.insert(0, os.path.join(THIS_DIR, '..', '..', 'third_party'))
22
23 import colorama
24
25 # These are not 'builders'.
26 SKIP = {
27 'compile_targets', 'gtest_tests', 'filter_compile_builders',
28 'non_filter_builders', 'non_filter_tests_builders',
29 }
30
31
32 def upgrade_test(test):
33 """Converts from old style string to new style dict."""
34 if isinstance(test, basestring):
35 return {'test': test}
36 assert isinstance(test, dict)
37 return test
38
39
40 def main():
41 colorama.init()
42 parser = argparse.ArgumentParser(description=sys.modules[__name__].__doc__)
43 group = parser.add_mutually_exclusive_group(required=True)
44 group.add_argument(
45 '-c', '--check', action='store_true', help='Only check the files')
46 group.add_argument(
47 '--convert', action='store_true',
48 help='Convert a test to run on Swarming everywhere')
49 group.add_argument(
50 '--remaining', action='store_true',
51 help='Count the number of tests not yet running on Swarming')
52 group.add_argument(
53 '-w', '--write', action='store_true', help='Rewrite the files')
54 parser.add_argument(
55 'test_name', nargs='?',
56 help='The test name to print which configs to update; only to be used '
57 'with --remaining')
58 args = parser.parse_args()
59
60 if args.convert and not args.test_name:
61 parser.error('A test name is required with --convert')
62 # Stats when running in --remaining mode.
63 # (local, swarming, local_configs).
64 tests_location = collections.defaultdict(lambda: [0, 0, {}])
65
66 result = 0
67 for filepath in glob.glob(os.path.join(THIS_DIR, '*.json')):
68 filename = os.path.basename(filepath)
69 with open(filepath) as f:
70 content = f.read()
71 config = json.loads(content)
72 for builder, data in sorted(config.iteritems()):
73 if builder in SKIP:
74 # Oddities.
75 continue
76
77 if not isinstance(data, dict):
78 print('%s: %s is broken: %s' % (filename, builder, data))
79 continue
80
81 if 'gtest_tests' in data:
82 config[builder]['gtest_tests'] = sorted(
83 (upgrade_test(l) for l in data['gtest_tests']),
84 key=lambda x: x['test'])
85
86 if args.remaining:
87 for test in data['gtest_tests']:
88 name = test['test']
89 if test.get('swarming', {}).get('can_use_on_swarming_builders'):
90 tests_location[name][1] += 1
91 else:
92 tests_location[name][0] += 1
93 tests_location[name][2].setdefault(filename, []).append(builder)
94 elif args.convert:
95 for test in data['gtest_tests']:
96 if test['test'] != args.test_name:
97 continue
98 test.setdefault('swarming', {})['can_use_on_swarming_builders'] = (
99 True)
100
101 expected = json.dumps(
102 config, sort_keys=True, indent=2, separators=(',', ': ')) + '\n'
103 if content != expected:
104 result = 1
105 if args.write or args.convert:
106 with open(filepath, 'wb') as f:
107 f.write(expected)
108 print('Updated %s' % filename)
109 else:
110 print('%s is not in canonical format' % filename)
111
112 if args.remaining:
113 if args.test_name:
114 if args.test_name not in tests_location:
115 print('Unknown test %s' % args.test_name)
116 return 1
117 for config, builders in sorted(
118 tests_location[args.test_name][2].iteritems()):
119 print('%s:' % config)
120 for builder in sorted(builders):
121 print(' %s' % builder)
122 else:
123 l = max(map(len, tests_location))
124 print('%-*s%sLocal %sSwarming' %
125 (l, 'Test', colorama.Fore.RED, colorama.Fore.GREEN))
126 total_local = 0
127 total_swarming = 0
128 for name, location in sorted(tests_location.iteritems()):
129 if not location[1]:
130 c = colorama.Fore.RED
131 elif location[0]:
132 c = colorama.Fore.YELLOW
133 else:
134 c = colorama.Fore.GREEN
135 total_local += location[0]
136 total_swarming += location[1]
137 print('%s%-*s %4d %4d' %
138 (c, l, name, location[0], location[1]))
139 total = total_local + total_swarming
140 p_local = 100. * total_local / total
141 p_swarming = 100. * total_swarming / total
142 print('%s%-*s %4d (%4.1f%%) %4d (%4.1f%%)' %
143 (colorama.Fore.WHITE, l, 'Total:', total_local, p_local,
144 total_swarming, p_swarming))
145 print('%-*s %4d' % (l, 'Total executions:', total))
146 return result
147
148
149 if __name__ == "__main__":
150 sys.exit(main())
OLDNEW
« no previous file with comments | « testing/buildbot/chromium_trybot.json ('k') | testing/buildbot/trybot_analyze_config.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698