From 76593711abeac8cd16f6a452023c76296baddf1d Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Wed, 20 Mar 2024 13:50:04 -0500 Subject: [PATCH] Added -f/--fail to test.py/bench.py This just tells test.py/bench.py to pretend the test failed and trigger any conditional utilities. This can be combined with --gdb to easily inspect a test that isn't actually failing. Up until this point I've just been inserting assert(false) when needed, which is clunky. --- scripts/bench.py | 12 ++++++++++-- scripts/test.py | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/scripts/bench.py b/scripts/bench.py index 026f0aee..05331c37 100755 --- a/scripts/bench.py +++ b/scripts/bench.py @@ -1008,6 +1008,10 @@ def run_stage(name, runner, bench_ids, stdout_, trace_, output_, **args): last_stdout.clear() last_assert = None elif op == 'finished': + # force a failure + if args.get('fail'): + raise BenchFailure(last_id, 0, list(last_stdout)) + # passed case = m.group('case') suite = case_suites[case] passed_suite_perms[suite] += 1 @@ -1061,7 +1065,7 @@ def run_stage(name, runner, bench_ids, stdout_, trace_, output_, **args): proged += proged_ erased += erased_ except KeyboardInterrupt: - raise BenchFailure(last_id, 1, list(last_stdout)) + raise BenchFailure(last_id, 0, list(last_stdout)) finally: children.remove(proc) mpty.close() @@ -1513,7 +1517,11 @@ if __name__ == "__main__": bench_parser.add_argument( '-k', '--keep-going', action='store_true', - help="Don't stop on first error.") + help="Don't stop on first failure.") + bench_parser.add_argument( + '-f', '--fail', + action='store_true', + help="Force a failure.") bench_parser.add_argument( '-i', '--isolate', action='store_true', diff --git a/scripts/test.py b/scripts/test.py index ff3e225c..bc856ff4 100755 --- a/scripts/test.py +++ b/scripts/test.py @@ -1003,6 +1003,10 @@ def run_stage(name, runner, test_ids, stdout_, trace_, output_, **args): last_id = m.group('id') powerlosses += 1 elif op == 'finished': + # force a failure? + if args.get('fail'): + raise TestFailure(last_id, 0, list(last_stdout)) + # passed case = m.group('case') suite = case_suites[case] passed_suite_perms[suite] += 1 @@ -1028,7 +1032,7 @@ def run_stage(name, runner, test_ids, stdout_, trace_, output_, **args): if args.get('keep_going'): proc.kill() except KeyboardInterrupt: - raise TestFailure(last_id, 1, list(last_stdout)) + raise TestFailure(last_id, 0, list(last_stdout)) finally: children.remove(proc) mpty.close() @@ -1530,7 +1534,11 @@ if __name__ == "__main__": test_parser.add_argument( '-k', '--keep-going', action='store_true', - help="Don't stop on first error.") + help="Don't stop on first failure.") + test_parser.add_argument( + '-f', '--fail', + action='store_true', + help="Force a failure.") test_parser.add_argument( '-i', '--isolate', action='store_true',