git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] test: use test_must_be_empty F instead of test_cmp empty F

From
René Scharfe <l.s.r@web.de>
Date
Nov 26, 2019, 19:46 UTC
Message-ID
<52479277-b753-c3c0-7f6c-5d013016964e@web.de>

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.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 t/t1011-read-tree-sparse-checkout.sh | 3 +--
 t/t9010-svn-fe.sh                    | 6 ++----
 2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/t/t1011-read-tree-sparse-checkout.sh b/t/t1011-read-tree-sparse-checkout.sh
index ba71b159ba..eb44bafb59 100755
--- a/t/t1011-read-tree-sparse-checkout.sh
+++ b/t/t1011-read-tree-sparse-checkout.sh
@@ -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' '
-	>empty &&
 	echo init.t >.git/info/sparse-checkout &&
 	echo sub/added >>.git/info/sparse-checkout &&
 	git checkout -f top &&
@@ -223,7 +222,7 @@ test_expect_success 'index removal and worktree narrowing at the same time' '
 	git checkout removed &&
 	git ls-files sub/added >result &&
 	test ! -f sub/added &&
-	test_cmp empty result
+	test_must_be_empty result
 '

 test_expect_success 'read-tree --reset removes outside worktree' '
diff --git a/t/t9010-svn-fe.sh b/t/t9010-svn-fe.sh
index 0b20b07e68..3a3d8d3bd5 100755
--- a/t/t9010-svn-fe.sh
+++ b/t/t9010-svn-fe.sh
@@ -53,9 +53,7 @@ text_no_props () {
 	printf "%s\n" "$text"
 }

->empty
-
-test_expect_success 'empty dump' '
+test_expect_success PIPE 'empty dump' '
 	reinit_git &&
 	echo "SVN-fs-dump-format-version: 2" >input &&
 	try_dump input
@@ -208,7 +206,7 @@ test_expect_failure 'timestamp and empty file' '
 	test_cmp expect.date actual.date &&
 	test_cmp expect.files actual.files &&
 	git checkout HEAD empty-file &&
-	test_cmp empty file
+	test_must_be_empty file
 '

 test_expect_success 'directory with files' '
--
2.24.0
Next: Denton Liu
Message 1 of 4 in “test: use test_must_be_empty F instead of test_cmp empty F”
  1. test: use test_must_be_empty F instead of test_cmp empty FRené Scharfe, Nov 26, 2019
  2. Denton LiuNov 26, 2019
  3. René ScharfeNov 27, 2019
  4. test: use test_must_be_empty F instead of test_cmp empty FRené Scharfe, Nov 27, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.