t0004 (unwritable files): simplify error handling
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@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jonathan Nieder committed
Sep 6, 2010 at 20:50 UTC
dbda967684dfefd0ac3518f9805ccf9ded9af429
1 file changed
+14
-38
t/t0004-unwritable.sh
+14
-38
@@ -16,53 +16,29 @@ test_expect_success setup '
16
'
17
18
test_expect_success POSIXPERM,SANITY 'write-tree should notice unwritable repository' '
19
-
20
- (
21
- chmod a-w .git/objects .git/objects/?? &&
22
- test_must_fail git write-tree
23
- )
24
- status=$?
25
- chmod 775 .git/objects .git/objects/??
26
- (exit $status)
27
-
19
+ test_when_finished "chmod 775 .git/objects .git/objects/??" &&
20
+ chmod a-w .git/objects .git/objects/?? &&
21
+ test_must_fail git write-tree
22
'
23
24
test_expect_success POSIXPERM,SANITY 'commit should notice unwritable repository' '
31
-
32
- (
33
- chmod a-w .git/objects .git/objects/?? &&
34
- test_must_fail git commit -m second
35
- )
36
- status=$?
37
- chmod 775 .git/objects .git/objects/??
38
- (exit $status)
39
-
25
+ test_when_finished "chmod 775 .git/objects .git/objects/??" &&
26
+ chmod a-w .git/objects .git/objects/?? &&
27
+ test_must_fail git commit -m second
28
'
29
30
test_expect_success POSIXPERM,SANITY 'update-index should notice unwritable repository' '
43
-
44
- (
45
- echo 6O >file &&
46
- chmod a-w .git/objects .git/objects/?? &&
47
- test_must_fail git update-index file
48
- )
49
- status=$?
50
- chmod 775 .git/objects .git/objects/??
51
- (exit $status)
52
-
31
+ test_when_finished "chmod 775 .git/objects .git/objects/??" &&
32
+ echo 6O >file &&
33
+ chmod a-w .git/objects .git/objects/?? &&
34
+ test_must_fail git update-index file
35
'
36
37
test_expect_success POSIXPERM,SANITY 'add should notice unwritable repository' '
56
-
57
- (
58
- echo b >file &&
59
- chmod a-w .git/objects .git/objects/?? &&
60
- test_must_fail git add file
61
- )
62
- status=$?
63
- chmod 775 .git/objects .git/objects/??
64
- (exit $status)
65
-
38
+ test_when_finished "chmod 775 .git/objects .git/objects/??" &&
39
+ echo b >file &&
40
+ chmod a-w .git/objects .git/objects/?? &&
41
+ test_must_fail git add file
42
'
43
44
test_done