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

Re: [PATCH v2 3/6] t1300: don't create unused files

From
Andrei Rybak <rybak.a.v@gmail.com>
Date
Apr 6, 2023, 21:30 UTC
Message-ID
<c43e6b71-075a-e39a-7351-8595e145dacf@gmail.com>
In-Reply-To
<230406.86pm8htnfk.gmgdl@evledraar.gmail.com>
On 06/04/2023 10:38, Ævar Arnfjörð Bjarmason wrote:
Show 68 quoted lines
> 
> On Tue, Apr 04 2023, Andrei Rybak wrote:
> 
>> Three tests in t1300-config.sh check that "git config --get" barfs when
>> syntax errors are present in the config file.  The tests redirect
>> standard output and standard error of "git config --get" to files,
>> "actual" and "error" correspondingly.  They assert presence of an error
>> message in file "error".  However, these tests don't use file "actual"
>> for assertions.
>>
>> Don't redirect standard output of "git config --get" to file "actual" in
>> t1300-config.sh to avoid creating unnecessary files.
>>
>> Signed-off-by: Andrei Rybak <rybak.a.v@gmail.com>
>> ---
>>   t/t1300-config.sh | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/t/t1300-config.sh b/t/t1300-config.sh
>> index d566729d74..8ac4531c1b 100755
>> --- a/t/t1300-config.sh
>> +++ b/t/t1300-config.sh
>> @@ -1575,7 +1575,7 @@ test_expect_success 'barf on syntax error' '
>>   	[section]
>>   	key garbage
>>   	EOF
>> -	test_must_fail git config --get section.key >actual 2>error &&
>> +	test_must_fail git config --get section.key 2>error &&
>>   	test_i18ngrep " line 3 " error
>>   '
>>   
>> @@ -1585,7 +1585,7 @@ test_expect_success 'barf on incomplete section header' '
>>   	[section
>>   	key = value
>>   	EOF
>> -	test_must_fail git config --get section.key >actual 2>error &&
>> +	test_must_fail git config --get section.key 2>error &&
>>   	test_i18ngrep " line 2 " error
>>   '
>>   
>> @@ -1595,7 +1595,7 @@ test_expect_success 'barf on incomplete string' '
>>   	[section]
>>   	key = "value string
>>   	EOF
>> -	test_must_fail git config --get section.key >actual 2>error &&
>> +	test_must_fail git config --get section.key 2>error &&
>>   	test_i18ngrep " line 3 " error
>>   '
> 
> Ditto my comment on 1/6, shouldn't we instead be doing e.g.:
> 	
> 	diff --git a/t/t1300-config.sh b/t/t1300-config.sh
> 	index 2575279ab84..df2070c2f09 100755
> 	--- a/t/t1300-config.sh
> 	+++ b/t/t1300-config.sh
> 	@@ -1575,7 +1575,8 @@ test_expect_success 'barf on syntax error' '
> 	 	[section]
> 	 	key garbage
> 	 	EOF
> 	-	test_must_fail git config --get section.key >actual 2>error &&
> 	+	test_must_fail git config --get section.key >out 2>error &&
> 	+	test_must_be_empty out &&
> 	 	test_i18ngrep " line 3 " error
> 	 '
> 	
> I.e. before this we had no coverage on the error being the only output,
> but seemingly by mistake. Let's just assert that, rather than dropping
> the redirection entirely, no?

Here, failing invocations of "git config" are tested, and an argument, as Junio C Hamano outlined in https://lore.kernel.org/git/xmqqsfe8s56p.fsf@gitster.g/ for output of failing "git mktree", could be applied here.

Thinking about it more, such assertions enforcing empty standard output for these commands might be helpful if some tools and/or scripts rely on empty standard output instead of checking the exit code. Hyrum's Law applies here, I guess.

Previous: Ævar Arnfjörð BjarmasonNext: Andrei Rybak
Message 28 of 58 in “t: fix unused files, part 2”
  1. 0/6 t: fix unused files, part 2Andrei Rybak, Apr 1, 2023
  2. 1/6 t0300: don't create unused fileAndrei Rybak, Apr 1, 2023
  3. Eric SunshineApr 2, 2023
  4. 5/6 t1502: don't create unused filesAndrei Rybak, Apr 1, 2023
  5. 2/6 t1300: fix config file syntax error descriptionsAndrei Rybak, Apr 1, 2023
  6. 3/6 t1300: don't create unused filesAndrei Rybak, Apr 1, 2023
  7. 4/6 t1450: don't create unused filesAndrei Rybak, Apr 1, 2023
  8. 6/6 t2019: don't create unused filesAndrei Rybak, Apr 1, 2023
  9. 0/6 t: fix unused files, part 2Andrei Rybak, Apr 3, 2023
  10. 1/6 t0300: don't create unused fileAndrei Rybak, Apr 3, 2023
  11. Ævar Arnfjörð BjarmasonApr 6, 2023
  12. Andrei RybakApr 6, 2023
  13. 2/6 t1300: fix config file syntax error descriptionsAndrei Rybak, Apr 3, 2023
  14. 4/6 t1450: don't create unused filesAndrei Rybak, Apr 3, 2023
  15. Ævar Arnfjörð BjarmasonApr 6, 2023
  16. Andrei RybakApr 6, 2023
  17. 6/6 t2019: don't create unused filesAndrei Rybak, Apr 3, 2023
  18. Ævar Arnfjörð BjarmasonApr 6, 2023
  19. Andrei RybakApr 7, 2023
  20. t2024: fix loose/strict local base branch DWIM testAndrei Rybak, Apr 8, 2023
  21. Junio C HamanoApr 10, 2023
  22. 5/6 t1502: don't create unused filesAndrei Rybak, Apr 3, 2023
  23. Øystein WalleApr 6, 2023
  24. Ævar Arnfjörð BjarmasonApr 6, 2023
  25. Andrei RybakApr 6, 2023
  26. 3/6 t1300: don't create unused filesAndrei Rybak, Apr 3, 2023
  27. Ævar Arnfjörð BjarmasonApr 6, 2023
  28. Andrei RybakApr 6, 2023
  29. git config tests for "'git config ignores pairs ..." (was Re: [PATCH v2 3/6] t1300: don't create unused files)Andrei Rybak, Apr 6, 2023
  30. 0/2 git config tests for "'git config ignores pairs ..."Andrei Rybak, Apr 14, 2023
  31. 1/2 t1300: drop duplicate testAndrei Rybak, Apr 14, 2023
  32. 2/2 t1300: check stderr for "ignores pairs" testsAndrei Rybak, Apr 14, 2023
  33. Andrei RybakApr 14, 2023
  34. 0/3 git config tests for "'git config ignores pairs ..."Andrei Rybak, Apr 18, 2023
  35. 1/3 t1300: drop duplicate testAndrei Rybak, Apr 18, 2023
  36. Junio C HamanoApr 18, 2023
  37. 2/3 t1300: check stderr for "ignores pairs" testsAndrei Rybak, Apr 18, 2023
  38. Junio C HamanoApr 18, 2023
  39. 3/3 t1300: add tests for missing keysAndrei Rybak, Apr 18, 2023
  40. Junio C HamanoApr 18, 2023
  41. Andrei RybakApr 18, 2023
  42. 0/3 git config tests for "'git config ignores pairs ..."Andrei Rybak, Apr 23, 2023
  43. 1/3 t1300: drop duplicate testAndrei Rybak, Apr 23, 2023
  44. 2/3 t1300: check stderr for "ignores pairs" testsAndrei Rybak, Apr 23, 2023
  45. 3/3 t1300: add tests for missing keysAndrei Rybak, Apr 23, 2023
  46. Junio C HamanoMay 1, 2023
  47. Andrei RybakMay 2, 2023
  48. 0/6 t: fix unused files, part 2Andrei Rybak, Apr 17, 2023
  49. 1/6 t0300: don't create unused fileAndrei Rybak, Apr 17, 2023
  50. 2/6 t1300: fix config file syntax error descriptionsAndrei Rybak, Apr 17, 2023
  51. 3/6 t1300: don't create unused filesAndrei Rybak, Apr 17, 2023
  52. 4/6 t1450: don't create unused filesAndrei Rybak, Apr 17, 2023
  53. 5/6 t1502: don't create unused filesAndrei Rybak, Apr 17, 2023
  54. 6/6 t2019: don't create unused filesAndrei Rybak, Apr 17, 2023
  55. Junio C HamanoMay 1, 2023
  56. Andrei RybakMay 2, 2023
  57. Elijah NewrenMay 3, 2023
  58. Junio C HamanoMay 3, 2023

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.