mirror of
https://github.com/dokku/dokku.git
synced 2026-05-18 05:05:46 +02:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user