From 3f004f547ede03f5574357d9292d52d6cb20b734 Mon Sep 17 00:00:00 2001 From: Renato Alves Date: Tue, 17 Feb 2015 12:19:59 +0000 Subject: [PATCH] Tests - Don't hang if spawning taskw fails --- test/basetest/utils.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/test/basetest/utils.py b/test/basetest/utils.py index 36f5a3992..c0781aefb 100644 --- a/test/basetest/utils.py +++ b/test/basetest/utils.py @@ -108,7 +108,20 @@ def _queue_output(arguments, pidq, outputq): kwargs = arguments["process"] input = arguments["input"] - proc = Popen(**kwargs) + try: + proc = Popen(**kwargs) + except OSError as e: + # pid None is read by the main thread as a crash of the process + pidq.put(None) + + outputq.put(( + "", + ("Unexpected exception caught during execution of taskw: '{0}' . " + "If you are running out-of-tree tests set USE_PATH=1 in shell " + "env before execution".format(e)), + 255)) # false exitcode + + return # NOTE If for whatever reason pid is None at the time of access, use the # following line instead @@ -161,6 +174,10 @@ def _get_output(arguments, timeout=None): try: pid = pidq.get(timeout=timeout) except Empty: + pid = None + + # Process crashed or timed out for some reason + if pid is None: return _retrieve_output(t, output_timeout, outputq, "TaskWarrior to start")