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

Re: [PATCH v9 2/3] t7507-commit-verbose: make test suite use write_script

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Mar 25, 2016, 14:46 UTC
Message-ID
<20160325154638.Horde.LzlsD6cZcQfmt894cll_0Tl@webmail.informatik.kit.edu>
In-Reply-To
<CAPig+cQJ1yK8WhXE0sxSmDenMt1DMZCoJypTu_wkDsDyuBsAWg@mail.gmail.com>
Quoting Eric Sunshine <sunshine@sunshineco.com>:
> On Thu, Mar 24, 2016 at 7:00 AM, SZEDER Gábor <szeder@ira.uka.de> wrote:
Show 22 quoted lines
>>> diff --git a/t/t7507-commit-verbose.sh b/t/t7507-commit-verbose.sh
>>> index 2ddf28c..cf95efb 100755
>>> --- a/t/t7507-commit-verbose.sh
>>> +++ b/t/t7507-commit-verbose.sh
>>> @@ -3,12 +3,11 @@
>>>  test_description='verbose commit template'
>>>  . ./test-lib.sh
>>>
>>> -cat >check-for-diff <<EOF
>>> -#!$SHELL_PATH
>>> -exec grep '^diff --git' "\$1"
>>> +write_script "check-for-diff" <<-\EOF &&
>>> +grep '^diff --git' "$1" >out &&
>>> +test $(wc -l <out) = 1
>>
>> Our test lib offers the test_line_count helper function, which
>> outputs a helpful error message in case the number of lines do not
>> match.
>
> test_line_count() was mentioned in [2], however, this line counting is
> done in the fake "editor" script, not in the test script proper, so
> the spelled-out form $(wc ...) was proposed[2].
Ah, yes, of course.

But then the question is: why is the line counting in the editor script in the first place?

By redirecting grep's output to a file in the editor script, like this patch wanted to, we can count the lines in the test script itself after 'git commit' finished. This way we could use test_line_count, with all its error reporting benefits, and we could use the same editor script for all tests.

And if you insist on doing the line counting in the editor script, then why redirecting grep's output and 'wc -l' separately, why not 'grep -c'?

Previous: Pranit BauvaNext: Pranit Bauva
Message 8 of 23 in “parse-options.c: make OPTION__COUNTUP consider negative values”
  1. 1/3 parse-options.c: make OPTION__COUNTUP consider negative valuesPranit Bauva, Mar 24, 2016
  2. 2/3 t7507-commit-verbose: make test suite use write_scriptPranit Bauva, Mar 24, 2016
  3. 2/3 t7507-commit-verbose: make test suite use write_scriptSZEDER Gábor, Mar 24, 2016
  4. Eric SunshineMar 24, 2016
  5. Pranit BauvaMar 25, 2016
  6. Eric SunshineMar 25, 2016
  7. Pranit BauvaMar 25, 2016
  8. SZEDER GáborMar 25, 2016
  9. Pranit BauvaMar 25, 2016
  10. Eric SunshineMar 25, 2016
  11. Pranit BauvaMar 25, 2016
  12. Eric SunshineMar 25, 2016
  13. 3/3 commit: add a commit.verbose config variablePranit Bauva, Mar 24, 2016
  14. SZEDER GáborMar 24, 2016
  15. Pranit BauvaMar 24, 2016
  16. Pranit BauvaMar 24, 2016
  17. Eric SunshineMar 25, 2016
  18. Pranit BauvaMar 25, 2016
  19. 1/3 parse-options.c: make OPTION__COUNTUP consider negative valuesSZEDER Gábor, Mar 24, 2016
  20. Pranit BauvaMar 24, 2016
  21. Eric SunshineMar 24, 2016
  22. Pranit BauvaMar 28, 2016
  23. Eric SunshineMar 28, 2016

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.