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

Re: [PATCH v2 6/6] t9109-git-svn-props.sh: split up several pipes

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Sep 18, 2018, 01:56 UTC
Message-ID
<CAPig+cT5BLu2onbuTBbZ_mMzNMkEuPk5-g2d5YKw4V6Z42Y3aQ@mail.gmail.com>
In-Reply-To
<e01b719de662f0b150f78b5a6ab6ccfce9c675fa.1537223021.git.matvore@google.com>
On Mon, Sep 17, 2018 at 6:25 PM Matthew DeVore <matvore@google.com> wrote:
> t9109-git-svn-props.sh: split up several pipes

Similar to my comment about 5/6, this title talks about the mechanical changes made by the patch but not the intent. Perhaps reword it like this:

    t9109: avoid swallowing Git exit code upstream of a pipe
Show 9 quoted lines
> A test uses several separate pipe sequences in a row which are awkward
> to split up. Wrap the split-up pipe in a function so the awkwardness is
> not repeated.
>
> Signed-off-by: Matthew DeVore <matvore@google.com>
> ---
> diff --git a/t/t9101-git-svn-props.sh b/t/t9101-git-svn-props.sh
> @@ -190,16 +190,21 @@ EOF
> +# Note we avoid using pipes in order to ensure that git exits with 0.

This new comment doesn't really add value for someone reading the patch without knowing the history leading up to the point the comment was added. It should probably be dropped. (The actual text of the comment is rather confusing anyhow since avoiding pipes has nothing to do with ensuring that git exits with 0, thus another reason why this comment ought to be dropped.)

>  test_expect_success 'test propget' "
> -       git svn propget svn:ignore . | cmp - prop.expect &&
> +       test_propget () {
> +               git svn propget $1 $2 >observed

The &&-chain is broken here, which means you're losing the exit status from the Git command anyhow (despite the point of the patch being to avoid losing it).

Also, for consistency, how about calling this "actual" rather than "observed"?
> +               cmp - $3

This is just wrong. The "-" argument to 'cmp' says to read from standard input, but there is nothing being passed to 'cmp' on standard input anymore now that you're removed the pipe. I'm guessing that you really meant to use "observed" here (and reverse the order of arguments to be consistent with the expect-then-actual idiom). Finally, since these (apparently) might be binary, you can use test_cmp_bin() instead.

Show 18 quoted lines
> +       } &&
> +       test_propget svn:ignore . prop.expect &&
>         cd deeply &&
> -       git svn propget svn:ignore . | cmp - ../prop.expect &&
> -       git svn propget svn:entry:committed-rev nested/directory/.keep \
> -         | cmp - ../prop2.expect &&
> -       git svn propget svn:ignore .. | cmp - ../prop.expect &&
> -       git svn propget svn:ignore nested/ | cmp - ../prop.expect &&
> -       git svn propget svn:ignore ./nested | cmp - ../prop.expect &&
> -       git svn propget svn:ignore .././deeply/nested | cmp - ../prop.expect
> +       test_propget svn:ignore . ../prop.expect &&
> +       test_propget svn:entry:committed-rev nested/directory/.keep \
> +               ../prop2.expect &&
> +       test_propget svn:ignore .. ../prop.expect &&
> +       test_propget svn:ignore nested/ ../prop.expect &&
> +       test_propget svn:ignore ./nested ../prop.expect &&
> +       test_propget svn:ignore .././deeply/nested ../prop.expect
>         "

After this patch, the test is even more broken than appears at first glance since the test body is inside double-quotes. This means that the $1, $2, $3 inside the test_propget() function are getting expanded _before_ the function itself is ever defined, to whatever bogus values $1, $2, $3 hold at that point. I can't see how this could ever have worked (except only appearing to work by pure accident).

Previous: Matthew DeVoreNext: Matthew DeVore
Message 63 of 66 in “Cleanup tests for test_cmp argument ordering and "|" placement”
  1. 0/2 Cleanup tests for test_cmp argument ordering and "|" placementMatthew DeVore, Sep 15, 2018
  2. 1/2 t/*: fix pipe placement and remove \'sMatthew DeVore, Sep 15, 2018
  3. Jonathan NiederSep 17, 2018
  4. Matthew DeVoreSep 17, 2018
  5. 2/2 t/*: fix ordering of expected/observed argumentsMatthew DeVore, Sep 15, 2018
  6. Matthew DeVoreSep 17, 2018
  7. Junio C HamanoSep 15, 2018
  8. 0/6 Clean up tests for test_cmp arg ordering and pipe placementMatthew DeVore, Sep 17, 2018
  9. 4/6 tests: Add linter check for pipe placement styleMatthew DeVore, Sep 17, 2018
  10. Eric SunshineSep 18, 2018
  11. Matthew DeVoreSep 19, 2018
  12. 0/5 Clean up tests for test_cmp arg ordering and pipe placementMatthew DeVore, Sep 21, 2018
  13. 1/5 CodingGuidelines: add shell piping guidelinesMatthew DeVore, Sep 21, 2018
  14. Eric SunshineSep 21, 2018
  15. Matthew DeVoreSep 21, 2018
  16. SZEDER GáborSep 24, 2018
  17. Matthew DeVoreSep 25, 2018
  18. SZEDER GáborSep 27, 2018
  19. Matthew DeVoreOct 1, 2018
  20. 2/5 tests: standardize pipe placementMatthew DeVore, Sep 21, 2018
  21. 3/5 t/*: fix ordering of expected/observed argumentsMatthew DeVore, Sep 21, 2018
  22. 4/5 tests: don't swallow Git errors upstream of pipesMatthew DeVore, Sep 21, 2018
  23. 5/5 t9109: don't swallow Git errors upstream of pipesMatthew DeVore, Sep 21, 2018
  24. 0/7 Clean up tests for test_cmp arg ordering and pipe placementMatthew DeVore, Oct 3, 2018
  25. 1/7 t/README: reformat Do, Don't, Keep in mind listsMatthew DeVore, Oct 3, 2018
  26. Junio C HamanoOct 5, 2018
  27. Matthew DeVoreOct 5, 2018
  28. 2/7 Documentation: add shell guidelinesMatthew DeVore, Oct 3, 2018
  29. Junio C HamanoOct 5, 2018
  30. Matthew DeVoreOct 5, 2018
  31. 3/7 tests: standardize pipe placementMatthew DeVore, Oct 3, 2018
  32. 4/7 t/*: fix ordering of expected/observed argumentsMatthew DeVore, Oct 3, 2018
  33. 5/7 tests: don't swallow Git errors upstream of pipesMatthew DeVore, Oct 3, 2018
  34. Junio C HamanoOct 5, 2018
  35. Matthew DeVoreOct 5, 2018
  36. Matthew DeVoreOct 5, 2018
  37. 6/7 t9109: don't swallow Git errors upstream of pipesMatthew DeVore, Oct 3, 2018
  38. 7/7 tests: order arguments to git-rev-list properlyMatthew DeVore, Oct 3, 2018
  39. Matthew DeVoreOct 3, 2018
  40. Junio C HamanoOct 5, 2018
  41. 0/7 subject: Clean up tests for test_cmp arg ordering and pipe placementMatthew DeVore, Oct 5, 2018
  42. 1/7 t/README: reformat Do, Don't, Keep in mind listsMatthew DeVore, Oct 5, 2018
  43. 2/7 Documentation: add shell guidelinesMatthew DeVore, Oct 5, 2018
  44. 3/7 tests: standardize pipe placementMatthew DeVore, Oct 5, 2018
  45. 4/7 t/*: fix ordering of expected/observed argumentsMatthew DeVore, Oct 5, 2018
  46. 5/7 tests: don't swallow Git errors upstream of pipesMatthew DeVore, Oct 5, 2018
  47. 6/7 t9109: don't swallow Git errors upstream of pipesMatthew DeVore, Oct 5, 2018
  48. 7/7 tests: order arguments to git-rev-list properlyMatthew DeVore, Oct 5, 2018
  49. Junio C HamanoOct 6, 2018
  50. 1/6 CodingGuidelines: add shell piping guidelinesMatthew DeVore, Sep 17, 2018
  51. Eric SunshineSep 18, 2018
  52. Matthew DeVoreSep 19, 2018
  53. Eric SunshineSep 19, 2018
  54. Junio C HamanoSep 19, 2018
  55. Matthew DeVoreSep 19, 2018
  56. 2/6 tests: standardize pipe placementMatthew DeVore, Sep 17, 2018
  57. 3/6 t/*: fix ordering of expected/observed argumentsMatthew DeVore, Sep 17, 2018
  58. 4/6 tests: add linter check for pipe placement styleMatthew DeVore, Sep 17, 2018
  59. 5/6 tests: split up pipesMatthew DeVore, Sep 17, 2018
  60. Eric SunshineSep 18, 2018
  61. Matthew DeVoreSep 19, 2018
  62. 6/6 t9109-git-svn-props.sh: split up several pipesMatthew DeVore, Sep 17, 2018
  63. Eric SunshineSep 18, 2018
  64. Matthew DeVoreSep 19, 2018
  65. Eric SunshineSep 19, 2018
  66. Matthew DeVoreSep 19, 2018

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.