From: Junio C Hamano <gitster@pobox.com>
To: Nanako Shiraishi <nanako3@lavabit.com>
Cc: Erick Mattos <erick.mattos@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH] commit -c/-C/--amend: reset timestamp and authorship to committer with --reset-author
Date: Tue, 03 Nov 2009 17:12:27 -0800 [thread overview]
Message-ID: <7vd43znldw.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: 20091104073822.6117@nanako3.lavabit.com
Nanako Shiraishi <nanako3@lavabit.com> writes:
> I think it is much better to replace "--mine" in gmane/131893
> with "--reset-author" and make no other change to the test.
Heh, I would not claim my tests were perfect, even though I agree with
most of the suggestions and comments, including the parts I did not quote
that are not about the test script.
My first test did not check the message contents, but all the other ones
(except the last one that we expect the command to fail) check output from
both author_header and message_body, so that not just "--mine affects the
authorship" but also "--mine does not mangle the message contents" are
checked.
One thing you did not mention was that I made sure that the command failed
when given both --mine and --author options; I think Erick's last round
fails to test this condition.
Side note. When writing tests for their shiny new toy, people often
forget to test "the other side".
It is just human nature. It is more fun to demonstrate what your new
feature does, than making sure that the new feature does not kick in
when it is not supposed to, nor it does not change what it is not
supposed to change.
Negative tests are not particularly hard to write. The harder part is
to force the habit of writing them on yourself. Right after designing
and implementing a new feature, the list of things it is supposed to
do and when it is supposed to kick in are pretty clear in your mind,
and that is what makes writing positive tests psychologically a lot
easier.
On the other hand, it takes concious effort to list what it is _not_
supposed to do or when it is _not_ supposed to kick in. That is why
people often fail to write negative tests.
I think in addition to the obvious "s/--mine/--reset-author/g"
replacements, we would need this patch on top of mine.
t/t7509-commit.sh | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/t/t7509-commit.sh b/t/t7509-commit.sh
index ec13cea..1dad228 100755
--- a/t/t7509-commit.sh
+++ b/t/t7509-commit.sh
@@ -28,6 +28,10 @@ test_expect_success '-C option copies authorship and message' '
git commit -a -C Initial &&
author_header Initial >expect &&
author_header HEAD >actual &&
+ test_cmp expect actual &&
+
+ message_body Initial >expect &&
+ message_body HEAD >actual &&
test_cmp expect actual
'
prev parent reply other threads:[~2009-11-04 1:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-03 21:09 [PATCH] commit -c/-C/--amend: reset timestamp and authorship to committer with --reset-author Erick Mattos
2009-11-03 22:38 ` Nanako Shiraishi
2009-11-03 23:51 ` Erick Mattos
2009-11-04 1:23 ` Junio C Hamano
2009-11-04 2:55 ` Erick Mattos
2009-11-04 1:12 ` Junio C Hamano [this message]
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=7vd43znldw.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=erick.mattos@gmail.com \
--cc=git@vger.kernel.org \
--cc=nanako3@lavabit.com \
/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;
as well as URLs for NNTP newsgroup(s).