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

Re: [PATCH] t-strvec: use test_msg()

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jul 4, 2024, 18:31 UTC
Message-ID
<CAPig+cSHoHVUGdEDk2h5updMqaPqQMkAvypFLK+S2qRYhw=CWw@mail.gmail.com>
In-Reply-To
<35b0ba6b-d485-44f2-a19f-3ce816f8b435@web.de>
On Thu, Jul 4, 2024 at 2:04 PM René Scharfe <l.s.r@web.de> wrote:
> check_strvec_loc() checks each the strvec item by looping through them
s/each the/each/
Show 5 quoted lines
> and comparing them with expected values.  If a check fails then we'd
> like to know which item is affected.  It reports that information by
> building a strbuf and delivering its contents using a failing assertion.
>
> Here's an example in which there are less items in the strvec than
s/less/fewer/
Show 30 quoted lines
> expected; the index of the missing item is reported in the last line:
>
>    # check "vec->nr > nr" failed at t/unit-tests/t-strvec.c:19
>    #    left: 1
>    #   right: 1
>    # check "strvec index 1" failed at t/unit-tests/t-strvec.c:71
>
> Note that it is also reported in the third line, i.e. the variable
> "nr" contains that index.
>
> Stop printing the index explicitly for checks that already report it.
> The message for the same condition as above becomes:
>
>    # check "vec->nr > nr" failed at t/unit-tests/t-strvec.c:19
>    #    left: 1
>    #   right: 1
>
> For the string comparison, whose error message doesn't include the
> index, report it using the simpler and more appropriate test_msg()
> instead.  Report the index using its actual name and format the line
> like the preceding ones.  The message for an unexpected string value
> becomes:
>
>    # check "!strcmp(vec->v[nr], str)" failed at t/unit-tests/t-strvec.c:24
>    #    left: "foo"
>    #   right: "bar"
>    #      nr: 0
>
> Reported-by: Phillip Wood <phillip.wood@dunelm.org.uk>
> ---
Missing sign-off.
Previous: René ScharfeNext: Phillip Wood
Message 2 of 20 in “t-strvec: use test_msg()”
  1. t-strvec: use test_msg()René Scharfe, Jul 4, 2024
  2. Eric SunshineJul 4, 2024
  3. Phillip WoodJul 5, 2024
  4. t-strvec: use test_msg()René Scharfe, Jul 5, 2024
  5. Jeff KingJul 9, 2024
  6. René ScharfeJul 14, 2024
  7. Jeff KingJul 16, 2024
  8. René ScharfeJul 16, 2024
  9. 2/1 t-strvec: improve check_strvec() outputRené Scharfe, Jul 14, 2024
  10. Junio C HamanoJul 15, 2024
  11. 3/1 t-strvec: tighten .alloc check in check_strvecRené Scharfe, Jul 14, 2024
  12. Junio C HamanoJul 15, 2024
  13. René ScharfeJul 15, 2024
  14. Junio C HamanoJul 15, 2024
  15. t-strvec: improve check_strvec() outputRené Scharfe, Jul 14, 2024
  16. René ScharfeJul 14, 2024
  17. Jeff KingJul 16, 2024
  18. Junio C HamanoJul 16, 2024
  19. t-strvec: fix type mismatch in check_strvecRené Scharfe, Jul 16, 2024
  20. Junio C HamanoJul 16, 2024

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.