From d89ce2ed1d4d2bf2ac3e273163af1e69603d9780 Mon Sep 17 00:00:00 2001 From: stijn Date: Sun, 31 Mar 2019 09:47:11 +0200 Subject: [PATCH] tests/run-tests: Ignore exception in process kill when ending repl test. When running Linux on WSL, Popen.kill() can raise a ProcessLookupError if the process does not exist anymore, which can happen here since the previous statement already tries to close the process by sending Ctrl-D to the running repl. This doesn't seem to be a problem on other OSes, so just swallow the exception silently since it indicates the process has been closed already, which after all is what we want. --- tests/run-tests | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/run-tests b/tests/run-tests index bf5c97c2b6..9f74c1cfcc 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -103,7 +103,16 @@ def run_micropython(pyb, args, test_file, is_special=False): banner = get(True) output_mupy = banner + b''.join(send_get(line) for line in f) send_get(b'\x04') # exit the REPL, so coverage info is saved - p.kill() + # At this point the process might have exited already, but trying to + # kill it 'again' normally doesn't result in exceptions as Python and/or + # the OS seem to try to handle this nicely. When running Linux on WSL + # though, the situation differs and calling Popen.kill after the process + # terminated results in a ProcessLookupError. Just catch that one here + # since we just want the process to be gone and that's the case. + try: + p.kill() + except ProcessLookupError: + pass os.close(master) os.close(slave) else: