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

Re: [PATCH v3 5/5] Testing: provide tests requiring them with ellipses after SHA-1 values

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 20, 2017, 04:06 UTC
Message-ID
<xmqqzi7hlhkx.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20171119184113.16630-5-bedhanger@gmx.de>
Ann T Ropea <bedhanger@gmx.de> writes:
> *1* We are being overly generous in t4013-diff-various.sh because we do
> not want to destroy/take apart the here-document.  Given that all this a
> temporary measure, we should get away with it.

I do not think the patch is being particularly generous. If anything, it is being unnecessarily sloppy by not adding new checks to verify the updated behaviour.

The above comment mentions "destroy/take apart" the here-document, but I do see no need to destroy anything. All you need to do is to enhance and extend. For example, you could do it like so (this is written in my e-mail client, and not an output of diff, so the indentation etc. may be all off, but should be sufficient to illustrate the idea):

    while read cmd
    do
            case "$cmd" in
            '' | '#'*) continue ;;
            esac
            test=$(echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g')
            pfx=$(printf "%04d" $test_count)
            expect="$TEST_DIRECTORY/t4013/diff.$test"
            actual="$pfx-diff.$test"
   +        case "$cmd" in
   +        X*) cmd=${cmd#X}; no_ellipses=" (no ellipses)" ;;
   +        *) no_ellipses= ;;
   +        esac
   -        test_expect_success "git $cmd" '
   +        test_expect_success "git $cmd$no_ellipses" '
                {
                        echo "\$ git $cmd"
   -                    git $cmd |
   +                    if test -n "$no_ellipses"
   +                    then
   +                            git $cmd
   +                    else
   +                            PRINT_SHA1_ELLIPSES=yes git $cmd
   +                    fi |
                        sed -e ....
        ...
    done <<\EOF
    diff-tree initial
    diff-tree -r initial
    diff-tree -r --abbrev initial
    diff-tree -r --abbrev=4 initial
   +Xdiff-tree -r --abbrev=4 initial
    ...
    EOF

There is a new and duplicated line with a prefix X for one existing test in the above. The idea is that the ones marked as such will test and verify the effect of this new behaviour by not setting the environment variable. The expected and actual test output for the new test will have X prefixed to it. t4013 is arranged in such a way that it is easy to add a new test like this---you only need to add an expected output in a new file in t/t4013/. directory. And the output with these ellipses removed will be something we would expect see in the new world (without the escape hatch environment variable), we would need to add a new file there to record what the expected output from the command is.

I singled out the diff-tree invocation with --abbrev=4 as an example in the above, but in a more thorough final version, we'd need to cover both "abbreviation with ellipses" and "abbreviation without ellipses" output for other lines in the test case listed in the here-document.

Previous: Ann T RopeaNext: Philip Oakley
Message 24 of 58 in “checkout: describe_detached_head: remove 3dots after committish”
  1. 1/3 checkout: describe_detached_head: remove 3dots after committishAnn T Ropea, Nov 5, 2017
  2. 2/3 Documentation: user-manual: limit potentially confusing usage of 3dots (and 2dots)Ann T Ropea, Nov 5, 2017
  3. 3/3 Documentation: revisions: add note about 3dots usages as continuation indicationsAnn T Ropea, Nov 5, 2017
  4. Junio C HamanoNov 6, 2017
  5. Junio C HamanoNov 6, 2017
  6. Philip OakleyNov 7, 2017
  7. Junio C HamanoNov 7, 2017
  8. Ann T RopeaNov 7, 2017
  9. Philip OakleyNov 7, 2017
  10. Junio C HamanoNov 8, 2017
  11. Philip OakleyNov 9, 2017
  12. Ann T RopeaNov 13, 2017
  13. Ann T RopeaNov 13, 2017
  14. Ann T RopeaNov 13, 2017
  15. Junio C HamanoNov 14, 2017
  16. Ann T RopeaNov 19, 2017
  17. Junio C HamanoNov 20, 2017
  18. Ann T RopeaNov 19, 2017
  19. Ann T RopeaNov 19, 2017
  20. Eric SunshineNov 19, 2017
  21. Ann T RopeaNov 19, 2017
  22. Eric SunshineNov 19, 2017
  23. Ann T RopeaNov 19, 2017
  24. Junio C HamanoNov 20, 2017
  25. Philip OakleyNov 20, 2017
  26. Junio C HamanoNov 22, 2017
  27. Philip OakleyNov 22, 2017
  28. Junio C HamanoNov 24, 2017
  29. Ann T RopeaNov 24, 2017
  30. Ann T RopeaNov 24, 2017
  31. Ann T RopeaNov 24, 2017
  32. Ann T RopeaNov 24, 2017
  33. Ann T RopeaNov 24, 2017
  34. Ann T RopeaNov 24, 2017
  35. Junio C HamanoNov 25, 2017
  36. Junio C HamanoNov 26, 2017
  37. Junio C HamanoNov 26, 2017
  38. Junio C HamanoNov 26, 2017
  39. Ann T RopeaDec 3, 2017
  40. Ann T RopeaDec 3, 2017
  41. Ann T RopeaDec 3, 2017
  42. Ann T RopeaDec 3, 2017
  43. Ann T RopeaDec 3, 2017
  44. Junio C HamanoDec 4, 2017
  45. Ann T RopeaDec 4, 2017
  46. Junio C HamanoDec 5, 2017
  47. Ann T RopeaDec 6, 2017
  48. Junio C HamanoDec 6, 2017
  49. Ann T RopeaDec 6, 2017
  50. Ann T RopeaDec 3, 2017
  51. Ann T RopeaDec 3, 2017
  52. Junio C HamanoDec 4, 2017
  53. Ann T RopeaNov 19, 2017
  54. Junio C HamanoNov 20, 2017
  55. Ann T RopeaNov 13, 2017
  56. Ann T RopeaNov 13, 2017
  57. Ann T RopeaNov 13, 2017
  58. Junio C HamanoNov 14, 2017

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.