git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Tao Klerks via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Tao Klerks" <tao@klerks.biz>
Subject: Re: [PATCH v3] t3200: fix antipatterns in existing branch tests
Date: Wed, 04 May 2022 10:27:31 -0700	[thread overview]
Message-ID: <xmqqh765mcn0.fsf@gitster.g> (raw)
In-Reply-To: <pull.1182.v3.git.1651344174050.gitgitgadget@gmail.com> (Tao Klerks via GitGitGadget's message of "Sat, 30 Apr 2022 18:42:53 +0000")

"Tao Klerks via GitGitGadget" <gitgitgadget@gmail.com> writes:

> +test_set_remote () {
> +	test_config "remote.$1.url" "$2" &&
> +	test_config "remote.$1.fetch" "${3:-"refs/heads/*:refs/remotes/$1/*"}"
> +}
> +

> @@ -389,11 +394,9 @@ EOF
>  '
>  
>  test_expect_success 'git branch with column.*' '
> -	git config column.ui column &&
> -	git config column.branch "dense" &&
> +	test_config column.ui column &&
> +	test_config column.branch "dense" &&
>  	COLUMNS=80 git branch >actual &&
> -	git config --unset column.branch &&
> -	git config --unset column.ui &&

OK these are easy to verify, as we can clearly see that the
intention is for these two settings to affect no later tests.

> @@ -406,9 +409,8 @@ test_expect_success 'git branch --column -v should fail' '
>  '
>  
>  test_expect_success 'git branch -v with column.ui ignored' '
> -	git config column.ui column &&
> +	test_config column.ui column &&
>  	COLUMNS=80 git branch -v | cut -c -8 | sed "s/ *$//" >actual &&
> -	git config --unset column.ui &&

Likewise.

> @@ -452,7 +454,7 @@ test_expect_success 'git branch -m s/s s should work when s/t is deleted' '
>  '
>  
>  test_expect_success 'config information was renamed, too' '
> -	test $(git config branch.s.dummy) = Hello &&
> +	test_cmp_config Hello branch.s.dummy &&
>  	test_must_fail git config branch.s/s.dummy
>  '

OK.

> @@ -510,63 +512,57 @@ test_expect_success 'git branch --copy dumps usage' '
>  test_expect_success 'git branch -c d e should work' '
>  	git branch --create-reflog d &&
>  	git reflog exists refs/heads/d &&
> -	git config branch.d.dummy Hello &&
> +	test_config branch.d.dummy Hello &&
>  	git branch -c d e &&
>  	git reflog exists refs/heads/d &&
>  	git reflog exists refs/heads/e &&
> -	echo Hello >expect &&
> -	git config branch.e.dummy >actual &&
> -	test_cmp expect actual &&
> -	echo Hello >expect &&
> -	git config branch.d.dummy >actual &&
> -	test_cmp expect actual
> +	test_cmp_config Hello branch.e.dummy &&
> +	test_cmp_config Hello branch.d.dummy
>  '

This test used to leave both branch.d.dummy and branch.e.dummy behind
for later tests.  Now with this patch, we clean branch.d.dummy
because we use test_config, but branch.e.dummy that was copied by
successful "git branch -c" will still be left.

 - It is unforunate that it is impossible to verify that the change
   in behaviour for branch.d.dummy is correct.  Without checking all
   the remainder of the test (and no, grepping for branch.d.dummy is
   not "checking all the remainder"---a later "branch -c d x" would
   have created brnach.x.dummy in the original, but with this patch,
   it would not), which is time consuming, that is.

   I trust you made sure that branch.d.dummy is never used after
   this test is done---it would have been good to explain it either
   in the proposed log message or after three-dash that you did
   check and how to save reviewer bandwidth.

 - Are you deliberatly leaving branch.e.dummy uncleaned, or is it a
   mere oversight?

>  test_expect_success 'git branch --copy is a synonym for -c' '
>  	git branch --create-reflog copy &&
>  	git reflog exists refs/heads/copy &&
> -	git config branch.copy.dummy Hello &&
> +	test_config branch.copy.dummy Hello &&
>  	git branch --copy copy copy-to &&
>  	git reflog exists refs/heads/copy &&
>  	git reflog exists refs/heads/copy-to &&
> -	echo Hello >expect &&
> -	git config branch.copy.dummy >actual &&
> -	test_cmp expect actual &&
> -	echo Hello >expect &&
> -	git config branch.copy-to.dummy >actual &&
> -	test_cmp expect actual
> +	test_cmp_config Hello branch.copy.dummy &&
> +	test_cmp_config Hello branch.copy-to.dummy
>  '

The same comment for branch.copy.dummy and branch.copy-to.dummy
applies.

I'll stop here for now.  Thanks for starting this clean-up.

  reply	other threads:[~2022-05-04 18:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-21  6:51 [PATCH] t3200: fix antipatterns in existing branch tests Tao Klerks via GitGitGadget
2022-03-21 13:47 ` Ævar Arnfjörð Bjarmason
2022-03-22 19:22   ` Tao Klerks
2022-03-23  0:23 ` [PATCH v2] " Tao Klerks via GitGitGadget
2022-04-30 18:42   ` [PATCH v3] " Tao Klerks via GitGitGadget
2022-05-04 17:27     ` Junio C Hamano [this message]
2022-05-12  5:12       ` Tao Klerks

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=xmqqh765mcn0.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=tao@klerks.biz \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).