Skip to content

Commit d18cd8b

Browse files
test(e2e): 340 只数它自己那个目录里的 ninja (#557)
THE PREDICATE WAS RIGHT AND THE OBJECT WAS WRONG. `count_ninja` counted every ninja on the machine. A baseline taken before the build covers one that was ALREADY running; it does not cover one that appears during the window, and a build server, a second checkout or a parallel test can start one at any moment. Measured in an ecosystem sandbox, which shares the host's PID namespace: an unrelated session's ninja, in a different project entirely, made this assertion fail on a build that has the fix. Counting is now scoped by the process's working directory to the test's own `$work` tree. Verified that scoping did not weaken it: the test still FAILS against the released 2026.9.4.2, naming the orphan and its directory. Co-authored-by: speak-agent <248744407+speak-agent@users.noreply.github.com>
1 parent d3773e7 commit d18cd8b

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

tests/e2e/340_no_orphan_survives_a_killed_mcpp.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,23 @@ work="$(mktemp -d)"; trap 'rm -rf "$work"' EXIT
3333
cd "$work"
3434
mkdir -p src
3535

36-
# Counting by executable name, not by a `pgrep -f` pattern: this script's own
37-
# command line contains the word, and a pattern match finds itself.
36+
# COUNTING BY EXECUTABLE NAME AND BY WORKING DIRECTORY, AND BOTH HALVES MATTER.
37+
#
38+
# Not by a `pgrep -f` pattern: this script's own command line contains the word,
39+
# and a pattern match finds itself.
40+
#
41+
# And not every ninja on the machine: a build server, a developer's second
42+
# checkout, or another test running in parallel can start one inside this
43+
# check's window, and a baseline taken before the build does not cover a process
44+
# that appears during it. Measured in an ecosystem sandbox — which shares the
45+
# host's PID namespace — where an unrelated session's ninja in a different
46+
# project failed this assertion. The predicate was right and the object was
47+
# wrong.
3848
count_ninja() {
3949
local n=0 p
4050
for p in /proc/[0-9]*; do
41-
[[ "$(cat "$p/comm" 2>/dev/null)" == "ninja" ]] && n=$((n+1))
51+
[[ "$(cat "$p/comm" 2>/dev/null)" == "ninja" ]] || continue
52+
case "$(readlink "$p/cwd" 2>/dev/null)" in "$work"*) n=$((n+1));; esac
4253
done
4354
echo "$n"
4455
}

0 commit comments

Comments
 (0)