Skip to content

Commit 1a368ba

Browse files
committed
fix: use printf instead of echo for portable \n handling in Makefile
echo's treatment of \n is shell-dependent (bash interprets it by default, zsh and POSIX sh do not without -e). Switch report() and the failure summary to printf in both integration-test and test-skip-lang-start targets.
1 parent 0d1b0c0 commit 1a368ba

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ integration-test: NORMALIZE ?= jq -S -e -f $(TESTDIR)/../normalise-filter.jq
2626
integration-test: DIFF ?= | diff -
2727
integration-test:
2828
errors=""; \
29-
report() { echo "$$1: $$2"; errors="$$errors\n$$1: $$2"; }; \
29+
report() { printf "%s: %s\n" "$$1" "$$2"; errors="$$errors\n$$1: $$2"; }; \
3030
for rust in ${TESTS}; do \
3131
target=$${rust%.rs}.smir.json; \
3232
dir=$$(dirname $${rust}); \
@@ -37,7 +37,7 @@ integration-test:
3737
&& rm $${target} \
3838
|| report "$$rust" "Unexpected json output"; \
3939
done; \
40-
[ -z "$$errors" ] || (echo "===============\nFAILING TESTS:$$errors"; exit 1)
40+
[ -z "$$errors" ] || (printf "===============\nFAILING TESTS:%s\n" "$$errors"; exit 1)
4141

4242

4343
golden:
@@ -48,7 +48,7 @@ test-skip-lang-start: TESTS ?= $(shell find $(TESTDIR) -type f -name "*.rs")
4848
test-skip-lang-start: SMIR ?= cargo run -- --d2 "-Zno-codegen"
4949
test-skip-lang-start:
5050
errors=""; \
51-
report() { echo "FAIL: $$1: $$2"; errors="$$errors\n$$1: $$2"; }; \
51+
report() { printf "FAIL: %s: %s\n" "$$1" "$$2"; errors="$$errors\n$$1: $$2"; }; \
5252
for rust in ${TESTS}; do \
5353
dir=$$(dirname $${rust}); \
5454
name=$$(basename $${rust} .rs); \
@@ -58,7 +58,7 @@ test-skip-lang-start:
5858
|| { report "$$rust" "Conversion failed"; continue; }; \
5959
rm -f $${d2}; \
6060
done; \
61-
[ -z "$$errors" ] || (echo "===============\nFAILING TESTS:$$errors"; exit 1)
61+
[ -z "$$errors" ] || (printf "===============\nFAILING TESTS:%s\n" "$$errors"; exit 1)
6262

6363
format:
6464
cargo fmt

0 commit comments

Comments
 (0)