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

Re: [PATCH 2/2] test-lib-functions: use BUG() in 'test_must_fail'

From
Jeff King <peff@peff.net>
Date
Apr 14, 2026, 22:18 UTC
Message-ID
<20260414221807.GB3475104@coredump.intra.peff.net>
In-Reply-To
<xmqqv7dt8cyj.fsf@gitster.g>
On Tue, Apr 14, 2026 at 02:11:00PM -0700, Junio C Hamano wrote:
Show 20 quoted lines
> I was wondering if we should remove "test_might_fail".  Its use case
> is rather limited to very narrow cases, like
> 
>  * we want to kill something but it may have exited on its own
> 
>  * we want "git config --unset" but the variable may or may not be set
> 
>  * we want "git foo --abort" just in case we are in the middle of
>    "git foo"
> 
> all of which is clearer with "|| :", and more importantly, the thing
> whose "failure" is protected against the test framework declaring a
> test failure is *not* what we are testing (these "config --unset"
> are not about testing "git config", in other words).
> 
> So the extra ability test_must_fail and test_might_fail have that
> they can detect uncontrolled death with non-zero exit status (aka
> "crash") is not very interesting---it is more like "As we are
> running a git command here, it would be better to catch than not
> catch a segfault here as well", i.e., a nice to have item.

I think the main value of both (but especially test_might_fail) is that they slot naturally into &&-chains. I left a similar comment in that other thread, but to expand a bit, if you do:

  false &&
  true || : &&
  echo everything ok
you will get "everything ok", even though step 1 failed. You need:
  false &&
  { true || : } &&
  echo everything ok

except that because it is shell you have to add an extra semicolon after the ":". ;)

Syntax-complaints aside, I think it is a very easy thing for contributors to get wrong. So I think test_might_fail has value, though I do not care if it has a different name.

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 9 of 13 in “tests: don't mess with fd 7 of test helper functions”
  1. 1/2 tests: don't mess with fd 7 of test helper functionsSZEDER Gábor, Feb 21, 2021
  2. 2/2 test-lib-functions: use BUG() in 'test_must_fail'SZEDER Gábor, Feb 21, 2021
  3. Jeff KingFeb 21, 2021
  4. Jeff KingFeb 22, 2021
  5. Jeff KingFeb 22, 2021
  6. Junio C HamanoFeb 22, 2021
  7. SZEDER GáborApr 14, 2026
  8. Junio C HamanoApr 14, 2026
  9. Jeff KingApr 14, 2026
  10. Junio C HamanoApr 15, 2026
  11. Jeff KingApr 14, 2026
  12. Jeff KingFeb 21, 2021
  13. Junio C HamanoFeb 22, 2021

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.