From 25c058a2a26e0437fbc52fc697409b8437ff5f08 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Mon, 15 Dec 2014 08:38:43 -0500 Subject: [PATCH] explicitly exit from TEST_exit This prevents some odd interactions with the EXIT trap, and our last command's status is seemingly not preserved for the script's real exit. Add a BASH override to the Makefile as well, as it might be useful for debugging or testing against other versions of bash. --- Makefile | 4 +++- test/common | 2 ++ test/test_option_twiddling | 2 -- test/test_valid_number_of_base | 3 --- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index f7edf2c..aae1515 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,8 @@ BINPROGS = \ genfstab \ pacstrap +BASH = bash + all: $(BINPROGS) V_GEN = $(_v_GEN_$(V)) @@ -23,7 +25,7 @@ clean: check: all @for f in $(BINPROGS); do bash -O extglob -n $$f; done - @r=0; for t in test/test_*; do $$t || r=1; done; exit $$r + @r=0; for t in test/test_*; do $(BASH) $$t || { echo $$t fail; r=1; }; done; exit $$r install: all install -dm755 $(DESTDIR)$(PREFIX)/bin diff --git a/test/common b/test/common index cf9308d..8773077 100644 --- a/test/common +++ b/test/common @@ -27,6 +27,8 @@ TEST_exit() { (( fail == 0 )) && result=PASS || result=FAIL printf '%s: %s\n' "$result" "$1" + + exit $(( fail != 0 )) } ASSERT_streq() { diff --git a/test/test_option_twiddling b/test/test_option_twiddling index 7aabc8d..214a63c 100755 --- a/test/test_option_twiddling +++ b/test/test_option_twiddling @@ -53,5 +53,3 @@ EXPECT_success optstring_match_option key key=val EXPECT_success optstring_match_option key=val key=val EXPECT_failure optstring_match_option key=val key=val2 EXPECT_failure optstring_match_option 'key=*' key=val2 - -(( fail == 0 )) diff --git a/test/test_valid_number_of_base b/test/test_valid_number_of_base index 15a91e9..97e6e9b 100755 --- a/test/test_valid_number_of_base +++ b/test/test_valid_number_of_base @@ -3,7 +3,6 @@ . "${1:-./common}" . ./test/common - EXPECT_success valid_number_of_base 16 feedfacebeef EXPECT_failure valid_number_of_base 16 feedsfacebeef EXPECT_success valid_number_of_base 16 1234567890 @@ -13,5 +12,3 @@ EXPECT_failure valid_number_of_base 10 1234.567890 EXPECT_failure valid_number_of_base 10 1234567890abcdef EXPECT_success valid_number_of_base 18 1234567890abcdefghi - -(( fail == 0 ))