From: Ben Darnell Date: Sun, 26 Mar 2017 17:13:27 +0000 (-0400) Subject: process_test: Report more details when test_sigchild_signal fails X-Git-Tag: v4.5.0~13^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1988%2Fhead;p=thirdparty%2Ftornado.git process_test: Report more details when test_sigchild_signal fails This test occasionally fails on pypy on travis-ci. --- diff --git a/tornado/test/process_test.py b/tornado/test/process_test.py index 89e742e36..74c10abf1 100644 --- a/tornado/test/process_test.py +++ b/tornado/test/process_test.py @@ -219,10 +219,27 @@ class SubprocessTest(AsyncTestCase): self.addCleanup(Subprocess.uninitialize) subproc = Subprocess([sys.executable, '-c', 'import time; time.sleep(30)'], + stdout=Subprocess.STREAM, io_loop=self.io_loop) subproc.set_exit_callback(self.stop) os.kill(subproc.pid, signal.SIGTERM) - ret = self.wait() + try: + ret = self.wait(timeout=1.0) + except AssertionError: + # We failed to get the termination signal. This test is + # occasionally flaky on pypy, so try to get a little more + # information: did the process close its stdout + # (indicating that the problem is in the parent process's + # signal handling) or did the child process somehow fail + # to terminate? + subproc.stdout.read_until_close(callback=self.stop) + try: + self.wait(timeout=1.0) + except AssertionError: + raise AssertionError("subprocess failed to terminate") + else: + raise AssertionError("subprocess closed stdout but failed to " + "get termination signal") self.assertEqual(subproc.returncode, ret) self.assertEqual(ret, -signal.SIGTERM)