git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Firmin Martin <firminmartin24@gmail.com>
Cc: git@vger.kernel.org, Eric Sunshine <sunshine@sunshineco.com>
Subject: Re: [PATCH v2 2/2] t: use test_config whenever possible
Date: Sun, 16 May 2021 14:02:09 +0900	[thread overview]
Message-ID: <xmqqbl9b6zla.fsf@gitster.g> (raw)
In-Reply-To: <20210515152721.885728-3-firminmartin24@gmail.com> (Firmin Martin's message of "Sat, 15 May 2021 17:27:21 +0200")

Firmin Martin <firminmartin24@gmail.com> writes:

"whenever possible" in the subject is not wrong per-se but because
we do not want to accept a patch that uses it where it is impossible
to be used anyway, it does not mean all that much.

Use of test_config to replace #1 below is a correctness improvement,
and use of test_config to replace #2 below is a readability thing.

    t: use more test_config for correctness and readability

perhaps?

> Replace patterns of the form
> 1.
>         git config <config-option> <value> &&
>         ...
>         git config --unset <config-option> &&

Adding "because this form fails to unset the config if an earlier
step fails." would be helpful to the readers to clarify that this is
a correctness "fix".

> 2.
>         test_when_finished "git config --unset <config-option>" &&
>         git config <config-option> <value> &&
>         ...
>
> to the concise
>
>         test_config <config-option> <value>

Nice.

> In t5526, two tests have been further simplified as the output file is
> written before "git config --global --unset".

> diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh
> index ed11569d8d..ff18263171 100755
> --- a/t/t5526-fetch-submodules.sh
> +++ b/t/t5526-fetch-submodules.sh
> ...
@@ -429,11 +429,7 @@ test_expect_success "'fetch.recurseSu
>  	(
>  		cd downstream &&
>  		git config fetch.recurseSubmodules on-demand &&
> -		git fetch >../actual.out 2>../actual.err
> -	) &&
> -	git config --global --unset fetch.recurseSubmodules &&
> -	(
> -		cd downstream &&
> +		git fetch >../actual.out 2>../actual.err &&
>  		git config --unset fetch.recurseSubmodules
>  	) &&
>  	test_must_be_empty actual.out &&

The original seems to be making sure that the config set in
"downstream" repository is used successfully before it is unset from
the global configuration and then the same fetch in the downstream
will work even when the configuration is removed from the global
configuration.  The squashing of the two tests into one would change
what is being tested, wouldn't it?

Surely, the actual.out and actual.err in the first invocation *was*
overwritten without being looked at, but the exit status of that
fetch (i.e. fetch before global config gets unset) was still checked
in the original.  So I'd call this a "simplification"

>  	(
>  		cd downstream &&
>  		git config fetch.recurseSubmodules on-demand &&
> -		git fetch >../actual.out 2>../actual.err
> +		git fetch
> 	) &&
> 	git config --global --unset fetch.recurseSubmodules &&

I.e. these redirected output files were not used and the next fetch
will overwrite them.

The patch I am responding to claims that 

 - "make sure it succeeds with global set, and then without global
   set, make sure it still works" is not worth testing.

 - it is OK to replace it with a single "it succeeds without
   unsetting the global config".

It is not clear if either is true.  Same for the other hunk that
squashes two tests into one for this path.

  reply	other threads:[~2021-05-16  5:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-14  6:55 [PATCH 1/2] t/README: document test_config Firmin Martin
2021-05-14  6:55 ` [PATCH 2/2] t: use test_config whenever possible Firmin Martin
2021-05-15 20:15   ` Felipe Contreras
2021-05-15 20:21     ` Felipe Contreras
2021-05-15 22:00       ` Firmin Martin
2021-05-14  7:02 ` [PATCH 1/2] t/README: document test_config Eric Sunshine
2021-05-15 14:43   ` Firmin Martin
2021-05-15 15:27 ` [PATCH v2 0/2] document test_config & use it whenever possible Firmin Martin
2021-05-15 15:27   ` [PATCH v2 1/2] t/README: document test_config Firmin Martin
2021-05-16  5:03     ` Bagas Sanjaya
2021-05-17  7:44       ` Firmin Martin
2021-05-15 15:27   ` [PATCH v2 2/2] t: use test_config whenever possible Firmin Martin
2021-05-16  5:02     ` Junio C Hamano [this message]
2021-05-17  6:08       ` Firmin Martin
2021-05-17  6:55         ` 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

  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=xmqqbl9b6zla.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=firminmartin24@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=sunshine@sunshineco.com \
    /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).