diff mbox series

[1/2] object-name tests: tighten up advise() output test

Message ID patch-1.2-7085f951a12-20211004T013611Z-avarab@gmail.com (mailing list archive)
State Superseded
Headers show
Series i18n: improve translatability of ambiguous object output | expand

Commit Message

Ævar Arnfjörð Bjarmason Oct. 4, 2021, 1:42 a.m. UTC
Change tests added in 1ffa26c4614 (get_short_sha1: list ambiguous
objects on error, 2016-09-26) to only care about the OIDs that are
listed, which is what the test is trying to check for.

This isn't needed by the subsequent commit, which won't change any of
the output, but a mere tightening of the tests assertions to more
closely match what we really want to test for here.

Now if the advise() message itself were change the phrasing around the
list of OIDs we won't have this test break. We're assuming that such
output won't have a need to indent anything except the OIDs.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t1512-rev-parse-disambiguation.sh | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Eric Sunshine Oct. 4, 2021, 2:52 a.m. UTC | #1
On Sun, Oct 3, 2021 at 9:43 PM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
> Change tests added in 1ffa26c4614 (get_short_sha1: list ambiguous
> objects on error, 2016-09-26) to only care about the OIDs that are
> listed, which is what the test is trying to check for.
>
> This isn't needed by the subsequent commit, which won't change any of
> the output, but a mere tightening of the tests assertions to more
> closely match what we really want to test for here.
>
> Now if the advise() message itself were change the phrasing around the

s/were change/were to change/

> list of OIDs we won't have this test break. We're assuming that such
> output won't have a need to indent anything except the OIDs.
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Jeff King Oct. 4, 2021, 7:05 a.m. UTC | #2
On Mon, Oct 04, 2021 at 03:42:48AM +0200, Ævar Arnfjörð Bjarmason wrote:

> Change tests added in 1ffa26c4614 (get_short_sha1: list ambiguous
> objects on error, 2016-09-26) to only care about the OIDs that are
> listed, which is what the test is trying to check for.
> 
> This isn't needed by the subsequent commit, which won't change any of
> the output, but a mere tightening of the tests assertions to more
> closely match what we really want to test for here.

I think the next commit does change the output. It adds an extra empty
line which would cause these tests to fail.

> Now if the advise() message itself were change the phrasing around the
> list of OIDs we won't have this test break. We're assuming that such
> output won't have a need to indent anything except the OIDs.

It feels like we're trading one assumption for another. :)

I admit that don't care much either way, though.

-Peff
diff mbox series

Patch

diff --git a/t/t1512-rev-parse-disambiguation.sh b/t/t1512-rev-parse-disambiguation.sh
index 7891a6becf3..d3a2d9188c7 100755
--- a/t/t1512-rev-parse-disambiguation.sh
+++ b/t/t1512-rev-parse-disambiguation.sh
@@ -334,16 +334,16 @@  test_expect_success 'ambiguity errors are not repeated (peel)' '
 
 test_expect_success 'ambiguity hints' '
 	test_must_fail git rev-parse 000000000 2>stderr &&
-	grep ^hint: stderr >hints &&
-	# 16 candidates, plus one intro line
-	test_line_count = 17 hints
+	grep "^hint:   " stderr >hints &&
+	# 16 candidates, minus surrounding prose
+	test_line_count = 16 hints
 '
 
 test_expect_success 'ambiguity hints respect type' '
 	test_must_fail git rev-parse 000000000^{commit} 2>stderr &&
-	grep ^hint: stderr >hints &&
-	# 5 commits, 1 tag (which is a committish), plus intro line
-	test_line_count = 7 hints
+	grep "^hint:   " stderr >hints &&
+	# 5 commits, 1 tag (which is a committish), minus surrounding prose
+	test_line_count = 6 hints
 '
 
 test_expect_success 'failed type-selector still shows hint' '
@@ -352,8 +352,8 @@  test_expect_success 'failed type-selector still shows hint' '
 	echo 851 | git hash-object --stdin -w &&
 	echo 872 | git hash-object --stdin -w &&
 	test_must_fail git rev-parse ee3d^{commit} 2>stderr &&
-	grep ^hint: stderr >hints &&
-	test_line_count = 3 hints
+	grep "^hint:   " stderr >hints &&
+	test_line_count = 2 hints
 '
 
 test_expect_success 'core.disambiguate config can prefer types' '