From 7bc8f2c8a167f4af77e293dd3392c19bec9f723b Mon Sep 17 00:00:00 2001 From: Mykhailo Chalyi Date: Tue, 7 Apr 2026 01:08:43 +0000 Subject: [PATCH] test(redirect): add append redirect spec tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds comprehensive tests for >> append behavior in compound commands, brace groups, if/else, and rebuild cycle patterns. All tests pass — the basic append mechanism is correct. If the issue reappears with a specific reproduction, these tests provide a baseline. Closes #1119 --- .../spec_cases/bash/append_redirect.test.sh | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 crates/bashkit/tests/spec_cases/bash/append_redirect.test.sh diff --git a/crates/bashkit/tests/spec_cases/bash/append_redirect.test.sh b/crates/bashkit/tests/spec_cases/bash/append_redirect.test.sh new file mode 100644 index 00000000..5023c2dc --- /dev/null +++ b/crates/bashkit/tests/spec_cases/bash/append_redirect.test.sh @@ -0,0 +1,74 @@ +# Append redirect tests +# Tests that >> does not duplicate content in compound commands (issue #1119) + +### append_simple +# Simple append works +echo "line1" > /tmp/append.txt +echo "line2" >> /tmp/append.txt +cat /tmp/append.txt +### expect +line1 +line2 +### end + +### append_brace_group +# Brace group append writes once +rm -f /tmp/brace.txt +{ echo "line1"; echo "line2"; } >> /tmp/brace.txt +cat /tmp/brace.txt +### expect +line1 +line2 +### end + +### append_brace_group_existing_file +# Brace group append to existing file +echo "existing" > /tmp/exist.txt +{ echo "new1"; echo "new2"; } >> /tmp/exist.txt +cat /tmp/exist.txt +### expect +existing +new1 +new2 +### end + +### append_no_duplicate +# Repeated appends should not duplicate +rm -f /tmp/nodup.txt +echo "first" >> /tmp/nodup.txt +echo "second" >> /tmp/nodup.txt +cat /tmp/nodup.txt +### expect +first +second +### end + +### append_if_else +# if/else with append redirect +rm -f /tmp/ifelse.txt +if false; then + echo "yes" +else + echo "no" +fi >> /tmp/ifelse.txt +cat /tmp/ifelse.txt +### expect +no +### end + +### append_rebuild_cycle +# Simulate bashblog rebuild: create file, then append-only should not duplicate +rm -f /tmp/footer.html +{ + echo "
footer line 1
" + echo "
footer line 2
" +} >> /tmp/footer.html +# Rebuild: run the same block again — should append, not duplicate first block +{ + echo "
footer line 1
" + echo "
footer line 2
" +} >> /tmp/footer.html +wc -l < /tmp/footer.html +### expect +4 +### end