Re: [PATCH] commit -c/-C/--amend: reset timestamp and authorship to committer with --reset-author
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:47:39
Subsystem:
the rest · Maintainer:
Linus Torvalds
Nanako Shiraishi [off-list ref] 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 '