Skip to content

Commit

Permalink
nix: Improve behavior for when test is interrupted
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Spinale <[email protected]>
  • Loading branch information
nspin committed Sep 25, 2024
1 parent 5a5b3e0 commit 8c11663
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions hacking/nix/scope/plat-utils/qemu/automate_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 8c11663

Please sign in to comment.