git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/3] t/t7004-tag: add failing tag message file test

From
Junio C Hamano <gitster@pobox.com>
Date
May 15, 2023, 07:02 UTC
Message-ID
<xmqq4joeaxgw.fsf@gitster.g>
In-Reply-To
<1f24aa43f70b16381ef0cfb4f1d482706161554d.1684067644.git.code@khaugsbakk.name>
Kristoffer Haugsbakk <code@khaugsbakk.name> writes:
> Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
> ---
>  t/t7004-tag.sh | 10 ++++++++++
>  1 file changed, 10 insertions(+)

Does this document the current behaviour, i.e. before applying the patch [3/3]? Or is this a new test designed to fail until [3/3] is applied?

If the latter, please don't [*].

Instead, combine this with [3/3] and make it [2/2] that changes the behaviour of the command and protects the new behaviour from future breakages in a single step. Those who are truly curious to see why the code change in it is necessary can apply the "code change plus new test" patch, and then temporarily revert only the code change part in their working tree to see how the test breaks without the code change.

Show 15 quoted lines
> diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
> index 550b5b1cce..1e512dbe06 100755
> --- a/t/t7004-tag.sh
> +++ b/t/t7004-tag.sh
> @@ -2136,4 +2136,14 @@ test_expect_success 'If tag is created then tag message file is unlinked' '
>  	! test -e .git/TAG_EDITMSG
>  '
>  
> +test_expect_success 'If tag cannot be created then tag message file is not unlinked' '
> +	test_when_finished "git tag -d foo/bar" &&
> +	write_script fakeeditor <<-\EOF &&
> +	echo Message >.git/TAG_EDITMSG
> +	EOF
> +	git tag foo/bar &&
> +	! GIT_EDITOR=./fakeeditor git tag -a foo &&

Imitate other tests that expect a controlled failure from our command, and write something like

	test_must_fail env GIT_EDITOR=./fakeeditor git tag -a foo

so that a segfaulting "git tag" will not count as "failing as expected".

> +	test -e .git/TAG_EDITMSG
Use "test_path_exists" instead.
Thanks.
[Footnote]
 * Introducing this as a failing test "test_expect_failure" in [2/3]
   and then flip it to "test_expect_success" in [3/3] would make
   tests pass without applying [3/3], but generally it is not a
   recommended practice.
   This is because such a [3/3] patch would only show the line with
   the test title and the behaviour of the test will not be shown in
   the diff context.  That hurts reviewability.
Previous: Kristoffer HaugsbakkNext: Junio C Hamano
Message 5 of 26 in “tag: keep the message file in case ref transaction fails”
  1. 0/3 tag: keep the message file in case ref transaction failsKristoffer Haugsbakk, May 14, 2023
  2. 1/3 t/t7004-tag: add regression test for existing behaviorKristoffer Haugsbakk, May 14, 2023
  3. Junio C HamanoMay 15, 2023
  4. 2/3 t/t7004-tag: add failing tag message file testKristoffer Haugsbakk, May 14, 2023
  5. Junio C HamanoMay 15, 2023
  6. Junio C HamanoMay 15, 2023
  7. Kristoffer HaugsbakkMay 15, 2023
  8. 3/3 tag: keep the message file in case ref transaction failsKristoffer Haugsbakk, May 14, 2023
  9. Junio C HamanoMay 15, 2023
  10. 0/3 tag: keep the message file in case ref transaction failsKristoffer Haugsbakk, May 15, 2023
  11. 1/3 doc: tag: document `TAG_EDITMSG`Kristoffer Haugsbakk, May 15, 2023
  12. Junio C HamanoMay 15, 2023
  13. 2/3 t/t7004-tag: add regression test for successful tag creationKristoffer Haugsbakk, May 15, 2023
  14. 3/3 tag: keep the message file in case ref transaction failsKristoffer Haugsbakk, May 15, 2023
  15. Junio C HamanoMay 15, 2023
  16. 0/3 tag: keep the message file in case ref transaction failsKristoffer Haugsbakk, May 16, 2023
  17. 1/3 doc: tag: document `TAG_EDITMSG`Kristoffer Haugsbakk, May 16, 2023
  18. 2/3 t/t7004-tag: add regression test for successful tag creationKristoffer Haugsbakk, May 16, 2023
  19. 3/3 tag: keep the message file in case ref transaction failsKristoffer Haugsbakk, May 16, 2023
  20. Junio C HamanoMay 16, 2023
  21. Jeff KingMay 17, 2023
  22. Junio C HamanoMay 17, 2023
  23. Jeff KingMay 17, 2023
  24. Eric SunshineMay 17, 2023
  25. Kristoffer HaugsbakkMay 17, 2023
  26. Kristoffer HaugsbakkMay 17, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.