git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Taylor Blau <me@ttaylorr.com>
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	git@vger.kernel.org, "Jeff King" <peff@peff.net>
Subject: Re: [PATCH v3 3/5] tests: replace [de]packetize() shell+perl test-tool pkt-line
Date: Wed, 14 Jul 2021 09:22:57 -0700	[thread overview]
Message-ID: <xmqqpmvkyie6.fsf@gitster.g> (raw)
In-Reply-To: <YO5iOqWx46UxdhKX@nand.local> (Taylor Blau's message of "Wed, 14 Jul 2021 00:04:10 -0400")

Taylor Blau <me@ttaylorr.com> writes:

> On Wed, Jul 14, 2021 at 02:54:03AM +0200, Ævar Arnfjörð Bjarmason wrote:
>> -extract_haves () {
>> -	depacketize | perl -lne '/^(\S+) \.have/ and print $1'
>> -}
>> -
>>  test_expect_success 'with core.alternateRefsCommand' '
>>  	write_script fork/alternate-refs <<-\EOF &&
>>  		git --git-dir="$1" for-each-ref \
>> @@ -27,18 +23,40 @@ test_expect_success 'with core.alternateRefsCommand' '
>>  			refs/heads/public/
>>  	EOF
>>  	test_config -C fork core.alternateRefsCommand ./alternate-refs &&
>> -	git rev-parse public/branch >expect &&
>> -	printf "0000" | git receive-pack fork >actual &&
>> -	extract_haves <actual >actual.haves &&
>> -	test_cmp expect actual.haves
>> +
>> +	test-tool pkt-line pack >in <<-\EOF &&
>> +	0000
>> +	EOF
>> +
>> +	cat >expect <<-EOF &&
>> +	$(git rev-parse main) refs/heads/main
>> +	$(git rev-parse base) refs/tags/base
>> +	$(git rev-parse public) .have
>> +	0000
>> +	EOF
>> +
>> +	git receive-pack fork >out <in &&
>> +	test-tool pkt-line unpack <out >actual &&
>
> I don't think extracting the haves themselves (and stripping ".have"
> from the output) adds much verbosity at all. Wouldn't it be:
>
>   test-tool pkt-line unpack <out >actual &&
>   perl -lne '/^(\S+) \.have/ and print $1' <actual >actual.haves
>
> (in fact, it might be quite nice to leave extract_haves as-is changing
> depacketize for 'test-tool pkt-line unpack').

I tend to agree with you ane Peff, after reading the resulting tests
myself.

Specifically I have problem with this line of reasoning:

    The conversion away from extract_haves() in ... isn't strictly
    required for this migration, but in this case it's easy enough
    to test_cmp the whole output, so let's just do that.

as if using test_cmp to compare the whole output is always a better
way to test, which is far from cut-and-dried clear and obvious.  The
default ought to be to keep the original behaviour, unless you can
clearly convince others that either (1) the new way is better, or
(2) keeping the old way is too hard and the cost for doing so
outweighs the benefit.

While there certainly is some value in end-to-end tests, they
inevitably become brittle.  We prefer focused tests that verify
things we _care_ about, while keeping the expected vector unaffected
by future changes in details that do not matter in what is being
tested.  If we are interested in ".have"s, we shouldn't be affected
by irrelevant details like what other branches and tags appear in
the output and in what order, for example.

Of course, if there is a solid reason why we would care not just
".have" but other details, it is perfectly justifiable thing to do
to update the tests, but we'd want to see (1) such an unrelated
change done in a separate step and (2) with its own justification.

So...

  reply	other threads:[~2021-07-14 16:23 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-07 10:21 [PATCH 0/5] tests: migrate to "test-tool pkt-line" Ævar Arnfjörð Bjarmason
2021-07-07 10:21 ` [PATCH 1/5] serve tests: add missing "extra delim" test Ævar Arnfjörð Bjarmason
2021-07-07 10:21 ` [PATCH 2/5] serve tests: use test_cmp in "protocol violations" test Ævar Arnfjörð Bjarmason
2021-07-07 10:21 ` [PATCH 3/5] tests: replace [de]packetize() shell+perl test-tool pkt-line Ævar Arnfjörð Bjarmason
2021-07-07 10:21 ` [PATCH 4/5] tests: replace remaining packetize() with "test-tool pkt-line" Ævar Arnfjörð Bjarmason
2021-07-07 10:21 ` [PATCH 5/5] test-lib-functions.sh: remove unused [de]packetize() functions Ævar Arnfjörð Bjarmason
2021-07-12 16:44 ` [PATCH v2 0/5] tests: migrate to "test-tool pkt-line" Ævar Arnfjörð Bjarmason
2021-07-12 16:44   ` [PATCH v2 1/5] serve tests: add missing "extra delim" test Ævar Arnfjörð Bjarmason
2021-07-12 16:44   ` [PATCH v2 2/5] serve tests: use test_cmp in "protocol violations" test Ævar Arnfjörð Bjarmason
2021-07-12 16:44   ` [PATCH v2 3/5] tests: replace [de]packetize() shell+perl test-tool pkt-line Ævar Arnfjörð Bjarmason
2021-07-13 20:50     ` Jeff King
2021-07-13 23:41       ` Ævar Arnfjörð Bjarmason
2021-07-14  1:12         ` Jeff King
2021-07-12 16:44   ` [PATCH v2 4/5] tests: replace remaining packetize() with "test-tool pkt-line" Ævar Arnfjörð Bjarmason
2021-07-13 20:58     ` Jeff King
2021-07-13 23:52       ` Ævar Arnfjörð Bjarmason
2021-07-14  1:16         ` Jeff King
2021-07-12 16:44   ` [PATCH v2 5/5] test-lib-functions.sh: remove unused [de]packetize() functions Ævar Arnfjörð Bjarmason
2021-07-12 20:41   ` [PATCH v2 0/5] tests: migrate to "test-tool pkt-line" Junio C Hamano
2021-07-13 21:00     ` Jeff King
2021-07-14  0:54   ` [PATCH v3 " Ævar Arnfjörð Bjarmason
2021-07-14  0:54     ` [PATCH v3 1/5] serve tests: add missing "extra delim" test Ævar Arnfjörð Bjarmason
2021-07-14  0:54     ` [PATCH v3 2/5] serve tests: use test_cmp in "protocol violations" test Ævar Arnfjörð Bjarmason
2021-07-14  0:54     ` [PATCH v3 3/5] tests: replace [de]packetize() shell+perl test-tool pkt-line Ævar Arnfjörð Bjarmason
2021-07-14  4:04       ` Taylor Blau
2021-07-14 16:22         ` Junio C Hamano [this message]
2021-07-14  0:54     ` [PATCH v3 4/5] tests: replace remaining packetize() with "test-tool pkt-line" Ævar Arnfjörð Bjarmason
2021-07-14  0:54     ` [PATCH v3 5/5] test-lib-functions.sh: remove unused [de]packetize() functions Ævar Arnfjörð Bjarmason
2021-07-16 15:41     ` [PATCH v4] test-lib-functions: use test-tool for [de]packetize() Ævar Arnfjörð Bjarmason
2021-07-16 16:53       ` Taylor Blau
2021-07-16 19:08         ` Jeff King
2021-07-16 19:03       ` Jeff King
2021-07-19 18:54       ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqpmvkyie6.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=me@ttaylorr.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).