From: Jeff King Date: Tue, 14 Apr 2026 22:18:07 GMT Subject: Re: [PATCH 2/2] test-lib-functions: use BUG() in 'test_must_fail' Message-ID: <20260414221807.GB3475104@coredump.intra.peff.net> In-Reply-To: On Tue, Apr 14, 2026 at 02:11:00PM -0700, Junio C Hamano wrote: > 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