Speed up wait.expect test

(This is being committed to a branch on the main repository so I can
verify that Travis is able to run this OK.)
This commit is contained in:
Mahmoud Al-Qudsi 2018-12-31 19:36:08 -06:00
parent f871951a87
commit 131f0f2de5

View File

@ -15,33 +15,33 @@ expect_prompt "jobs: There are no jobs" {} unmatched { puts stderr $error_msg }
# three job ids specified
set error_msg "three job ids specified: Fail"
send_line "sleep 3 &; sleep 1 &; sleep 2 &; sleep 4 &;"
send_line "sleep 0.3 &; sleep 0.1 &; sleep 0.2 &; sleep 0.4 &;"
expect_prompt
send_line "wait %1 %3 %4"
expect "Job 2, 'sleep 1 &' has ended" {} timeout { puts stderr $error_msg }
expect "Job 3, 'sleep 2 &' has ended" {} timeout { puts stderr $error_msg }
expect "Job 1, 'sleep 3 &' has ended" {} timeout { puts stderr $error_msg }
expect_prompt "Job 4, 'sleep 4 &' has ended" {} unmatched { puts stderr $error_msg }
expect "Job 2, 'sleep 0.1 &' has ended" {} timeout { puts stderr $error_msg }
expect "Job 3, 'sleep 0.2 &' has ended" {} timeout { puts stderr $error_msg }
expect "Job 1, 'sleep 0.3 &' has ended" {} timeout { puts stderr $error_msg }
expect_prompt "Job 4, 'sleep 0.4 &' has ended" {} unmatched { puts stderr $error_msg }
send_line "jobs"
expect_prompt "jobs: There are no jobs" {} unmatched { puts stderr $error_msg }
# specify job ids with -n option
set error_msg "specify job ids with -n option: Fail"
send_line "sleep 3 &; sleep 1 &; sleep 2 &"
send_line "sleep 0.3 &; sleep 0.1 &; sleep 0.2 &"
expect_prompt
send_line "wait -n %1 %3"
expect "Job 2, 'sleep 1 &' has ended" {} timeout { puts stderr $error_msg }
expect_prompt "Job 3, 'sleep 2 &' has ended" {} unmatched { puts stderr $error_msg }
expect "Job 2, 'sleep 0.1 &' has ended" {} timeout { puts stderr $error_msg }
expect_prompt "Job 3, 'sleep 0.2 &' has ended" {} unmatched { puts stderr $error_msg }
send_line "wait -n %1"
expect_prompt "Job 1, 'sleep 3 &' has ended" {} unmatched { puts stderr $error_msg }
expect_prompt "Job 1, 'sleep 0.3 &' has ended" {} unmatched { puts stderr $error_msg }
send_line "jobs"
expect_prompt "jobs: There are no jobs" {} unmatched { puts stderr $error_msg }
# don't wait for stopped jobs
set error_msg "don't wait for stopped jobs: Fail"
send_line "sleep 3 &"
send_line "sleep 0.3 &"
expect_prompt
send_line "kill -STOP %1"
expect_prompt
@ -71,7 +71,7 @@ expect_prompt "jobs: There are no jobs" {} unmatched { puts stderr $error_msg }
# wait for jobs by its process name with -n option
set error_msg "wait for jobs by its process name with -n option: Fail"
send_line "for i in (seq 1 3); sleep \$i &; end"
send_line "for i in (seq 1 3); sleep 0.\$i &; end"
expect_prompt
send_line "wait -n sleep"
expect_prompt
@ -86,11 +86,11 @@ expect_prompt "jobs: There are no jobs" {} unmatched { puts stderr $error_msg }
# complex case
set error_msg "complex case: Fail"
send_line "for i in (seq 1 10); ls | sleep 2 | cat > /dev/null &; end"
send_line "for i in (seq 1 10); ls | sleep 0.2 | cat > /dev/null &; end"
expect_prompt
send_line "sleep 3 | cat &"
send_line "sleep 0.3 | cat &"
expect_prompt
send_line "sleep 1 &"
send_line "sleep 0.1 &"
expect_prompt
send_line "wait \$last_pid sleep"
expect_prompt
@ -110,7 +110,7 @@ expect_prompt "jobs: There are no jobs" {} unmatched { puts stderr $error_msg }
# test with fish script
set error_msg "test with fish script: Fail"
send_line "fish -c 'sleep 2 &; sleep 3 &; sleep 1 &; wait -n sleep; jobs | wc -l'"
send_line "fish -c 'sleep 0.2 &; sleep 0.3 &; sleep 0.1 &; wait -n sleep; jobs | wc -l'"
expect "1" {} timeout { puts stderr $error_msg }
expect_prompt