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

Re: [PATCH 1/2] unwritable tests: assert exact error output

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 11, 2021, 20:50 UTC
Message-ID
<xmqq5yu3b80j.fsf@gitster.g>
In-Reply-To
<patch-1.2-a5ef8ea47f4-20211009T133354Z-avarab@gmail.com>
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
> In preparation for fixing a regression where we started emitting some
> of these error messages twice, let's assert what the output from "git
> commit" and friends is now in the case of permission errors.

Usually we frown upon expecting an exact error message, but I guess that the nature of the bug this series tries to address justifies it.

Show 9 quoted lines
> -	test_must_fail git write-tree
> +
> +	cat >expect <<-\EOF &&
> +	error: insufficient permission for adding an object to repository database .git/objects
> +	fatal: git-write-tree: error building trees
> +	EOF
> +	test_must_fail git write-tree 2>actual &&
> +	test_cmp expect actual
>  '
OK.
Show 10 quoted lines
>  test_expect_success POSIXPERM,SANITY 'commit should notice unwritable repository' '
>  	test_when_finished "chmod 775 .git/objects .git/objects/??" &&
>  	chmod a-w .git/objects .git/objects/?? &&
> -	test_must_fail git commit -m second
> +
> +	cat >expect <<-\EOF &&
> +	error: insufficient permission for adding an object to repository database .git/objects
> +	error: insufficient permission for adding an object to repository database .git/objects
> +	error: Error building trees
> +	EOF

This is odd. Shouldn't the test expect one message from write-tree and be marked as expecting a failure until the bug gets fixed?

> +	test_must_fail git commit -m second 2>actual &&
> +	test_cmp expect actual
>  '
Previous: Ævar Arnfjörð Bjarmason
Message 7 of 7 in “unwritable tests: assert exact error output”
  1. 1/2 unwritable tests: assert exact error outputÆvar Arnfjörð Bjarmason, Oct 9, 2021
  2. 2/2 commit: fix duplication regression in permission error outputÆvar Arnfjörð Bjarmason, Oct 9, 2021
  3. Junio C HamanoOct 11, 2021
  4. 0/2 commit: fix duplication regression in permission error outputÆvar Arnfjörð Bjarmason, Oct 12, 2021
  5. 1/2 unwritable tests: assert exact error outputÆvar Arnfjörð Bjarmason, Oct 12, 2021
  6. 2/2 commit: fix duplication regression in permission error outputÆvar Arnfjörð Bjarmason, Oct 12, 2021
  7. Junio C HamanoOct 11, 2021

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.