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

Re: [PATCHv5 9/9] t3301: Modernize

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Nov 12, 2014, 01:57 UTC
Message-ID
<CAPig+cSVtAi-n4EKaOgNwDqLvajzvozRG5_o3XjfZAMzW8T8-g@mail.gmail.com>
In-Reply-To
<1415752816-22782-10-git-send-email-johan@herland.net>
On Tue, Nov 11, 2014 at 7:40 PM, Johan Herland <johan@herland.net> wrote:
Show 19 quoted lines
> Make this test script appear somewhat less old-fashioned:
> Signed-off-by: Johan Herland <johan@herland.net>
> ---
> diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh
> index 416ed9e..861c159 100755
> --- a/t/t3301-notes.sh
> +++ b/t/t3301-notes.sh
> @@ -50,206 +44,186 @@ test_expect_success 'handle empty notes gracefully' '
>  '
>
>  test_expect_success 'create notes' '
> -       git config core.notesRef refs/notes/commits &&
>         MSG=b4 git notes add &&
> -       test ! -f .git/NOTES_EDITMSG &&
> -       test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
> -       test b4 = $(git notes show) &&
> +       test_path_is_missing .git/NOTES_EDITMSG &&
> +       git ls-tree -r refs/notes/commits >actual &&
> +       test_line_count = 1 actual

Broken &&-chain. This problem is repeated each place use invoke test_line_count().

Show 95 quoted lines
> +       test "b4" = "$(git notes show)" &&
>         git show HEAD^ &&
>         test_must_fail git notes show HEAD^
>  '
>
>  test_expect_success 'show notes entry with %N' '
> -       for l in A b4 B
> -       do
> -               echo "$l"
> -       done >expect &&
> -       git show -s --format='A%n%NB' >output &&
> -       test_cmp expect output
> +       test_write_lines A b4 B >expect &&
> +       git show -s --format="A%n%NB" >actual &&
> +       test_cmp expect actual
>  '
>
> -cat >expect <<EOF
> -d423f8c refs/notes/commits@{0}: notes: Notes added by 'git notes add'
> -EOF
> -
>  test_expect_success 'create reflog entry' '
> -       git reflog show refs/notes/commits >output &&
> -       test_cmp expect output
> +       cat <<-EOF >expect &&
> +               a1d8fa6 refs/notes/commits@{0}: notes: Notes added by '"'"'git notes add'"'"'
> +       EOF
> +       git reflog show refs/notes/commits >actual &&
> +       test_cmp expect actual
>  '
>
>  test_expect_success 'edit existing notes' '
>         MSG=b3 git notes edit &&
> -       test ! -f .git/NOTES_EDITMSG &&
> -       test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
> -       test b3 = $(git notes show) &&
> +       test_path_is_missing .git/NOTES_EDITMSG &&
> +       git ls-tree -r refs/notes/commits >actual &&
> +       test_line_count = 1 actual
> +       test "b3" = "$(git notes show)" &&
>         git show HEAD^ &&
>         test_must_fail git notes show HEAD^
>  '
>
>  test_expect_success 'cannot "git notes add -m" where notes already exists' '
>         test_must_fail git notes add -m "b2" &&
> -       test ! -f .git/NOTES_EDITMSG &&
> -       test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
> -       test b3 = $(git notes show) &&
> +       test_path_is_missing .git/NOTES_EDITMSG &&
> +       git ls-tree -r refs/notes/commits >actual &&
> +       test_line_count = 1 actual
> +       test "b3" = "$(git notes show)" &&
>         git show HEAD^ &&
>         test_must_fail git notes show HEAD^
>  '
>
>  test_expect_success 'can overwrite existing note with "git notes add -f -m"' '
>         git notes add -f -m "b1" &&
> -       test ! -f .git/NOTES_EDITMSG &&
> -       test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
> -       test b1 = $(git notes show) &&
> +       test_path_is_missing .git/NOTES_EDITMSG &&
> +       git ls-tree -r refs/notes/commits >actual &&
> +       test_line_count = 1 actual
> +       test "b1" = "$(git notes show)" &&
>         git show HEAD^ &&
>         test_must_fail git notes show HEAD^
>  '
>
>  test_expect_success 'add w/no options on existing note morphs into edit' '
>         MSG=b2 git notes add &&
> -       test ! -f .git/NOTES_EDITMSG &&
> -       test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
> -       test b2 = $(git notes show) &&
> +       test_path_is_missing .git/NOTES_EDITMSG &&
> +       git ls-tree -r refs/notes/commits >actual &&
> +       test_line_count = 1 actual
> +       test "b2" = "$(git notes show)" &&
>         git show HEAD^ &&
>         test_must_fail git notes show HEAD^
>  '
>
>  test_expect_success 'can overwrite existing note with "git notes add -f"' '
>         MSG=b1 git notes add -f &&
> -       test ! -f .git/NOTES_EDITMSG &&
> -       test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
> -       test b1 = $(git notes show) &&
> +       test_path_is_missing .git/NOTES_EDITMSG &&
> +       git ls-tree -r refs/notes/commits >actual &&
> +       test_line_count = 1 actual
> +       test "b1" = "$(git notes show)" &&
>         git show HEAD^ &&
>         test_must_fail git notes show HEAD^
>  '
Previous: Johan HerlandNext: Johan Herland
Message 11 of 14 in “[PATCHv5 0/9] Handling empty notes”
  1. Johan HerlandNov 12, 2014
  2. 1/9 builtin/notes: Fix premature failure when trying to add the empty blobJohan Herland, Nov 12, 2014
  3. 2/9 t3301: Verify that 'git notes' removes empty notes by defaultJohan Herland, Nov 12, 2014
  4. 3/9 builtin/notes: Improve namingJohan Herland, Nov 12, 2014
  5. 4/9 builtin/notes: Refactor note file path into struct note_dataJohan Herland, Nov 12, 2014
  6. 5/9 builtin/notes: Simplify early exit code in add()Johan Herland, Nov 12, 2014
  7. 6/9 builtin/notes: Split create_note() to clarify add vs. remove logicJohan Herland, Nov 12, 2014
  8. 7/9 builtin/notes: Add --allow-empty, to allow storing empty notesJohan Herland, Nov 12, 2014
  9. 8/9 notes: Empty notes should be shown by 'git log'Johan Herland, Nov 12, 2014
  10. 9/9 t3301: ModernizeJohan Herland, Nov 12, 2014
  11. Eric SunshineNov 12, 2014
  12. Johan HerlandNov 12, 2014
  13. Junio C HamanoNov 12, 2014
  14. Johan HerlandNov 12, 2014

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.