git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/1] Fix a false negative in t3301-notes.sh
@ 2019-04-09 10:41 Johannes Schindelin via GitGitGadget
  2019-04-09 10:41 ` [PATCH 1/1] t3301: fix false negative Johannes Schindelin via GitGitGadget
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2019-04-09 10:41 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

It is always bad when test cases fail for the wrong reasons, but it is in
some ways more scary when they pass for the wrong reasons.

I stumbled over this issue while chasing down a Windows-specific issue that
caused two other test cases to fail, and should have caused this one to
fail, too, but didn't.

Johannes Schindelin (1):
  t3301: fix false negative

 t/t3301-notes.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)


base-commit: 8104ec994ea3849a968b4667d072fedd1e688642
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-176%2Fdscho%2Ffix-false-negative-in-t3301-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-176/dscho/fix-false-negative-in-t3301-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/176
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/1] t3301: fix false negative
  2019-04-09 10:41 [PATCH 0/1] Fix a false negative in t3301-notes.sh Johannes Schindelin via GitGitGadget
@ 2019-04-09 10:41 ` Johannes Schindelin via GitGitGadget
  2019-04-09 11:33   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2019-04-09 10:41 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Johannes Schindelin

From: Johannes Schindelin <johannes.schindelin@gmx.de>

In 6956f858f6 (notes: implement helpers needed for note copying during
rewrite, 2010-03-12), we introduced a test case that verifies that the
config setting `notes.rewriteRef` can be overridden via the environment
variable `GIT_NOTES_REWRITE_REF`.

Back when it was introduced, it relied on a side effect of an earlier
test case that configured `core.noteRef` to point to `refs/notes/other`.

In 908a320363 (t3301: modernize style, 2014-11-12), this side effect was
removed.

The test case *still* passed, but for the wrong reason: we no longer
overrode the rewrite ref, but there simply was nothing to rewrite
anymore, as the overridden notes ref was "modernized" away.

Let's let that test case pass for the correct reason again.

To make sure of that, let's change the idea of the original test case:
it configured `notes.rewriteRef` to point to the actual notes ref,
forced that to be ignored and then verified that the notes were *not*
rewritten.

By turning that idea upside down (configure the `notes.rewriteRef` to
another notes ref, override it via the environment variable to force the
notes to be copied, and then verify that the notes *were* rewritten), we
make it much harder for that test case to pass for the wrong reason.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 t/t3301-notes.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh
index 84bbf88cf9..704bbc6541 100755
--- a/t/t3301-notes.sh
+++ b/t/t3301-notes.sh
@@ -1120,9 +1120,10 @@ test_expect_success 'GIT_NOTES_REWRITE_REF overrides config' '
 	test_config notes.rewriteMode overwrite &&
 	test_config notes.rewriteRef refs/notes/other &&
 	echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
-	GIT_NOTES_REWRITE_REF= git notes copy --for-rewrite=foo &&
+	GIT_NOTES_REWRITE_REF=refs/notes/commits \
+		git notes copy --for-rewrite=foo &&
 	git log -1 >actual &&
-	test_cmp expect actual
+	grep "replacement note 3" actual
 '
 
 test_expect_success 'git notes copy diagnoses too many or too few parameters' '
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] t3301: fix false negative
  2019-04-09 10:41 ` [PATCH 1/1] t3301: fix false negative Johannes Schindelin via GitGitGadget
@ 2019-04-09 11:33   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2019-04-09 11:33 UTC (permalink / raw)
  To: Johannes Schindelin via GitGitGadget; +Cc: git, Johannes Schindelin

"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:

> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> In 6956f858f6 (notes: implement helpers needed for note copying during
> rewrite, 2010-03-12), we introduced a test case that verifies that the
> config setting `notes.rewriteRef` can be overridden via the environment
> variable `GIT_NOTES_REWRITE_REF`.
>
> Back when it was introduced, it relied on a side effect of an earlier
> test case that configured `core.noteRef` to point to `refs/notes/other`.
>
> In 908a320363 (t3301: modernize style, 2014-11-12), this side effect was
> removed.
>
> The test case *still* passed, but for the wrong reason: we no longer
> overrode the rewrite ref, but there simply was nothing to rewrite
> anymore, as the overridden notes ref was "modernized" away.

Wow.  Thanks for digging thru this

> Let's let that test case pass for the correct reason again.
>
> To make sure of that, let's change the idea of the original test case:
> it configured `notes.rewriteRef` to point to the actual notes ref,
> forced that to be ignored and then verified that the notes were *not*
> rewritten.
>
> By turning that idea upside down (configure the `notes.rewriteRef` to
> another notes ref, override it via the environment variable to force the
> notes to be copied, and then verify that the notes *were* rewritten), we
> make it much harder for that test case to pass for the wrong reason.

Yup.  I agree that testing positive side, expressing what we want to
happen in a more explicit manner, is always a better alternative.

Will queue.  Thanks.

> index 84bbf88cf9..704bbc6541 100755
> --- a/t/t3301-notes.sh
> +++ b/t/t3301-notes.sh
> @@ -1120,9 +1120,10 @@ test_expect_success 'GIT_NOTES_REWRITE_REF overrides config' '
>  	test_config notes.rewriteMode overwrite &&
>  	test_config notes.rewriteRef refs/notes/other &&
>  	echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
> -	GIT_NOTES_REWRITE_REF= git notes copy --for-rewrite=foo &&
> +	GIT_NOTES_REWRITE_REF=refs/notes/commits \
> +		git notes copy --for-rewrite=foo &&
>  	git log -1 >actual &&
> -	test_cmp expect actual
> +	grep "replacement note 3" actual
>  '
>  
>  test_expect_success 'git notes copy diagnoses too many or too few parameters' '

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-04-09 11:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-09 10:41 [PATCH 0/1] Fix a false negative in t3301-notes.sh Johannes Schindelin via GitGitGadget
2019-04-09 10:41 ` [PATCH 1/1] t3301: fix false negative Johannes Schindelin via GitGitGadget
2019-04-09 11:33   ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).