[PATCH 4/7] t0004 (unwritable files): simplify error handling

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

 



Instead of

	... normal test script ...
	status=$?
	... cleanup ...
	(exit $status)

set up cleanup commands with test_when_finished.  This makes the
test script a little shorter, and more importantly, it ensures errors
during cleanup are reported.

Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx>
---
 t/t0004-unwritable.sh |   52 +++++++++++++-----------------------------------
 1 files changed, 14 insertions(+), 38 deletions(-)

diff --git a/t/t0004-unwritable.sh b/t/t0004-unwritable.sh
index 2342ac5..3e6a334 100755
--- a/t/t0004-unwritable.sh
+++ b/t/t0004-unwritable.sh
@@ -16,53 +16,29 @@ test_expect_success setup '
 '
 
 test_expect_success POSIXPERM 'write-tree should notice unwritable repository' '
-
-	(
-		chmod a-w .git/objects .git/objects/?? &&
-		test_must_fail git write-tree
-	)
-	status=$?
-	chmod 775 .git/objects .git/objects/??
-	(exit $status)
-
+	test_when_finished "chmod 775 .git/objects .git/objects/??" &&
+	chmod a-w .git/objects .git/objects/?? &&
+	test_must_fail git write-tree
 '
 
 test_expect_success POSIXPERM 'commit should notice unwritable repository' '
-
-	(
-		chmod a-w .git/objects .git/objects/?? &&
-		test_must_fail git commit -m second
-	)
-	status=$?
-	chmod 775 .git/objects .git/objects/??
-	(exit $status)
-
+	test_when_finished "chmod 775 .git/objects .git/objects/??" &&
+	chmod a-w .git/objects .git/objects/?? &&
+	test_must_fail git commit -m second
 '
 
 test_expect_success POSIXPERM 'update-index should notice unwritable repository' '
-
-	(
-		echo 6O >file &&
-		chmod a-w .git/objects .git/objects/?? &&
-		test_must_fail git update-index file
-	)
-	status=$?
-	chmod 775 .git/objects .git/objects/??
-	(exit $status)
-
+	test_when_finished "chmod 775 .git/objects .git/objects/??" &&
+	echo 6O >file &&
+	chmod a-w .git/objects .git/objects/?? &&
+	test_must_fail git update-index file
 '
 
 test_expect_success POSIXPERM 'add should notice unwritable repository' '
-
-	(
-		echo b >file &&
-		chmod a-w .git/objects .git/objects/?? &&
-		test_must_fail git add file
-	)
-	status=$?
-	chmod 775 .git/objects .git/objects/??
-	(exit $status)
-
+	test_when_finished "chmod 775 .git/objects .git/objects/??" &&
+	echo b >file &&
+	chmod a-w .git/objects .git/objects/?? &&
+	test_must_fail git add file
 '
 
 test_done
-- 
1.7.2.3

--
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]