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

Re: [PATCH v12 4/5] t7507-commit-verbose: improve test coverage by testing number of diffs

From
Pranit Bauva <pranit.bauva@gmail.com>
Date
Apr 5, 2016, 15:54 UTC
Message-ID
<CAFZEwPO_Y6-jEGXDspExhmaWO36QWhaK813TcEUWSqB_byZngQ@mail.gmail.com>
In-Reply-To
<CAPig+cRBwOjxA2cB=ZR__o7LsHxk9Rbzfv7ngRxv8h6=koQSRw@mail.gmail.com>
On Mon, Apr 4, 2016 at 5:32 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 22 quoted lines
> On Sat, Apr 2, 2016 at 7:33 PM, Pranit Bauva <pranit.bauva@gmail.com> wrote:
>> Make the fake "editor" store output of grep in a file so that we can
>> see how many diffs were contained in the message and use them in
>> individual tests where ever it is required. Also use write_script()
>> to create the fake "editor".
>>
>> A subsequent commit will introduce scenarios where it is important to be
>> able to exactly determine how many diffs were present.
>
> These two sentences are backward. The "subsequent commit" bit is
> justification for why you are making the "editor" store the output,
> thus it belongs with the first paragraph. The bit about write_script()
> is just a minor aside which can go in its own paragraph.
>
> I think it's also important to explain that you're changing the
> behavior of write_script() so that it always succeeds, regardless of
> whether grep found diff headers or not, and to give the reason for
> making this change ("so that you don't have to use 'test_must_fail'
> for cases when no diff headers are expected and can instead easily use
> 'test_line_count = 0'").
>
> The patch itself looks fine and is easy enough to read.
I will include some more explanation as you suggest.
Show 49 quoted lines
>
>> Helped-by: Eric Sunshine <sunshine@sunshineco.com>
>> Signed-off-by: Pranit Bauva <pranit.bauva@gmail.com>
>> ---
>> diff --git a/t/t7507-commit-verbose.sh b/t/t7507-commit-verbose.sh
>> index 2ddf28c..0f28a86 100755
>> --- a/t/t7507-commit-verbose.sh
>> +++ b/t/t7507-commit-verbose.sh
>> @@ -3,11 +3,10 @@
>>  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
>> +exit 0
>>  EOF
>> -chmod +x check-for-diff
>>  test_set_editor "$PWD/check-for-diff"
>>
>>  cat >message <<'EOF'
>> @@ -23,7 +22,8 @@ test_expect_success 'setup' '
>>  '
>>
>>  test_expect_success 'initial commit shows verbose diff' '
>> -       git commit --amend -v
>> +       git commit --amend -v &&
>> +       test_line_count = 1 out
>>  '
>>
>>  test_expect_success 'second commit' '
>> @@ -39,13 +39,15 @@ check_message() {
>>
>>  test_expect_success 'verbose diff is stripped out' '
>>         git commit --amend -v &&
>> -       check_message message
>> +       check_message message &&
>> +       test_line_count = 1 out
>>  '
>>
>>  test_expect_success 'verbose diff is stripped out (mnemonicprefix)' '
>>         git config diff.mnemonicprefix true &&
>>         git commit --amend -v &&
>> -       check_message message
>> +       check_message message &&
>> +       test_line_count = 1 out
>>  '
Previous: Eric SunshineNext: Pranit Bauva
Message 14 of 36 in “t0040-test-parse-options.sh: fix style issues”
  1. 1/5 t0040-test-parse-options.sh: fix style issuesPranit Bauva, Apr 2, 2016
  2. 3/5 parse-options.c: make OPTION_COUNTUP respect "unspecified" valuesPranit Bauva, Apr 2, 2016
  3. Eric SunshineApr 3, 2016
  4. Pranit BauvaApr 5, 2016
  5. 2/5 test-parse-options: print quiet as integerPranit Bauva, Apr 2, 2016
  6. Eric SunshineApr 3, 2016
  7. Pranit BauvaApr 5, 2016
  8. Eric SunshineApr 6, 2016
  9. Duy NguyenApr 8, 2016
  10. Junio C HamanoApr 8, 2016
  11. 4/5 t7507-commit-verbose: improve test coverage by testing number of diffsPranit Bauva, Apr 2, 2016
  12. Eric SunshineApr 4, 2016
  13. Eric SunshineApr 4, 2016
  14. Pranit BauvaApr 5, 2016
  15. 5/5 commit: add a commit.verbose config variablePranit Bauva, Apr 2, 2016
  16. Eric SunshineApr 4, 2016
  17. Eric SunshineApr 4, 2016
  18. Pranit BauvaApr 5, 2016
  19. Eric SunshineApr 3, 2016
  20. Pranit BauvaApr 4, 2016
  21. Eric SunshineApr 4, 2016
  22. Pranit BauvaApr 5, 2016
  23. 1/6 t0040-test-parse-options.sh: fix style issuesPranit Bauva, Apr 9, 2016
  24. 6/6 commit: add a commit.verbose config variablePranit Bauva, Apr 9, 2016
  25. Junio C HamanoApr 12, 2016
  26. Pranit BauvaApr 12, 2016
  27. Junio C HamanoApr 12, 2016
  28. Junio C HamanoApr 12, 2016
  29. Pranit BauvaApr 12, 2016
  30. 5/6 t7507-commit-verbose: improve test coverage by testing number of diffsPranit Bauva, Apr 9, 2016
  31. 2/6 test-parse-options: print quiet as integerPranit Bauva, Apr 9, 2016
  32. Junio C HamanoApr 12, 2016
  33. Pranit BauvaApr 12, 2016
  34. Junio C HamanoApr 12, 2016
  35. 3/6 t0040-parse-options: improve test coveragePranit Bauva, Apr 9, 2016
  36. 4/6 parse-options.c: make OPTION_COUNTUP respect "unspecified" valuesPranit Bauva, Apr 9, 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.