提交 dbda9676 编写于 作者: J Jonathan Nieder 提交者: Junio C Hamano

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: NJonathan Nieder <jrnieder@gmail.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 e14712c9
......@@ -16,53 +16,29 @@ test_expect_success setup '
'
test_expect_success POSIXPERM,SANITY '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,SANITY '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,SANITY '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,SANITY '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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册