From d32257c2d583dafb99172f44eb17733591d43b6f Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Tue, 14 Jan 2025 16:19:07 +0100 Subject: [PATCH] pexpects/wait: wait on the same line as the background jobs The issue here is we start some short `sleep`s in the background, wait for a prompt, and only *then* wait for jobs, and *then* check for the job end output. That means if the prompt takes too long, we'll read the job end messages with the `expect_prompt`. Instead of increasing the timeouts, just wait on the same line and remove that prompt. --- tests/pexpects/wait.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/pexpects/wait.py b/tests/pexpects/wait.py index 3dc21fc62..6e6e365c3 100644 --- a/tests/pexpects/wait.py +++ b/tests/pexpects/wait.py @@ -28,9 +28,7 @@ sendline("jobs") expect_prompt("jobs: There are no jobs") # three job ids specified -sendline("sleep 0.5 &; sleep 0.1 &; sleep 0.3 &; sleep 0.7 &;") -expect_prompt() -sendline("wait %1 %3 %4") +sendline("sleep 0.5 &; sleep 0.1 &; sleep 0.3 &; sleep 0.7 &; wait %1 %3 %4") expect_str("Job 2, 'sleep 0.1 &' has ended") expect_str("Job 3, 'sleep 0.3 &' has ended") expect_str("Job 1, 'sleep 0.5 &' has ended") @@ -39,9 +37,7 @@ sendline("jobs") expect_prompt("jobs: There are no jobs") # specify job ids with -n option -sendline("sleep 0.5 &; sleep 0.1 &; sleep 0.3 &") -expect_prompt() -sendline("wait -n %1 %3") +sendline("sleep 0.5 &; sleep 0.1 &; sleep 0.3 &; wait -n %1 %3") expect_str("Job 2, 'sleep 0.1 &' has ended") expect_prompt("Job 3, 'sleep 0.3 &' has ended") sendline("wait -n %1")