Skip to content

Commit dbda967

Browse files
jrngitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e14712c commit dbda967

File tree

1 file changed

+14
-38
lines changed

1 file changed

+14
-38
lines changed

t/t0004-unwritable.sh

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,53 +16,29 @@ test_expect_success setup '
1616
'
1717

1818
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
2822
'
2923

3024
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
4028
'
4129

4230
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
5335
'
5436

5537
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
6642
'
6743

6844
test_done

0 commit comments

Comments
 (0)