Skip to content

Commit b7a413a

Browse files
author
Sungin Kim
committed
Merge fm/fm-session-start-e2e-failure (upstream PR 1476)
Both sides had hardened the same MISSING-tool fixture against host PATH leakage: the fork removes no-mistakes (never present in a system PATH), this branch adds hide_node. Both statements are kept, because the surrounding assertions require the no-mistakes MISSING line while the auto-merged run_session_start calls require the mask this branch produces.
2 parents 7a18213 + 38951b1 commit b7a413a

1 file changed

Lines changed: 27 additions & 4 deletions

File tree

‎tests/fm-session-start.test.sh‎

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,25 @@ SH
8686
printf '%s\n' manual > "${fakebin%/*}/home-placeholder" 2>/dev/null || true
8787
}
8888

89+
# hide_node <fakebin> <home>: make node genuinely undetectable so bootstrap emits
90+
# its real "MISSING: node" diagnostic. Deleting the fake binary alone is not
91+
# enough on hosts that ship node in the base PATH, so this also masks the lookup
92+
# the same way the Herdr cases mask tmux. Echoes the mask path for BASH_ENV.
93+
hide_node() {
94+
local fakebin=$1 home=$2 mask
95+
rm -f "$fakebin/node"
96+
mask="$home/mask-node.bash"
97+
cat > "$mask" <<'SH'
98+
command() {
99+
if [ "${1:-}" = -v ] && [ "${2:-}" = node ]; then
100+
return 1
101+
fi
102+
builtin command "$@"
103+
}
104+
SH
105+
printf '%s\n' "$mask"
106+
}
107+
89108
make_fake_tasks_axi_compact() {
90109
local fakebin=$1
91110
cat > "$fakebin/tasks-axi" <<'SH'
@@ -793,7 +812,7 @@ SH
793812
# --- output ordering ----------------------------------------------------------
794813

795814
test_output_ordering_diagnostics_lead() {
796-
local rec root home fakebin out lock_line boot_line wake_line context_line fleet_line next_line
815+
local rec root home fakebin mask out lock_line boot_line wake_line context_line fleet_line next_line
797816
rec=$(new_world ordering)
798817
IFS='|' read -r root home fakebin <<EOF
799818
$rec
@@ -805,10 +824,13 @@ EOF
805824
# rather than a common tool like node that a host may install into $BASE_PATH
806825
# (/usr/bin) and thereby mask the forced-missing condition.
807826
rm -f "$fakebin/no-mistakes"
827+
# Also mask node, so a host that ships it in the base PATH cannot change which
828+
# other diagnostics the digest emits around the asserted line.
829+
mask=$(hide_node "$fakebin" "$home")
808830

809831
printf 'window=fm-sess:w1\nkind=ship\n' > "$home/state/task-a.meta"
810832

811-
out=$(run_session_start "$home" "$root" "$fakebin:$BASE_PATH")
833+
out=$(BASH_ENV="$mask" run_session_start "$home" "$root" "$fakebin:$BASE_PATH")
812834

813835
lock_line=$(printf '%s\n' "$out" | grep -n '^LOCK$' | head -1 | cut -d: -f1)
814836
boot_line=$(printf '%s\n' "$out" | grep -n '^BOOTSTRAP$' | head -1 | cut -d: -f1)
@@ -1079,7 +1101,7 @@ EOF
10791101
# --- composition: real scripts run, not reimplemented ------------------------
10801102

10811103
test_composition_invokes_real_scripts() {
1082-
local rec root home fakebin out
1104+
local rec root home fakebin mask out
10831105
rec=$(new_world composition)
10841106
IFS='|' read -r root home fakebin <<EOF
10851107
$rec
@@ -1089,11 +1111,12 @@ EOF
10891111
# Force a MISSING via a firstmate-specific tool never on a standard system PATH
10901112
# (node can leak from $BASE_PATH; see test_output_ordering_diagnostics_lead).
10911113
rm -f "$fakebin/no-mistakes"
1114+
mask=$(hide_node "$fakebin" "$home")
10921115

10931116
printf 'needs-decision: pick a library\n' > "$home/state/task-z.status"
10941117
append_wake "$home/state" signal task-z.status "needs-decision: pick a library"
10951118

1096-
out=$(run_session_start "$home" "$root" "$fakebin:$BASE_PATH")
1119+
out=$(BASH_ENV="$mask" run_session_start "$home" "$root" "$fakebin:$BASE_PATH")
10971120

10981121
# fm-lock.sh's own exact success text.
10991122
assert_contains "$out" "lock acquired: harness pid" "fm-lock.sh's real output did not appear (composition, not reimplementation)"

0 commit comments

Comments
 (0)