Subject: Re: [PATCH 2/4] Make t1300-repo-config resilient to being run via 'sh -x'

From: Junio C Hamano <[email-masked]>
Date: Tue, 22 Mar 2016 13:34:13 -0700

Jonathan Nieder <[email-masked]> writes:

> Johannes Schindelin wrote:
>
>> --- a/t/t1300-repo-config.sh
>> +++ b/t/t1300-repo-config.sh
>> @@ -699,17 +699,13 @@ test_expect_success 'invalid unit' '
>>  	echo 1auto >expect &&
>>  	git config aninvalid.unit >actual &&
>>  	test_cmp expect actual &&
>> -	cat >expect <<-\EOF &&
>> -	fatal: bad numeric config value '\''1auto'\'' for '\''aninvalid.unit'\'' in file .git/config: invalid unit
>> -	EOF
>>  	test_must_fail git config --int --get aninvalid.unit 2>actual &&
>> -	test_i18ncmp expect actual
>> +	grep "^fatal: bad numeric config value .1auto. for .aninvalid.unit. in file .git/config: invalid unit$" actual
>
> Would test_i18ngrep work?
>
>>  '
>>  
>>  test_expect_success 'invalid stdin config' '
>> -	echo "fatal: bad config line 1 in standard input " >expect &&
>>  	echo "[broken" | test_must_fail git config --list --file - >output 2>&1 &&
>> -	test_cmp expect output
>> +	grep "^fatal: bad config line 1 in standard input $" output
>
> This test is very strange.  Why do we care that it starts with
> "fatal:" as opposed to error?  Why are we testing for an extra space at
> the end of the line?
>
> I would expect something like
>
> 	test_i18ngrep 'line 1 in standard input' output
>
> to be more useful for testing the useful part of the error message while
> remaining resilient against error message changes.

Both sounds sensible.  Should we squash this in, then?

 t/t1300-repo-config.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index 0236fe2..dca27a3 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -700,12 +700,12 @@ test_expect_success 'invalid unit' '
 	git config aninvalid.unit >actual &&
 	test_cmp expect actual &&
 	test_must_fail git config --int --get aninvalid.unit 2>actual &&
-	grep "^fatal: bad numeric config value .1auto. for .aninvalid.unit. in file .git/config: invalid unit$" actual
+	test_i18ngrep "bad numeric config value .1auto. for .aninvalid.unit. in file .git/config: invalid unit" actual
 '
 
 test_expect_success 'invalid stdin config' '
 	echo "[broken" | test_must_fail git config --list --file - >output 2>&1 &&
-	grep "^fatal: bad config line 1 in standard input $" output
+	test_i18ngrep "bad config line 1 in standard input" output
 '
 
 cat > expect << EOF