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

Re: [PATCH] t5310-pack-bitmaps: fix bogus 'pack-objects to file can use bitmap' test

From
Matthew DeVore <matvore@google.com>
Date
Aug 22, 2018, 18:14 UTC
Message-ID
<20180822181444.169611-1-matvore@google.com>
In-Reply-To
<4d6ffc81-a1e8-a60f-d53f-2ec159160fcd@gmail.com>

I would encourage use of an existing function to check for emptiness, but require a particular argument for it to be considered "the right way:"

test_cmp /dev/null actual

This means less vocabulary to memorize for test writers. It's usually a code smell to have special logic for a specific value for a specific argument - a sign that a separate function ought to be created - but since we want to add an error or warning in test_cmp anyway when <EXPECTED> is empty, I think this special logic is OK.

As for comparing against a file that *might* be empty, like a utility function, might I suggest requiring the file name be formatted in a specific way if it may be empty? Like require a certain substring. Then the syntax for comparison would be:

# If the emptiness is unconditional test_cmp /dev/null actual

# If the emptiness is unknown ahead of time test_cmp maybe_empty_expected actual

Then, issue an error for something like:
> expected && test_cmp expected actual

which says: " Use test_cmp /dev/null <ACTUAL> to verify a file is empty. If the <EXPECTED> file may or may not be empty (as in a utility function), include the string "maybe_empty" in the <EXPECTED> file name. "

Previous: SZEDER GáborNext: Kirill Smelkov
Message 14 of 17 in “t5310-pack-bitmaps: fix bogus 'pack-objects to file can use bitmap' test”
  1. t5310-pack-bitmaps: fix bogus 'pack-objects to file can use bitmap' testSZEDER Gábor, Aug 14, 2018
  2. Jeff KingAug 14, 2018
  3. Andrei RybakAug 16, 2018
  4. Junio C HamanoAug 16, 2018
  5. SZEDER GáborAug 17, 2018
  6. Andrei RybakAug 17, 2018
  7. Junio C HamanoAug 17, 2018
  8. Andrei RybakAug 19, 2018
  9. Jeff KingAug 19, 2018
  10. Andrei RybakAug 19, 2018
  11. Jeff KingAug 19, 2018
  12. Junio C HamanoAug 21, 2018
  13. SZEDER GáborAug 17, 2018
  14. Matthew DeVoreAug 22, 2018
  15. Kirill SmelkovAug 27, 2018
  16. Jeff KingAug 27, 2018
  17. Kirill SmelkovAug 28, 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.