From 605bd10a051c2fc6bc3a02d336aa2bc23a2bf94a Mon Sep 17 00:00:00 2001 From: speak-agent <248744407+speak-agent@users.noreply.github.com> Date: Fri, 4 Sep 2026 20:13:02 +0800 Subject: [PATCH] =?UTF-8?q?test(e2e):=20340=20=E5=8F=AA=E6=95=B0=E5=AE=83?= =?UTF-8?q?=E8=87=AA=E5=B7=B1=E9=82=A3=E4=B8=AA=E7=9B=AE=E5=BD=95=E9=87=8C?= =?UTF-8?q?=E7=9A=84=20ninja?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../e2e/340_no_orphan_survives_a_killed_mcpp.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/e2e/340_no_orphan_survives_a_killed_mcpp.sh b/tests/e2e/340_no_orphan_survives_a_killed_mcpp.sh index 9851ec57..e481d809 100755 --- a/tests/e2e/340_no_orphan_survives_a_killed_mcpp.sh +++ b/tests/e2e/340_no_orphan_survives_a_killed_mcpp.sh @@ -33,12 +33,23 @@ work="$(mktemp -d)"; trap 'rm -rf "$work"' EXIT cd "$work" mkdir -p src -# Counting by executable name, not by a `pgrep -f` pattern: this script's own -# command line contains the word, and a pattern match finds itself. +# COUNTING BY EXECUTABLE NAME AND BY WORKING DIRECTORY, AND BOTH HALVES MATTER. +# +# Not by a `pgrep -f` pattern: this script's own command line contains the word, +# and a pattern match finds itself. +# +# And not every ninja on the machine: a build server, a developer's second +# checkout, or another test running in parallel can start one inside this +# check's window, and a baseline taken before the build does not cover a process +# that appears during it. Measured in an ecosystem sandbox — which shares the +# host's PID namespace — where an unrelated session's ninja in a different +# project failed this assertion. The predicate was right and the object was +# wrong. count_ninja() { local n=0 p for p in /proc/[0-9]*; do - [[ "$(cat "$p/comm" 2>/dev/null)" == "ninja" ]] && n=$((n+1)) + [[ "$(cat "$p/comm" 2>/dev/null)" == "ninja" ]] || continue + case "$(readlink "$p/cwd" 2>/dev/null)" in "$work"*) n=$((n+1));; esac done echo "$n" }