Correct the order of pkill arguments

On macOS, the tests would often fail because calls to `pkill` would "leak"
across tests: kill processes run by other tests. This is because on macOS,
the -P argument to pkill must come before the process name. On Linux it
doesn't matter.

This improves test reliability on Mac.
This commit is contained in:
ridiculousfish 2021-09-04 13:32:51 -07:00
parent 2e24aaa605
commit 9070ed8039
2 changed files with 5 additions and 3 deletions

View file

@ -51,5 +51,7 @@ expect_prompt()
# cmd_line contains the entire pipeline. proc_id and proc_name are set in a pipeline.
sendline("true | sleep 6")
sleep(0.100)
call(["pkill", "-KILL", "sleep", "-P", str(sp.spawn.pid)])
# Beware: Mac pkill requires that the -P argument come before the process name,
# else the -P argument is ignored.
call(["pkill", "-KILL", "-P", str(sp.spawn.pid), "sleep"])
expect_re("[0-9]+:1:true|sleep 6:SIGKILL:Forced quit:[0-9]+:sleep", timeout=20)

View file

@ -53,13 +53,13 @@ sendline(
expect_prompt()
sendline("sleep 5")
sleep(0.100)
subprocess.call(["pkill", "-INT", "sleep", "-P", str(sp.spawn.pid)])
subprocess.call(["pkill", "-INT", "-P", str(sp.spawn.pid), "sleep"])
expect_str("fish_kill_signal 2")
expect_prompt()
sendline("sleep 5")
sleep(0.100)
subprocess.call(["pkill", "-TERM", "sleep", "-P", str(sp.spawn.pid)])
subprocess.call(["pkill", "-TERM", "-P", str(sp.spawn.pid), "sleep"])
expect_str("fish_kill_signal 15")
expect_prompt()