From 8c11663457cc277573634856f0cf7e3d66cd675d Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Tue, 24 Sep 2024 13:55:37 -0700 Subject: [PATCH] nix: Improve behavior for when test is interrupted Signed-off-by: Nick Spinale --- .../scope/plat-utils/qemu/automate_simple.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/hacking/nix/scope/plat-utils/qemu/automate_simple.py b/hacking/nix/scope/plat-utils/qemu/automate_simple.py index 3e68c25ad..dffbf7152 100644 --- a/hacking/nix/scope/plat-utils/qemu/automate_simple.py +++ b/hacking/nix/scope/plat-utils/qemu/automate_simple.py @@ -18,14 +18,17 @@ def main(): def run(args): child = pexpect.spawn(args.simulate, encoding='utf-8') child.logfile = sys.stdout - ix = child.expect(['TEST_PASS', 'TEST_FAIL', pexpect.TIMEOUT], timeout=args.timeout) - print() - if ix != 0: - if ix == 1: - sys.exit('> test reported failure') - if ix == 2: - sys.exit('> test timed out') - assert False + try: + ix = child.expect(['TEST_PASS', 'TEST_FAIL', pexpect.TIMEOUT], timeout=args.timeout) + print() + if ix != 0: + if ix == 1: + sys.exit('> test reported failure') + if ix == 2: + sys.exit('> test timed out') + assert False + except KeyboardInterrupt: + sys.exit('> interrupted') if __name__ == '__main__': main()