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

Re: [PATCH 09/20] abbrev tests: test for "git-log" behavior

From
MÅMartin Ågren <martin.agren@gmail.com>
Date
Jun 9, 2018, 13:56 UTC
Message-ID
<CAN0heSrh6kJyiAATc377sEg46O=ofEnczCrBubrSM5pxT72W7Q@mail.gmail.com>
In-Reply-To
<87a7s4471y.fsf@evledraar.gmail.com>
On 9 June 2018 at 11:56, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
Show 23 quoted lines
>
> On Sat, Jun 09 2018, Martin Ågren wrote:
>
>> On 9 June 2018 at 00:41, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
>>> The "log" family of commands does its own parsing for --abbrev in
>>> revision.c, so having dedicated tests for it makes sense.
>>
>>> +for i in $(test_seq 4 40)
>>
>> I've just been skimming so might have missed something, but I see
>> several instances of this construct, and I wonder what this brute-force
>> approach really buys us. An alternative would be, e.g., "for i in 4 23
>> 40". That is, min/max and some arbitrary number in between (odd because
>> the others are even).
>>
>> Of course, we might have a bug which magically happens for the number 9,
>> but I'd expect us to test for that only if we have some reason to
>> believe that number 9 is indeed magical.
>
> Good point, I'll change this in v2, or at least guard it with
> EXPENSIVE. I hacked it up like this while exhaustively testing things
> during development, and discovered some edge cases (e.g. "0" is special
> sometimes).

Ah, "useful during hacking" explains why you did it like this. Of your two approaches, I'd probably favour "make it cheaper" over "mark it as EXPENSIVE". Nothing I feel strongly about.

Show 9 quoted lines
>> Also, 40 is of course tied to SHA-1. You could perhaps define a variable
>> at the top of this file to simplify a future generalization. (Same for
>> 39/41 which are related to 40.)
>
> I forgot to note this in the commit message, but I intentionally didn't
> guard this test with the SHA1 prereq, there's nothing per-se specific to
> SHA-1 here, it's not a given that whatever our NewHash is that we won't
> use 40 characters, and the rest of the magic constants like 4 and 7 is
> something we're likely to retain with NewHash.
I'd tend to agree about not marking this SHA1.
> Although maybe we should expose GIT_SHA1_HEXSZ to the test suite.

It seems like brian's "test_translate"-approach [1] would be a good choice of tool for this. That is, you'd just define something at the top of this file for now, then once that tool is in place, a one-line change could get "hexsz" from `test_translate` instead.

[1] https://public-inbox.org/git/20180604235229.279814-2-sandals@crustytoothpaste.net/
Martin
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 28 of 37 in “unconditional O(1) SHA-1 abbreviation”
  1. 00/20 unconditional O(1) SHA-1 abbreviationÆvar Arnfjörð Bjarmason, Jun 8, 2018
  2. 01/20 t/README: clarify the description of test_line_countÆvar Arnfjörð Bjarmason, Jun 8, 2018
  3. 02/20 test library: add a test_byte_countÆvar Arnfjörð Bjarmason, Jun 8, 2018
  4. 04/20 abbrev tests: add tests for core.abbrev and --abbrevÆvar Arnfjörð Bjarmason, Jun 8, 2018
  5. Junio C HamanoJun 12, 2018
  6. 07/20 abbrev tests: test "git branch" behaviorÆvar Arnfjörð Bjarmason, Jun 8, 2018
  7. 10/20 abbrev tests: test for "git-diff" behaviorÆvar Arnfjörð Bjarmason, Jun 8, 2018
  8. 14/20 config.c: use braces on multiple conditional armsÆvar Arnfjörð Bjarmason, Jun 8, 2018
  9. 16/20 abbrev: unify the handling of non-numeric valuesÆvar Arnfjörð Bjarmason, Jun 8, 2018
  10. 17/20 abbrev: unify the handling of empty valuesÆvar Arnfjörð Bjarmason, Jun 8, 2018
  11. Martin ÅgrenJun 9, 2018
  12. Martin ÅgrenJun 9, 2018
  13. 19/20 abbrev: support relative abbrev valuesÆvar Arnfjörð Bjarmason, Jun 8, 2018
  14. Martin ÅgrenJun 9, 2018
  15. Junio C HamanoJun 12, 2018
  16. Ævar Arnfjörð BjarmasonJun 13, 2018
  17. Junio C HamanoJun 13, 2018
  18. Ævar Arnfjörð BjarmasonJun 14, 2018
  19. Junio C HamanoJun 14, 2018
  20. Ævar Arnfjörð BjarmasonJun 14, 2018
  21. 20/20 abbrev: add a core.validateAbbrev settingÆvar Arnfjörð Bjarmason, Jun 8, 2018
  22. Martin ÅgrenJun 9, 2018
  23. Junio C HamanoJun 12, 2018
  24. 18/20 abbrev parsing: use braces on multiple conditional armsÆvar Arnfjörð Bjarmason, Jun 8, 2018
  25. 09/20 abbrev tests: test for "git-log" behaviorÆvar Arnfjörð Bjarmason, Jun 8, 2018
  26. Martin ÅgrenJun 9, 2018
  27. Ævar Arnfjörð BjarmasonJun 9, 2018
  28. Martin ÅgrenJun 9, 2018
  29. 15/20 parse-options-cb.c: use braces on multiple conditional armsÆvar Arnfjörð Bjarmason, Jun 8, 2018
  30. 12/20 abbrev tests: test for --abbrev and core.abbrev=[+-]NÆvar Arnfjörð Bjarmason, Jun 8, 2018
  31. 13/20 parse-options-cb.c: convert uses of 40 to GIT_SHA1_HEXSZÆvar Arnfjörð Bjarmason, Jun 8, 2018
  32. 06/20 blame: fix a bug, core.abbrev should work like --abbrevÆvar Arnfjörð Bjarmason, Jun 8, 2018
  33. 08/20 abbrev tests: test for "git-describe" behaviorÆvar Arnfjörð Bjarmason, Jun 8, 2018
  34. 11/20 abbrev tests: test for plumbing behaviorÆvar Arnfjörð Bjarmason, Jun 8, 2018
  35. 03/20 blame doc: explicitly note how --abbrev=40 gives 39 charsÆvar Arnfjörð Bjarmason, Jun 8, 2018
  36. Junio C HamanoJun 12, 2018
  37. 05/20 abbrev tests: test "git-blame" behaviorÆvar Arnfjörð Bjarmason, Jun 8, 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.