Skip to content

Commit 3ffd75e

Browse files
committed
test: avoid broken pipe in template-loader assertions
Use here-strings instead of echo | grep pipelines so that grep -q finishing early cannot raise SIGPIPE on echo under set -o pipefail. Mirrors the same fix already applied to test-templates-comprehensive.sh.
1 parent e96f864 commit 3ffd75e

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

tests/test-template-loader.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ RESULT=$(load_and_render "$TEMPLATE_DIR" "block/wrong-round-number.md" \
155155
"CURRENT_ROUND=5" \
156156
"CORRECT_PATH=/tmp/round-5-summary.md")
157157

158-
if echo "$RESULT" | grep -q "Wrong Round Number" && \
159-
echo "$RESULT" | grep -q "round-3-summary.md" && \
160-
echo "$RESULT" | grep -q "current round is \*\*5\*\*"; then
158+
if grep -q "Wrong Round Number" <<<"$RESULT" && \
159+
grep -q "round-3-summary.md" <<<"$RESULT" && \
160+
grep -q "current round is \*\*5\*\*" <<<"$RESULT"; then
161161
pass "load_and_render works correctly with real template"
162162
else
163163
fail "load_and_render integration test" "Content with replaced variables" "$RESULT"
@@ -201,7 +201,7 @@ echo "Test 11: load_and_render_safe - missing template uses fallback"
201201
FALLBACK="Fallback message: {{VAR}}"
202202
RESULT=$(load_and_render_safe "$TEMPLATE_DIR" "non-existing.md" "$FALLBACK" "VAR=test_value")
203203

204-
if echo "$RESULT" | grep -q "Fallback message: test_value"; then
204+
if grep -q "Fallback message: test_value" <<<"$RESULT"; then
205205
pass "load_and_render_safe uses fallback for missing template"
206206
else
207207
fail "load_and_render_safe fallback" "Fallback message: test_value" "$RESULT"
@@ -215,7 +215,7 @@ echo "Test 12: load_and_render_safe - existing template works normally"
215215
FALLBACK="This should not appear"
216216
RESULT=$(load_and_render_safe "$TEMPLATE_DIR" "block/git-push.md" "$FALLBACK")
217217

218-
if echo "$RESULT" | grep -q "Git Push Blocked" && ! echo "$RESULT" | grep -q "should not appear"; then
218+
if grep -q "Git Push Blocked" <<<"$RESULT" && ! grep -q "should not appear" <<<"$RESULT"; then
219219
pass "load_and_render_safe uses template when available"
220220
else
221221
fail "load_and_render_safe with existing template" "Git Push Blocked (not fallback)" "$RESULT"

0 commit comments

Comments
 (0)