]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-121988: Fix test hang when pyrepl is not available (#121990)
authorSam Gross <colesbury@gmail.com>
Sat, 20 Jul 2024 14:04:14 +0000 (10:04 -0400)
committerGitHub <noreply@github.com>
Sat, 20 Jul 2024 14:04:14 +0000 (16:04 +0200)
Also explicitly fail the test if we timeout while waiting for output so
that this failure mode is caught earlier.

Lib/test/test_pyrepl/test_pyrepl.py

index e6fcb69571c3247ef0420d70ada3684e98bf26ab..e3feeeb76f11d696687c7868988747433151c6e5 100644 (file)
@@ -964,7 +964,7 @@ class TestMain(TestCase):
             mod.write_text("FOO = 42", encoding="utf-8")
             commands = [
                 "print(f'{" + var + "=}')" for var in expectations
-            ] + ["exit"]
+            ] + ["exit()"]
             if as_file and as_module:
                 self.fail("as_file and as_module are mutually exclusive")
             elif as_file:
@@ -1115,6 +1115,10 @@ class TestMain(TestCase):
             except OSError:
                 break
             output.append(data)
+        else:
+            os.close(master_fd)
+            process.kill()
+            self.fail(f"Timeout while waiting for output, got: {''.join(output)}")
 
         os.close(master_fd)
         try: