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.
This commit is contained in:
Jose Diaz-Gonzalez
2026-05-09 13:36:29 -04:00
parent 25abd38387
commit f4213a4bf5

View File

@@ -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