Skip to content

Commit 2ce4050

Browse files
committed
test: avoid broken pipes in monitor runtime checks
1 parent e08c0d0 commit 2ce4050

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

tests/test-monitor-runtime.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -109,25 +109,25 @@ chmod +x test_graceful_stop.sh
109109
output=$(./test_graceful_stop.sh "$TEST_BASE" "$PROJECT_ROOT" 2>&1)
110110

111111
# Verify the output contains expected messages
112-
if echo "$output" | grep -q "RESTORE_TERMINAL_CALLED"; then
112+
if grep -q "RESTORE_TERMINAL_CALLED" <<< "$output"; then
113113
pass "_restore_terminal was called"
114114
else
115115
fail "_restore_terminal call" "Function not called"
116116
fi
117117

118-
if echo "$output" | grep -q "CLEANUP_CALLED"; then
118+
if grep -q "CLEANUP_CALLED" <<< "$output"; then
119119
pass "_cleanup was called"
120120
else
121121
fail "_cleanup call" "Function not called"
122122
fi
123123

124-
if echo "$output" | grep -q "Monitoring stopped:"; then
124+
if grep -q "Monitoring stopped:" <<< "$output"; then
125125
pass "Graceful stop message displayed"
126126
else
127127
fail "Graceful stop message" "Message not found"
128128
fi
129129

130-
if echo "$output" | grep -q "directory no longer exists"; then
130+
if grep -q "directory no longer exists" <<< "$output"; then
131131
pass "User-friendly reason in message"
132132
else
133133
fail "User-friendly reason" "Reason not in message"
@@ -170,7 +170,7 @@ TESTSCRIPT
170170
chmod +x test_double_cleanup.sh
171171
output=$(./test_double_cleanup.sh 2>&1)
172172

173-
if echo "$output" | grep -q "FINAL_COUNT: 1"; then
173+
if grep -q "FINAL_COUNT: 1" <<< "$output"; then
174174
pass "Cleanup only executed once (idempotent)"
175175
else
176176
fail "Idempotent cleanup" "Cleanup executed multiple times"
@@ -232,19 +232,19 @@ TESTSCRIPT
232232
chmod +x test_loop_detection.sh
233233
output=$(./test_loop_detection.sh "$TEST_BASE" 2>&1)
234234

235-
if echo "$output" | grep -q "CONTINUING"; then
235+
if grep -q "CONTINUING" <<< "$output"; then
236236
pass "Monitor continues while directory exists"
237237
else
238238
fail "Directory existence check" "Stopped while directory exists"
239239
fi
240240

241-
if echo "$output" | grep -q "STOPPED_AFTER_DELETE"; then
241+
if grep -q "STOPPED_AFTER_DELETE" <<< "$output"; then
242242
pass "Monitor detects deletion and stops gracefully"
243243
else
244244
fail "Deletion detection" "Did not stop after deletion"
245245
fi
246246

247-
if echo "$output" | grep -q "GRACEFUL_STOP"; then
247+
if grep -q "GRACEFUL_STOP" <<< "$output"; then
248248
pass "Graceful stop triggered on deletion"
249249
else
250250
fail "Graceful stop trigger" "Not triggered"
@@ -290,13 +290,13 @@ TESTSCRIPT
290290
chmod +x test_terminal_restore.sh
291291
output=$(./test_terminal_restore.sh "$TEST_BASE" "$PROJECT_ROOT" 2>&1)
292292

293-
if echo "$output" | grep -q "FUNCTION_DEFINED"; then
293+
if grep -q "FUNCTION_DEFINED" <<< "$output"; then
294294
pass "_restore_terminal function is defined"
295295
else
296296
fail "_restore_terminal definition" "Function not found"
297297
fi
298298

299-
if echo "$output" | grep -q "SCROLL_REGION_RESET"; then
299+
if grep -q "SCROLL_REGION_RESET" <<< "$output"; then
300300
pass "_restore_terminal resets scroll region"
301301
else
302302
fail "Scroll region reset" "Reset command not found"
@@ -393,7 +393,7 @@ TESTSCRIPT
393393
chmod +x test_sigint_bash.sh
394394
output=$(./test_sigint_bash.sh 2>&1)
395395

396-
if echo "$output" | grep -q "CLEANUP_BY_SIGINT"; then
396+
if grep -q "CLEANUP_BY_SIGINT" <<< "$output"; then
397397
pass "SIGINT triggers _cleanup in bash"
398398
else
399399
fail "SIGINT in bash" "Cleanup not triggered"
@@ -494,11 +494,11 @@ TESTSCRIPT
494494
# Run in subshell to prevent SIGINT propagation to parent
495495
output=$(bash -c 'trap "" INT; zsh test_sigint_zsh.zsh 2>&1' || true)
496496

497-
if echo "$output" | grep -q "CLEANUP_BY_SIGINT_ZSH"; then
497+
if grep -q "CLEANUP_BY_SIGINT_ZSH" <<< "$output"; then
498498
pass "SIGINT triggers TRAPINT cleanup in zsh"
499499
else
500500
# zsh might handle signals differently, check if it at least ran
501-
if echo "$output" | grep -q "ZSH_SIGINT_HANDLED"; then
501+
if grep -q "ZSH_SIGINT_HANDLED" <<< "$output"; then
502502
pass "SIGINT triggers TRAPINT cleanup in zsh"
503503
else
504504
fail "SIGINT in zsh" "TRAPINT cleanup not triggered: $output"

0 commit comments

Comments
 (0)