Skip to content

Commit d43083d

Browse files
committed
test(337): the build half reads the cache entry, not whichever file find returns first
⚠️⚠️ IT PASSED LOCALLY AND FAILED ON CI, WHICH IS THE SIGNATURE OF AN ASSERTION THAT DEPENDS ON SOMETHING NOBODY CHOSE. The block ran `find target -name featrun | head -1`. By then two output directories exist — one per feature set — and which one `find` walks first is filesystem order. What the fix actually changed is the cache ENTRY: it records the feature set its artefacts were built with, and both fast paths compare it. Entries are written most-recently-used first, so the first `features=` line belongs to the build that just ran. Reading it is exact and order-free. Measured on the same project: plain -> '', --features loud -> 'loud', plain again -> '' — the third being the reading that was 'loud' before the fix.
1 parent 45a36db commit d43083d

1 file changed

Lines changed: 27 additions & 9 deletions

File tree

‎tests/e2e/337_run_takes_features_and_profile.sh‎

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,37 @@ want "$again" "dev" "a plain run inherited the previous --release"
8585
#
8686
# Measured before the fix: three builds of one project printed
8787
# `quiet`, `LOUD`, `LOUD`.
88-
artifact() { find target -type f -name featrun -newermt '-1 day' | head -1; }
88+
# ⚠️⚠️ THE ASSERTION IS ON WHAT THE CACHE ENTRY RECORDS, NOT ON WHICH FILE A
89+
# `find` HAPPENS TO RETURN FIRST.
90+
#
91+
# The first version of this block ran `find target -name featrun | head -1`.
92+
# Two output directories exist by then — one per feature set — and which one
93+
# `find` walks first is filesystem order. It passed locally and failed on CI,
94+
# which is the signature of an assertion that depends on something nobody
95+
# chose.
96+
#
97+
# What the fix actually changed is the ENTRY: it now records the feature set its
98+
# artefacts were built with, and both fast paths compare it. Entries are written
99+
# most-recently-used first, so the first `features=` line in the cache belongs
100+
# to the build that just ran — and reading it is exact.
101+
mru_features() { awk -F= '/^features=/{print $2; exit}' target/.build_cache; }
89102

90103
rm -rf target
91104
"$MCPP" build >/dev/null 2>&1
92-
first="$(./"$(artifact)")"
105+
[ -z "$(mru_features)" ] || {
106+
echo "FAIL: a plain build recorded features '$(mru_features)'"; exit 1; }
107+
93108
"$MCPP" build --features loud >/dev/null 2>&1
109+
[ "$(mru_features)" = "loud" ] || {
110+
echo "FAIL: --features loud recorded '$(mru_features)', expected loud"; exit 1; }
111+
112+
# ⚠️ THE ONE THAT CAUGHT THE PRE-EXISTING DEFECT. Before the entry carried a
113+
# feature set, this plain build matched the entry `--features loud` had written,
114+
# reported success in 0.00s and left the loud artefact in place. Measured: three
115+
# consecutive builds of one project printed `quiet`, `LOUD`, `LOUD`.
94116
"$MCPP" build >/dev/null 2>&1
95-
third="$(./"$(artifact)")"
96-
case "$first" in *quiet*) ;; *) echo "FAIL: the first build was not plain"; exit 1 ;; esac
97-
case "$third" in
98-
*quiet*) ;;
99-
*) echo "FAIL: a plain build after --features served the featured artefact"
100-
echo " first=$first third=$third"; exit 1 ;;
101-
esac
117+
[ -z "$(mru_features)" ] || {
118+
echo "FAIL: a plain build after --features matched an entry recorded as '$(mru_features)'"
119+
exit 1; }
102120

103121
echo "PASS: mcpp run takes --features and --profile, and the fast path honours both"

0 commit comments

Comments
 (0)