@@ -55,10 +55,20 @@ check "unsupported value (pack)" 2 "$MCPP" pack --format bogus
5555# And the supported ones must still be JSON on stdout. Asserted here because
5656# every check above is about what does NOT happen; without this, deleting the
5757# feature entirely would leave the file green.
58+ #
59+ # HERE-STRINGS, NOT PIPES. `set -o pipefail` is on, and `grep -q` exits the
60+ # moment it matches — so `echo "$out" | grep -q` leaves `echo` writing into a
61+ # closed pipe, takes SIGPIPE, and the pipeline reports 141 even though the
62+ # match SUCCEEDED. It only shows up once `$out` is big enough that echo has not
63+ # finished writing, which for `cache list` means "once this machine has built a
64+ # few things": measured 3-4 failures in 5 runs on a developer box with a warm
65+ # build cache, and zero on CI, with `grep -c` on the same string finding 153
66+ # matches. A test that fails on the size of an unrelated cache is a test that
67+ # will be read as a regression in whatever happens to be in flight.
5868for cmd in " self env" " cache list" ; do
5969 out=$( $MCPP $cmd --format json 2> /dev/null) || { echo " FAIL: $cmd --format json exited non-zero" ; fail=1; }
60- echo " $out " | grep -q ' "schemaVersion"' || { echo " FAIL: $cmd --format json has no schemaVersion" ; fail=1; }
61- echo " $out " | grep -q ' "kind"' || { echo " FAIL: $cmd --format json has no kind" ; fail=1; }
70+ grep -q ' "schemaVersion"' <<< " $out " || { echo " FAIL: $cmd --format json has no schemaVersion" ; fail=1; }
71+ grep -q ' "kind"' <<< " $out " || { echo " FAIL: $cmd --format json has no kind" ; fail=1; }
6272done
6373
6474[[ " $fail " -eq 0 ]] || exit 1
0 commit comments