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.
This commit is contained in:
Fabian Boehm
2025-01-14 16:19:07 +01:00
parent 37a1611b54
commit d32257c2d5

View File

@@ -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")