From f4213a4bf505990a0e4deafd46da21f54081b4f7 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 9 May 2026 13:36:29 -0400 Subject: [PATCH] tests: prevent assert_output_contains from aborting on no match Bats runs tests under `set -eo pipefail`, so when `grep -F -o` finds nothing inside the count pipe it exits 1, the whole pipe fails, errexit fires, and the function aborts before reaching the count comparison. Wrap grep in `{ ... || true; }` so the pipe stays zero when the pattern is absent and the helper falls through to the flunk message. --- tests/unit/test_helper.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/test_helper.bash b/tests/unit/test_helper.bash index 08fbd4a63..a998d67bc 100644 --- a/tests/unit/test_helper.bash +++ b/tests/unit/test_helper.bash @@ -144,7 +144,7 @@ assert_output_contains() { local expected="$1" local count="${2:-1}" local found - found=$(printf '%s' "$input" | grep -F -o -- "$expected" | wc -l | tr -d ' ') + found=$(printf '%s' "$input" | { grep -F -o -- "$expected" || true; } | wc -l | tr -d ' ') if [[ "$count" -eq -1 ]]; then if [[ "$found" -gt 0 ]]; then