test: use test_must_be_empty F instead of test_cmp empty F

Use test_must_be_empty instead of comparing it to an empty file.  That's
more efficient, as the function only needs built-in meta-data only check
in the usual case, and provides nicer debug output otherwise.

Helped-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
René Scharfe 2019-11-27 08:51:43 +01:00 коммит произвёл Junio C Hamano
Родитель 213dabf49d
Коммит ed254710ee
2 изменённых файлов: 2 добавлений и 5 удалений

Просмотреть файл

@ -215,7 +215,6 @@ test_expect_success 'read-tree adds to worktree, dirty case' '
' '
test_expect_success 'index removal and worktree narrowing at the same time' ' test_expect_success 'index removal and worktree narrowing at the same time' '
>empty &&
echo init.t >.git/info/sparse-checkout && echo init.t >.git/info/sparse-checkout &&
echo sub/added >>.git/info/sparse-checkout && echo sub/added >>.git/info/sparse-checkout &&
git checkout -f top && git checkout -f top &&
@ -223,7 +222,7 @@ test_expect_success 'index removal and worktree narrowing at the same time' '
git checkout removed && git checkout removed &&
git ls-files sub/added >result && git ls-files sub/added >result &&
test ! -f sub/added && test ! -f sub/added &&
test_cmp empty result test_must_be_empty result
' '
test_expect_success 'read-tree --reset removes outside worktree' ' test_expect_success 'read-tree --reset removes outside worktree' '

Просмотреть файл

@ -53,8 +53,6 @@ text_no_props () {
printf "%s\n" "$text" printf "%s\n" "$text"
} }
>empty
test_expect_success 'empty dump' ' test_expect_success 'empty dump' '
reinit_git && reinit_git &&
echo "SVN-fs-dump-format-version: 2" >input && echo "SVN-fs-dump-format-version: 2" >input &&
@ -208,7 +206,7 @@ test_expect_failure 'timestamp and empty file' '
test_cmp expect.date actual.date && test_cmp expect.date actual.date &&
test_cmp expect.files actual.files && test_cmp expect.files actual.files &&
git checkout HEAD empty-file && git checkout HEAD empty-file &&
test_cmp empty file test_must_be_empty file
' '
test_expect_success 'directory with files' ' test_expect_success 'directory with files' '