From: Junio C Hamano <gitster@pobox.com>
To: Jon Simons <jon@jonsimons.org>
Cc: git@vger.kernel.org,
Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>,
Patrick Steinhardt <ps@pks.im>
Subject: Re: [PATCH] SubmittingPatches: avoid add-failing-test-then-fix anti-pattern
Date: Sun, 11 Oct 2026 16:44:26 -0700 [thread overview]
Message-ID: <xmqq5wz7dcpx.fsf@gitster.g> (raw)
In-Reply-To: <20261011153206.72386-1-jon@jonsimons.org> (Jon Simons's message of "Sun, 11 Oct 2026 11:32:06 -0400")
Jon Simons <jon@jonsimons.org> writes:
> +When fixing a bug, you may find it useful to first write a test using
> +`test_expect_failure` to confirm that the test exposes the bug.
> +However, unless there is a strong reason not to, submit the test as
> +`test_expect_success` in the same commit as your code change that
> +fixes the bug. A separate commit that only changes `test_expect_failure`
> +to `test_expect_success` can leave the behavior being tested out of the
> +diff context, making the fix harder to review. Reviewers who want to
> +verify that your test reproduces the bug can temporarily undo the code
> +changes while keeping the test.
This indeed matches what contributors have been told to do.
But do we even need to say the first two and a half lines? One
might find it convenient not to write any tests, or to be satisfied
with manual testing, or to send test_expect_failure() separately
and early. None of these is what we recommend.
As you described, adding a test_expect_failure() test with a large
body alone in one patch, and fixing the code in another patch would
show a change from test_expect_failure() to test_expect_success()
without showing much of the body of the test in the second patch,
making the review unnecessarily cumbersome. If the test is trivial
and small, it may fit within the diff context and avoid such a
problem, but then there is no need to add such a small test as a
failing one in a separate patch in the first place, unless the goal
is to inflate the commit count.
So, unless we can think of concrete cases that qualify as a
"strong reason", I do not think we want to write everything before
and up to "a strong reason not to" in your text.
How about a short and sweet sentence like this instead?
A bugfix patch should include tests in test_expect_success()
blocks that demonstrate the breakage when the code change that
implements the fix is omitted.
next prev parent reply other threads:[~2026-10-11 23:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-11 15:32 [PATCH] SubmittingPatches: avoid add-failing-test-then-fix anti-pattern Jon Simons
2026-10-11 16:21 ` Kristoffer Haugsbakk
2026-10-11 23:44 ` Junio C Hamano [this message]
2026-10-12 1:46 ` Jon Simons
2026-10-12 3:00 ` [PATCH v2] " Jon Simons
2026-10-12 14:34 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq5wz7dcpx.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=jon@jonsimons.org \
--cc=kristofferhaugsbakk@fastmail.com \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox