[PATCH] Expect the exit code of builtin checkout to be in portable range

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This allows crashes to be noticed at least in bash and dash, which put
the signal which terminated the command in its exit status.

Signed-off-by: Alex Riesen <raa.lkml@xxxxxxxxx>
---

Alex Riesen, Thu, Feb 28, 2008 17:30:47 +0100:
> Noticed in t2008, which actually passed, but silently removed
> core-files (I saw segfaults in syslog) and did not properly check the
> exit code.  The change for the t2008 comes as seperate patch, but it
> should be noted that "! command" is *not* how you check for a command
> to have failed. It could have crashed.

So we'd better check the exit status in failure tests.
Like this, for instance

 t/t2008-checkout-subdir.sh |   28 ++++++++++++++++++++--------
 1 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/t/t2008-checkout-subdir.sh b/t/t2008-checkout-subdir.sh
index 4a723dc..1295a09 100755
--- a/t/t2008-checkout-subdir.sh
+++ b/t/t2008-checkout-subdir.sh
@@ -67,16 +67,28 @@ test_expect_success 'checkout with simple prefix' '
 
 '
 
-test_expect_success 'relative path outside tree should fail' \
-	'! git checkout HEAD -- ../../Makefile'
+test_expect_success 'relative path outside tree should fail' '
+	git checkout HEAD -- ../../Makefile
+	test $? -gt 0 -a $? -le 128
+'
 
-test_expect_success 'incorrect relative path to file should fail (1)' \
-	'! git checkout HEAD -- ../file0'
+test_expect_success 'incorrect relative path to file should fail (1)' '
+	git checkout HEAD -- ../file0
+	test $? -gt 0 -a $? -le 128
+'
 
-test_expect_success 'incorrect relative path should fail (2)' \
-	'( cd dir1 && ! git checkout HEAD -- ./file0 )'
+test_expect_success 'incorrect relative path should fail (2)' '
+	( cd dir1 && {
+	    git checkout HEAD -- ./file0
+	    test $? -gt 0 -a $? -le 128
+	} )
+'
 
-test_expect_success 'incorrect relative path should fail (3)' \
-	'( cd dir1 && ! git checkout HEAD -- ../../file0 )'
+test_expect_success 'incorrect relative path should fail (3)' '
+	( cd dir1 && {
+	    git checkout HEAD -- ../../file0
+	    test $? -gt 0 -a $? -le 128
+	} )
+'
 
 test_done
-- 
1.5.4.3.253.g9f1d5

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux