Skip to content

Commit 71d815f

Browse files
committed
fix(e2e): the leg-selection grep assumed forward slashes
256's `check` extracted the selected leg with `grep -o "dist/mathkit-0.1.0/lib/[A-Za-z0-9_-]*"`. A native mcpp.exe writes NATIVE separators into build.ninja, so on Windows that matched nothing at all and the test reported native saw more than one leg: (empty) — i.e. a count of zero, printed as "more than one", over an empty list. It reads like a packaging bug on the one platform where nothing else could confirm it, and it is a grep bug. Anchored on the package name instead, with `[\\/]` for either separator, and the failure now prints the count and the package's own lines from build.ninja so the next reader is not guessing. 245 carries the same helper — it only runs on Linux, but leaving the fragile version there invites the next test to copy it — and passes locally with it, which is what validates the pattern on `/`.
1 parent 3d104ca commit 71d815f

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

tests/e2e/245_pack_library_fat_target_selection.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,16 @@ check() { # $1 = label, $2 = expected leg dir, $3.. = build args
101101
( cd app && "$MCPP" build "$@" > "$TMP/$label.log" 2>&1 ) \
102102
|| { cat "$TMP/$label.log"; echo "$label build failed"; exit 1; }
103103
local nj; nj="$(find app/target -name build.ninja | head -1)"
104-
grep -o "dist/mathkit-0.1.0/lib/[a-z0-9_-]*" "$nj" | sort -u > "$TMP/$label.legs"
104+
# Separator-agnostic and anchored on the PACKAGE name: a native mcpp.exe
105+
# writes native separators into build.ninja, so a `dist/…/lib/…` pattern
106+
# matches nothing there and the failure reads like a packaging bug. Same
107+
# helper as 256, which is where that was measured.
108+
grep -oE "mathkit-0\.1\.0[\\/]lib[\\/][A-Za-z0-9_-]+" "$nj" \
109+
| sed 's|.*[\\/]||' | sort -u > "$TMP/$label.legs"
105110
[[ "$(wc -l < "$TMP/$label.legs")" -eq 1 ]] || {
106-
echo "$label saw more than one leg:"; cat "$TMP/$label.legs"; exit 1; }
107-
grep -q "lib/$want\$" "$TMP/$label.legs" || {
111+
echo "$label saw $(wc -l < "$TMP/$label.legs") leg(s), expected exactly 1:"
112+
cat "$TMP/$label.legs"; exit 1; }
113+
grep -qx "$want" "$TMP/$label.legs" || {
108114
echo "$label picked the wrong leg:"; cat "$TMP/$label.legs"; exit 1; }
109115
}
110116

tests/e2e/256_pack_library_fat_windows.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,20 @@ check() { # $1 = label, $2 = expected leg dir, $3.. = build args
125125
( cd app && "$MCPP" build "$@" > "$TMP/$label.log" 2>&1 ) \
126126
|| { cat "$TMP/$label.log"; echo "$label build failed"; exit 1; }
127127
local nj; nj="$(find app/target -name build.ninja | head -1)"
128-
grep -o "dist/mathkit-0.1.0/lib/[A-Za-z0-9_-]*" "$nj" | sort -u > "$TMP/$label.legs"
128+
# ⚠️ Separator-agnostic, and matched from the PACKAGE name rather than from
129+
# `dist/`. A native mcpp.exe writes native separators into build.ninja, so
130+
# the first version of this — `grep -o "dist/mathkit-0.1.0/lib/…"` — matched
131+
# nothing at all on Windows and reported "saw more than one leg" over an
132+
# empty list, which reads like a packaging bug and is a grep bug.
133+
grep -oE "mathkit-0\.1\.0[\\/]lib[\\/][A-Za-z0-9_-]+" "$nj" \
134+
| sed 's|.*[\\/]||' | sort -u > "$TMP/$label.legs"
129135
[[ "$(wc -l < "$TMP/$label.legs")" -eq 1 ]] || {
130-
echo "$label saw more than one leg:"; cat "$TMP/$label.legs"; exit 1; }
131-
grep -q "lib/$want\$" "$TMP/$label.legs" || {
136+
echo "$label saw $(wc -l < "$TMP/$label.legs") leg(s), expected exactly 1:"
137+
cat "$TMP/$label.legs"
138+
echo "--- lines mentioning the package ---"
139+
grep -n 'mathkit' "$nj" | head -20
140+
exit 1; }
141+
grep -qx "$want" "$TMP/$label.legs" || {
132142
echo "$label picked the wrong leg:"; cat "$TMP/$label.legs"; exit 1; }
133143
}
134144

0 commit comments

Comments
 (0)