git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrei Rybak <rybak.a.v@gmail.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org, "Øystein Walle" <oystwa@gmail.com>,
	"Junio C Hamano" <gitster@pobox.com>
Subject: Re: [PATCH v2 1/6] t0300: don't create unused file
Date: Thu, 6 Apr 2023 23:01:07 +0200	[thread overview]
Message-ID: <db2de983-9b1f-5efb-0fdc-cc704e6b875b@gmail.com> (raw)
In-Reply-To: <230406.86ttxttnir.gmgdl@evledraar.gmail.com>

On 06/04/2023 10:34, Ævar Arnfjörð Bjarmason wrote:
> 
> On Tue, Apr 04 2023, Andrei Rybak wrote:
> 
>> Test 'credential config with partial URLs' in t0300-credentials.sh
>> contains three "git credential fill" invocations.  For two of the
>> invocations, the test asserts presence or absence of string "yep" in the
>> standard output.  For the third test it checks for an error message in
>> standard error.
>>
>> Don't redirect standard output of "git credential" to file "stdout" in
>> t0300-credentials.sh to avoid creating an unnecessary file when only
>> standard error is checked.
>>
>> Signed-off-by: Andrei Rybak <rybak.a.v@gmail.com>
>> ---
>>   t/t0300-credentials.sh | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/t/t0300-credentials.sh b/t/t0300-credentials.sh
>> index c66d91e82d..b8612ede95 100755
>> --- a/t/t0300-credentials.sh
>> +++ b/t/t0300-credentials.sh
>> @@ -808,7 +808,7 @@ test_expect_success 'credential config with partial URLs' '
>>   
>>   	git -c credential.$partial.helper=yep \
>>   		-c credential.with%0anewline.username=uh-oh \
>> -		credential fill <stdin >stdout 2>stderr &&
>> +		credential fill <stdin 2>stderr &&
>>   	test_i18ngrep "skipping credential lookup for key" stderr
>>   '
> 
> This goes for these changes in this series general: You're correct that
> this is useless now, but I don't think it follows that we should be
> removing the "redundant" code in all cases, rather than fixing the test
> to actually check these.

I'll reply to these on one-by-one.  See also this review of a patch in part 1
of this series from Junio C Hamano:

   https://lore.kernel.org/git/xmqqsfe8s56p.fsf@gitster.g/

> E.g. this will also make this test pass:
> 	
> 	diff --git a/t/t0300-credentials.sh b/t/t0300-credentials.sh
> 	index c66d91e82d8..62c2a0fd50e 100755
> 	--- a/t/t0300-credentials.sh
> 	+++ b/t/t0300-credentials.sh
> 	@@ -806,9 +806,11 @@ test_expect_success 'credential config with partial URLs' '
> 	 		return 1
> 	 	done &&
> 	
> 	+	cp stdout stdout.last &&
> 	 	git -c credential.$partial.helper=yep \
> 	 		-c credential.with%0anewline.username=uh-oh \
> 	 		credential fill <stdin >stdout 2>stderr &&
> 	+	test_cmp stdout.last stdout &&
> 	 	test_i18ngrep "skipping credential lookup for key" stderr
> 	 '
> 	
> 
> Does that make sense? No idea, I don't know the credential system well.
> 
> But isn't it worth testing that when we ask for this that we're getting
> some known output along with the warning?

Current version from branch "master" with more context lines:

> test_expect_success 'credential config with partial URLs' '
> 	echo "echo password=yep" | write_script git-credential-yep &&
> 	test_write_lines url=https://user@example.com/repo.git >stdin &&

The test is checking that "url=https://user@example.com/repo.git" matches ...

> 	for partial in \
> 		example.com \
> 		user@example.com \
> 		https:// \
> 		https://example.com \
> 		https://example.com/ \
> 		https://user@example.com \
> 		https://user@example.com/ \
> 		https://example.com/repo.git \
> 		https://user@example.com/repo.git \
> 		/repo.git

... these partial URLs ...

> 	do
> 		git -c credential.$partial.helper=yep \
> 			credential fill <stdin >stdout &&
> 		grep yep stdout ||
> 		return 1
> 	done &&
> 
> 	for partial in \
> 		dont.use.this \
> 		http:// \
> 		/repo

... but doesn't match these.

> 	do
> 		git -c credential.$partial.helper=yep \
> 			credential fill <stdin >stdout &&
> 		! grep yep stdout ||

Here "! grep yep stdout" ensures that git-credential-yep isn't launched for the
three kinds of partial URLs.  Otherwise, the actual content of "stdout" is
ignored.  It comes from script "askpass" (see bottom of file "t/lib-credential.sh").

Absence or presence of "yep" is a proxy for whether or not partial URL got
matched or not, and that is what's important for this test.  Adding assertions
for output of "askpass" here would only obscure this fact, I think.

There are other tests in t030[0-3] that do check standard output for what
the helper script "askpass" prints out -- those tests validate that the
"git credentials" fallbacks to asking for credentials in the terminal in
various situations.  This is done via functions helper_test and
helper_test_timeout from "t/lib-credential.sh".

> 		return 1
> 	done &&
> 
> 	git -c credential.$partial.helper=yep \
> 		-c credential.with%0anewline.username=uh-oh \
> 		credential fill <stdin >stdout 2>stderr &&
> 	test_i18ngrep "skipping credential lookup for key" stderr

Here, the important part is that "git credential" reacts to invalid key being
used: "credential.with%0anewline.username=uh-oh", and similarly, I think that
adding assertions about "stdout" might not be a good idea.

>'

Perhaps Johannes Schindelin, author of commit 9a121b0d22 ("credential: handle
`credential.<partial-URL>.<key>` again", 2020-04-24), could chime in.

  reply	other threads:[~2023-04-06 21:01 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-01 21:28 [PATCH v1 0/6] t: fix unused files, part 2 Andrei Rybak
2023-04-01 21:28 ` [PATCH v1 1/6] t0300: don't create unused file Andrei Rybak
2023-04-02  1:30   ` Eric Sunshine
2023-04-01 21:28 ` [PATCH v1 2/6] t1300: fix config file syntax error descriptions Andrei Rybak
2023-04-01 21:28 ` [PATCH v1 3/6] t1300: don't create unused files Andrei Rybak
2023-04-01 21:28 ` [PATCH v1 4/6] t1450: " Andrei Rybak
2023-04-01 21:28 ` [PATCH v1 5/6] t1502: " Andrei Rybak
2023-04-01 21:28 ` [PATCH v1 6/6] t2019: " Andrei Rybak
2023-04-03 22:33 ` [PATCH v2 0/6] t: fix unused files, part 2 Andrei Rybak
2023-04-03 22:33   ` [PATCH v2 1/6] t0300: don't create unused file Andrei Rybak
2023-04-06  8:34     ` Ævar Arnfjörð Bjarmason
2023-04-06 21:01       ` Andrei Rybak [this message]
2023-04-03 22:33   ` [PATCH v2 2/6] t1300: fix config file syntax error descriptions Andrei Rybak
2023-04-03 22:33   ` [PATCH v2 3/6] t1300: don't create unused files Andrei Rybak
2023-04-06  8:38     ` Ævar Arnfjörð Bjarmason
2023-04-06 21:30       ` Andrei Rybak
2023-04-06 21:35         ` git config tests for "'git config ignores pairs ..." (was Re: [PATCH v2 3/6] t1300: don't create unused files) Andrei Rybak
2023-04-14  8:13           ` [PATCH v1 0/2] git config tests for "'git config ignores pairs ..." Andrei Rybak
2023-04-14  8:13             ` [PATCH v1 1/2] t1300: drop duplicate test Andrei Rybak
2023-04-14  8:13             ` [PATCH v1 2/2] t1300: check stderr for "ignores pairs" tests Andrei Rybak
2023-04-14 13:28               ` Andrei Rybak
2023-04-18 17:50             ` [PATCH v2 0/3] git config tests for "'git config ignores pairs ..." Andrei Rybak
2023-04-18 17:50               ` [PATCH v2 1/3] t1300: drop duplicate test Andrei Rybak
2023-04-18 18:37                 ` Junio C Hamano
2023-04-18 17:50               ` [PATCH v2 2/3] t1300: check stderr for "ignores pairs" tests Andrei Rybak
2023-04-18 18:39                 ` Junio C Hamano
2023-04-18 17:50               ` [RFC PATCH v2 3/3] t1300: add tests for missing keys Andrei Rybak
2023-04-18 19:31                 ` Junio C Hamano
2023-04-18 17:53               ` [PATCH v2 0/3] git config tests for "'git config ignores pairs ..." Andrei Rybak
2023-04-23 13:46               ` [PATCH v3 " Andrei Rybak
2023-04-23 13:46                 ` [PATCH v3 1/3] t1300: drop duplicate test Andrei Rybak
2023-04-23 13:46                 ` [PATCH v3 2/3] t1300: check stderr for "ignores pairs" tests Andrei Rybak
2023-04-23 13:46                 ` [PATCH v3 3/3] t1300: add tests for missing keys Andrei Rybak
2023-05-01 22:02                 ` [PATCH v3 0/3] git config tests for "'git config ignores pairs ..." Junio C Hamano
2023-05-02 19:58                   ` Andrei Rybak
2023-04-03 22:33   ` [PATCH v2 4/6] t1450: don't create unused files Andrei Rybak
2023-04-06  8:41     ` Ævar Arnfjörð Bjarmason
2023-04-06 22:19       ` Andrei Rybak
2023-04-03 22:33   ` [PATCH v2 5/6] t1502: " Andrei Rybak
2023-04-06  8:15     ` Øystein Walle
2023-04-06  8:47     ` Ævar Arnfjörð Bjarmason
2023-04-06 19:51       ` Andrei Rybak
2023-04-03 22:33   ` [PATCH v2 6/6] t2019: " Andrei Rybak
2023-04-06  8:44     ` Ævar Arnfjörð Bjarmason
2023-04-07  2:19       ` Andrei Rybak
2023-04-08 20:54       ` [PATCH] t2024: fix loose/strict local base branch DWIM test Andrei Rybak
2023-04-10 17:37         ` Junio C Hamano
2023-04-17 19:10   ` [PATCH v3 0/6] t: fix unused files, part 2 Andrei Rybak
2023-04-17 19:10     ` [PATCH v3 1/6] t0300: don't create unused file Andrei Rybak
2023-04-17 19:10     ` [PATCH v3 2/6] t1300: fix config file syntax error descriptions Andrei Rybak
2023-04-17 19:10     ` [PATCH v3 3/6] t1300: don't create unused files Andrei Rybak
2023-04-17 19:10     ` [PATCH v3 4/6] t1450: " Andrei Rybak
2023-04-17 19:10     ` [PATCH v3 5/6] t1502: " Andrei Rybak
2023-04-17 19:10     ` [PATCH v3 6/6] t2019: " Andrei Rybak
2023-05-01 21:52     ` [PATCH v3 0/6] t: fix unused files, part 2 Junio C Hamano
2023-05-02 21:03       ` Andrei Rybak
2023-05-03  4:11       ` Elijah Newren
2023-05-03 15: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=db2de983-9b1f-5efb-0fdc-cc704e6b875b@gmail.com \
    --to=rybak.a.v@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=oystwa@gmail.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.
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).