git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: git@vger.kernel.org, "Eric Wong" <e@80x24.org>,
	"Benno Evers" <benno@bmevers.de>, "Jean Privat" <jean@pryen.org>,
	"René Scharfe" <l.s.r@web.de>
Subject: Re: [PATCH 02/10] describe tests: refactor away from glob matching
Date: Mon, 01 Mar 2021 13:26:37 -0800	[thread overview]
Message-ID: <xmqq1rcypnua.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <20210228195414.21372-3-avarab@gmail.com> (=?utf-8?B?IsOGdmFy?= =?utf-8?B?IEFybmZqw7Zyw7A=?= Bjarmason"'s message of "Sun, 28 Feb 2021 20:54:06 +0100")

Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

> Change the glob matching via a "case" statement to a "test_cmp" after
> we've stripped out the hash-specific g<hash-abbrev>
> suffix. 5312ab11fbf (Add describe test., 2007-01-13).
>
> This means that we can use test_cmp to compare the output. I could
> omit the "-8" change of e.g. "A-*" to "A-8-gHASH", but I think it
> makes sense to test that here explicitly. It means you need to add new
> tests to the bottom of the file, but that's not a burden in this case.

I think the point in these tests are that they consider "which tip
the tested commit is the closest" is the only piece of information
that matter, and allows the numbers ("number of commits on top of")
to be redefined in the future without having to change the tests,
but I tend to agree that such a change should be accompanied by and
documented with changes to these tests. 

> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  t/t6120-describe.sh | 78 ++++++++++++++++++++++-----------------------
>  1 file changed, 38 insertions(+), 40 deletions(-)
>
> diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh
> index 7bc2aaa46e..e4fd5d567f 100755
> --- a/t/t6120-describe.sh
> +++ b/t/t6120-describe.sh
> @@ -21,12 +21,10 @@ check_describe () {
>  	shift
>  	describe_opts="$@"

Just a style thing, when we are not invoking the "each positional
arg is double-quoted individually against being split at $IFS" magic,
we prefer to spell this as "$*".

>  	test_expect_success "describe $describe_opts" '
> +		git describe $describe_opts 2>err.actual >raw &&
> +		sed -e "s/-g[0-9a-f]*\$/-gHASH/" <raw >actual &&

The exact ones would be passed as-is (i.e. "test_cmp raw actual"
could pass), which is what we want anyway.

If we are planning to further extend this helper to make it more
capable, we might want to consider quoting $describe to be evaled
properly so that we can do an equivalent of

	check_describe A-8-gHASH --dirty='.d i r t y' HEAD

when we gain new option that is more intresting than --dirty=<mark>
that legitimately would benefit from being able to pass arguments
with $IFS whitespace in them.

But that is outside the scope of this step.  I haven't seen the
overall topic yet, so it may or may not be within the scope of this
series.  We'll see.

> +		echo $expect >expect &&

Let's double-quote to relieve readers from having to wonder if you
are expecting the callers to feed crazy things like "a  b" and this
echo to normalize it to "a b".

> +		test_cmp expect actual
>  	'
>  }

  reply	other threads:[~2021-03-01 21:30 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-23 12:51 [PATCH] describe: dont abort too early when searching tags Benno Evers
2020-02-24 20:52 ` Junio C Hamano
2020-02-25 19:07   ` benno
2020-02-25 20:10     ` Junio C Hamano
2021-02-28 19:54 ` [PATCH 00/10] describe tests: refactor & fix recent broken tests Ævar Arnfjörð Bjarmason
2021-03-09  0:47   ` Junio C Hamano
2021-03-12 23:59   ` Junio C Hamano
2021-04-12 11:21   ` [PATCH v2 0/5] describe test fixes Ævar Arnfjörð Bjarmason
2021-04-12 11:21     ` [PATCH v2 1/5] describe tests: improve test for --work-tree & --dirty Ævar Arnfjörð Bjarmason
2021-04-12 11:21     ` [PATCH v2 2/5] describe tests: refactor away from glob matching Ævar Arnfjörð Bjarmason
2021-04-12 11:21     ` [PATCH v2 3/5] describe tests: don't rely on err.actual from "check_describe" Ævar Arnfjörð Bjarmason
2021-04-12 11:21     ` [PATCH v2 4/5] describe tests: fix nested "test_expect_success" call Ævar Arnfjörð Bjarmason
2021-04-12 11:21     ` [PATCH v2 5/5] describe tests: support -C in "check_describe" Ævar Arnfjörð Bjarmason
2021-04-12 11:33   ` [PATCH v2 0/2] svn tests: trivial "set -e" in main body of test fixes Ævar Arnfjörð Bjarmason
2021-04-12 11:33     ` [PATCH v2 1/2] svn tests: remove legacy re-setup from init-clone test Ævar Arnfjörð Bjarmason
2021-04-12 11:33     ` [PATCH v2 2/2] svn tests: refactor away a "set -e" in test body Ævar Arnfjörð Bjarmason
2021-02-28 19:54 ` [PATCH 01/10] describe tests: improve test for --work-tree & --dirty Ævar Arnfjörð Bjarmason
2021-02-28 19:54 ` [PATCH 02/10] describe tests: refactor away from glob matching Ævar Arnfjörð Bjarmason
2021-03-01 21:26   ` Junio C Hamano [this message]
2021-02-28 19:54 ` [PATCH 03/10] describe tests: always assert empty stderr from "describe" Ævar Arnfjörð Bjarmason
2021-03-01 21:32   ` Junio C Hamano
2021-02-28 19:54 ` [PATCH 04/10] test-lib functions: add an --annotated-tag option to "test_commit" Ævar Arnfjörð Bjarmason
2021-03-01 21:41   ` Junio C Hamano
2021-03-02  9:34     ` Ævar Arnfjörð Bjarmason
2021-03-03  6:35       ` Junio C Hamano
2021-02-28 19:54 ` [PATCH 05/10] describe tests: convert setup to use test_commit Ævar Arnfjörð Bjarmason
2021-03-01 21:42   ` Junio C Hamano
2021-02-28 19:54 ` [PATCH 06/10] describe tests: fix nested "test_expect_success" call Ævar Arnfjörð Bjarmason
2021-02-28 19:54 ` [PATCH 07/10] describe tests: support -C in "check_describe" Ævar Arnfjörð Bjarmason
2021-02-28 19:54 ` [PATCH 08/10] svn tests: remove legacy re-setup from init-clone test Ævar Arnfjörð Bjarmason
2021-02-28 19:54 ` [PATCH 09/10] svn tests: refactor away a "set -e" in test body Ævar Arnfjörð Bjarmason
2021-02-28 21:14   ` Eric Wong
2021-02-28 19:54 ` [PATCH 10/10] test-lib: return 1 from test_expect_{success,failure} Ævar Arnfjörð Bjarmason
2021-03-01 21:43   ` 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=xmqq1rcypnua.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=benno@bmevers.de \
    --cc=e@80x24.org \
    --cc=git@vger.kernel.org \
    --cc=jean@pryen.org \
    --cc=l.s.r@web.de \
    /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).