Thread (7 messages) 7 messages, 3 authors, 2020-06-03

Re: [PATCH 1/2] t5318: use 'test_must_be_empty'

From: Taylor Blau <hidden>
Date: 2020-06-03 22:21:11
Subsystem: the rest · Maintainer: Linus Torvalds

On Tue, Jun 02, 2020 at 08:04:03PM +0200, SZEDER Gábor wrote:
On Mon, Jun 01, 2020 at 12:01:27PM -0600, Taylor Blau wrote:
quoted
A handful of tests in t5318 use 'test_line_count = 0 ...' to make sure
that some command does not write any output. While correct, it is more
helpful to use 'test_must_be_empty' instead, since the latter prints the
contents of the file if it is non-empty.

Since 'test_line_count' only prints the expected and actual line count,
not the contents, using 'test_must_be_empty' may be more helpful for
debugging if there is regression in any of these tests.
These two paragraphs essentially say the same thing, so I think only
one would be sufficient, but...  Both paragraphs are wrong, because
'test_line_count' does include the content of the file on failure:

  expecting success of 9999.1 'test':
          cat >foo <<-EOF &&
          Add
          some
          content
          EOF
          test_line_count = 0 foo

  test_line_count: line count for foo != 0
  Add
  some
  content
  not ok 1 - test

Having said that, I think that the change itself is good, because
'test_must_be_empty foo' is more idiomatic.
Sounds good. Let's use this version of the patch instead, and otherwise
I think this should be ready to go:
--- >8 ---
Subject: [PATCH] t5318: use 'test_must_be_empty'

A handful of tests in t5318 use 'test_line_count = 0 ...' to make sure
that some command does not write any output. While correct, it is more
idiomatic to use 'test_must_be_empty' instead. Switch the former
invocations to use the latter instead.

Signed-off-by: Taylor Blau <redacted>
---
 t/t5318-commit-graph.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh
index a79c624875..d23986f603 100755
--- a/t/t5318-commit-graph.sh
+++ b/t/t5318-commit-graph.sh
@@ -147,7 +147,7 @@ test_expect_success 'Add more commits' '
 test_expect_success 'commit-graph write progress off for redirected stderr' '
 	cd "$TRASH_DIRECTORY/full" &&
 	git commit-graph write 2>err &&
-	test_line_count = 0 err
+	test_must_be_empty err
 '

 test_expect_success 'commit-graph write force progress on for stderr' '
@@ -159,13 +159,13 @@ test_expect_success 'commit-graph write force progress on for stderr' '
 test_expect_success 'commit-graph write with the --no-progress option' '
 	cd "$TRASH_DIRECTORY/full" &&
 	git commit-graph write --no-progress 2>err &&
-	test_line_count = 0 err
+	test_must_be_empty err
 '

 test_expect_success 'commit-graph verify progress off for redirected stderr' '
 	cd "$TRASH_DIRECTORY/full" &&
 	git commit-graph verify 2>err &&
-	test_line_count = 0 err
+	test_must_be_empty err
 '

 test_expect_success 'commit-graph verify force progress on for stderr' '
@@ -177,7 +177,7 @@ test_expect_success 'commit-graph verify force progress on for stderr' '
 test_expect_success 'commit-graph verify with the --no-progress option' '
 	cd "$TRASH_DIRECTORY/full" &&
 	git commit-graph verify --no-progress 2>err &&
-	test_line_count = 0 err
+	test_must_be_empty err
 '

 # Current graph structure:
--
2.27.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help