git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3] t3200: fix antipatterns in existing branch tests

From
Junio C Hamano <gitster@pobox.com>
Date
May 4, 2022, 17:27 UTC
Message-ID
<xmqqh765mcn0.fsf@gitster.g>
In-Reply-To
<pull.1182.v3.git.1651344174050.gitgitgadget@gmail.com>
"Tao Klerks via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 5 quoted lines
> +test_set_remote () {
> +	test_config "remote.$1.url" "$2" &&
> +	test_config "remote.$1.fetch" "${3:-"refs/heads/*:refs/remotes/$1/*"}"
> +}
> +
Show 11 quoted lines
> @@ -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.

Show 8 quoted lines
> @@ -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.
Show 8 quoted lines
> @@ -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.
Show 18 quoted lines
> @@ -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?
Show 17 quoted lines
>  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.
Previous: Tao Klerks via GitGitGadgetNext: Tao Klerks
Message 6 of 7 in “t3200: fix antipatterns in existing branch tests”
  1. t3200: fix antipatterns in existing branch testsTao Klerks via GitGitGadget, Mar 21, 2022
  2. Ævar Arnfjörð BjarmasonMar 21, 2022
  3. Tao KlerksMar 22, 2022
  4. t3200: fix antipatterns in existing branch testsTao Klerks via GitGitGadget, Mar 23, 2022
  5. t3200: fix antipatterns in existing branch testsTao Klerks via GitGitGadget, Apr 30, 2022
  6. Junio C HamanoMay 4, 2022
  7. Tao KlerksMay 12, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.