Skip to content

Commit 51b8cdb

Browse files
committed
scripts: Added -q/--quiet to test.py/bench.py
This will probably only have niche uses, but may be useful for small test sets or for running specific tests with -O-. Though it is a bit funny that -q -O- turns test.py/bench.py into more or less just a complicated way to run a C program.
1 parent 0b450b1 commit 51b8cdb

File tree

2 files changed

+56
-40
lines changed

2 files changed

+56
-40
lines changed

scripts/bench.py

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,8 @@ def run_job(start=None, step=None):
12231223
daemon=True))
12241224

12251225
def print_update(done):
1226-
if (not args.get('verbose')
1226+
if (not args.get('quiet')
1227+
and not args.get('verbose')
12271228
and not args.get('stdout') == '-'
12281229
and (args['color'] or done)):
12291230
sys.stdout.write('%s%srunning %s%s:%s %s%s' % (
@@ -1284,8 +1285,9 @@ def print_update(done):
12841285

12851286
def run(runner, bench_ids=[], **args):
12861287
# query runner for benches
1287-
print('using runner: %s' % ' '.join(
1288-
shlex.quote(c) for c in find_runner(runner, **args)))
1288+
if not args.get('quiet'):
1289+
print('using runner: %s' % ' '.join(
1290+
shlex.quote(c) for c in find_runner(runner, **args)))
12891291

12901292
# query ids, perms, etc
12911293
bench_ids = find_ids(runner, bench_ids, **args)
@@ -1294,12 +1296,13 @@ def run(runner, bench_ids=[], **args):
12941296
expected_case_perms,
12951297
expected_perms,
12961298
total_perms) = find_perms(runner, bench_ids, **args)
1297-
print('found %d suites, %d cases, %d/%d permutations' % (
1298-
len(expected_suite_perms),
1299-
len(expected_case_perms),
1300-
expected_perms,
1301-
total_perms))
1302-
print()
1299+
if not args.get('quiet'):
1300+
print('found %d suites, %d cases, %d/%d permutations' % (
1301+
len(expected_suite_perms),
1302+
len(expected_case_perms),
1303+
expected_perms,
1304+
total_perms))
1305+
print()
13031306

13041307
# automatic job detection?
13051308
if args.get('jobs') == 0:
@@ -1377,17 +1380,18 @@ def run(runner, bench_ids=[], **args):
13771380
output.close()
13781381

13791382
# show summary
1380-
print()
1381-
print('%sdone:%s %s' % (
1382-
('\x1b[34m' if not failed else '\x1b[31m')
1383-
if args['color'] else '',
1384-
'\x1b[m' if args['color'] else '',
1385-
', '.join(filter(None, [
1386-
'%d readed' % readed,
1387-
'%d proged' % proged,
1388-
'%d erased' % erased,
1389-
'in %.2fs' % (stop-start)]))))
1390-
print()
1383+
if not args.get('quiet'):
1384+
print()
1385+
print('%sdone:%s %s' % (
1386+
('\x1b[34m' if not failed else '\x1b[31m')
1387+
if args['color'] else '',
1388+
'\x1b[m' if args['color'] else '',
1389+
', '.join(filter(None, [
1390+
'%d readed' % readed,
1391+
'%d proged' % proged,
1392+
'%d erased' % erased,
1393+
'in %.2fs' % (stop-start)]))))
1394+
print()
13911395

13921396
# print each failure
13931397
for failure in failures[:args.get('failures', 3)]:
@@ -1505,6 +1509,10 @@ def main(**args):
15051509
'-v', '--verbose',
15061510
action='store_true',
15071511
help="Output commands that run behind the scenes.")
1512+
parser.add_argument(
1513+
'-q', '--quiet',
1514+
action='store_true',
1515+
help="Show nothing except for bench failures.")
15081516
parser.add_argument(
15091517
'--color',
15101518
choices=['never', 'always', 'auto'],

scripts/test.py

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,8 @@ def run_job(start=None, step=None):
12071207
daemon=True))
12081208

12091209
def print_update(done):
1210-
if (not args.get('verbose')
1210+
if (not args.get('quiet')
1211+
and not args.get('verbose')
12111212
and not args.get('stdout') == '-'
12121213
and (args['color'] or done)):
12131214
sys.stdout.write('%s%srunning %s%s:%s %s%s' % (
@@ -1268,8 +1269,9 @@ def print_update(done):
12681269

12691270
def run(runner, test_ids=[], **args):
12701271
# query runner for tests
1271-
print('using runner: %s' % ' '.join(
1272-
shlex.quote(c) for c in find_runner(runner, **args)))
1272+
if not args.get('quiet'):
1273+
print('using runner: %s' % ' '.join(
1274+
shlex.quote(c) for c in find_runner(runner, **args)))
12731275

12741276
# query ids, perms, etc
12751277
test_ids = find_ids(runner, test_ids, **args)
@@ -1278,12 +1280,13 @@ def run(runner, test_ids=[], **args):
12781280
expected_case_perms,
12791281
expected_perms,
12801282
total_perms) = find_perms(runner, test_ids, **args)
1281-
print('found %d suites, %d cases, %d/%d permutations' % (
1282-
len(expected_suite_perms),
1283-
len(expected_case_perms),
1284-
expected_perms,
1285-
total_perms))
1286-
print()
1283+
if not args.get('quiet'):
1284+
print('found %d suites, %d cases, %d/%d permutations' % (
1285+
len(expected_suite_perms),
1286+
len(expected_case_perms),
1287+
expected_perms,
1288+
total_perms))
1289+
print()
12871290

12881291
# automatic job detection?
12891292
if args.get('jobs') == 0:
@@ -1355,17 +1358,18 @@ def run(runner, test_ids=[], **args):
13551358
output.close()
13561359

13571360
# show summary
1358-
print()
1359-
print('%sdone:%s %s' % (
1360-
('\x1b[32m' if not failed else '\x1b[31m')
1361-
if args['color'] else '',
1362-
'\x1b[m' if args['color'] else '',
1363-
', '.join(filter(None, [
1364-
'%d/%d passed' % (passed, expected),
1365-
'%d/%d failed' % (failed, expected),
1366-
'%dpls!' % powerlosses if powerlosses else None,
1367-
'in %.2fs' % (stop-start)]))))
1368-
print()
1361+
if not args.get('quiet'):
1362+
print()
1363+
print('%sdone:%s %s' % (
1364+
('\x1b[32m' if not failed else '\x1b[31m')
1365+
if args['color'] else '',
1366+
'\x1b[m' if args['color'] else '',
1367+
', '.join(filter(None, [
1368+
'%d/%d passed' % (passed, expected),
1369+
'%d/%d failed' % (failed, expected),
1370+
'%dpls!' % powerlosses if powerlosses else None,
1371+
'in %.2fs' % (stop-start)]))))
1372+
print()
13691373

13701374
# print each failure
13711375
for failure in failures[:args.get('failures', 3)]:
@@ -1521,6 +1525,10 @@ def main(**args):
15211525
'-v', '--verbose',
15221526
action='store_true',
15231527
help="Output commands that run behind the scenes.")
1528+
parser.add_argument(
1529+
'-q', '--quiet',
1530+
action='store_true',
1531+
help="Show nothing except for test failures.")
15241532
parser.add_argument(
15251533
'--color',
15261534
choices=['never', 'always', 'auto'],

0 commit comments

Comments
 (0)