verify.py (12897:9f8c25581024) verify.py (12903:f81321fad993)
1#!/usr/bin/env python2
2#
3# Copyright 2018 Google, Inc.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;

--- 144 unchanged lines hidden (view full) ---

153
154parser.add_argument('--flavor', choices=['debug', 'opt', 'fast'],
155 default='opt',
156 help='Flavor of binary to test.')
157
158parser.add_argument('--list', action='store_true',
159 help='List the available tests')
160
1#!/usr/bin/env python2
2#
3# Copyright 2018 Google, Inc.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;

--- 144 unchanged lines hidden (view full) ---

153
154parser.add_argument('--flavor', choices=['debug', 'opt', 'fast'],
155 default='opt',
156 help='Flavor of binary to test.')
157
158parser.add_argument('--list', action='store_true',
159 help='List the available tests')
160
161parser.add_argument('--filter', default='True',
162 help='Python expression which filters tests based on '
163 'their properties')
161filter_opts = parser.add_mutually_exclusive_group()
162filter_opts.add_argument('--filter', default='True',
163 help='Python expression which filters tests based '
164 'on their properties')
165filter_opts.add_argument('--filter-file', default=None,
166 type=argparse.FileType('r'),
167 help='Same as --filter, but read from a file')
164
165def collect_phases(args):
166 phase_groups = [list(g) for k, g in
167 itertools.groupby(args, lambda x: x != '--phase') if k]
168 main_args = parser.parse_args(phase_groups[0][1:])
169 phases = []
170 names = []
171 for group in phase_groups[1:]:

--- 19 unchanged lines hidden (view full) ---

191json_path = os.path.join(main_args.build_dir, json_rel_path)
192
193if main_args.update_json:
194 scons(os.path.join(json_path))
195
196with open(json_path) as f:
197 test_data = json.load(f)
198
168
169def collect_phases(args):
170 phase_groups = [list(g) for k, g in
171 itertools.groupby(args, lambda x: x != '--phase') if k]
172 main_args = parser.parse_args(phase_groups[0][1:])
173 phases = []
174 names = []
175 for group in phase_groups[1:]:

--- 19 unchanged lines hidden (view full) ---

195json_path = os.path.join(main_args.build_dir, json_rel_path)
196
197if main_args.update_json:
198 scons(os.path.join(json_path))
199
200with open(json_path) as f:
201 test_data = json.load(f)
202
203 if main_args.filter_file:
204 f = main_args.filter_file
205 filt = compile(f.read(), f.name, 'eval')
206 else:
207 filt = compile(main_args.filter, '<string>', 'eval')
208
209 filtered_tests = {
210 target: props for (target, props) in
211 test_data.iteritems() if eval(filt, dict(props))
212 }
213
199 if main_args.list:
214 if main_args.list:
200 for target, props in test_data.iteritems():
201 if not eval(main_args.filter, dict(props)):
202 continue
215 for target, props in sorted(filtered_tests.iteritems()):
203 print('%s.%s' % (target, main_args.flavor))
204 for key, val in props.iteritems():
205 print(' %s: %s' % (key, val))
206 else:
216 print('%s.%s' % (target, main_args.flavor))
217 for key, val in props.iteritems():
218 print(' %s: %s' % (key, val))
219 else:
207 tests_to_run = []
208 for target, props in test_data.iteritems():
209 if not eval(main_args.filter, props):
210 continue
211 tests_to_run.append(Test(target, main_args.flavor,
212 main_args.build_dir, props))
220 tests_to_run = list([
221 Test(target, main_args.flavor, main_args.build_dir, props) for
222 target, props in sorted(filtered_tests.iteritems())
223 ])
213
214 for phase in phases:
215 phase.run(tests_to_run)
224
225 for phase in phases:
226 phase.run(tests_to_run)