From 9070ed8039911b52c77018e736a1a09e8bbc9a7a Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sat, 4 Sep 2021 13:32:51 -0700 Subject: [PATCH] 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. --- tests/pexpects/job_summary.py | 4 +++- tests/pexpects/signals.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/pexpects/job_summary.py b/tests/pexpects/job_summary.py index ba2e89486..d9e8984d5 100644 --- a/tests/pexpects/job_summary.py +++ b/tests/pexpects/job_summary.py @@ -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) diff --git a/tests/pexpects/signals.py b/tests/pexpects/signals.py index 35bc9a64c..4fbf8f163 100644 --- a/tests/pexpects/signals.py +++ b/tests/pexpects/signals.py @@ -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()