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

Re: [PATCH v3] t0091-bugreport.sh: actually verify some content of report

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 5, 2023, 19:53 UTC
Message-ID
<xmqqv8eyyw2g.fsf@gitster.g>
In-Reply-To
<20230705183532.3057433-1-martin.agren@gmail.com>
Martin Ågren <martin.agren@gmail.com> writes:
> +test_expect_success 'create a report' '
> +	git bugreport -s format &&
> +	test_file_not_empty git-bugreport-format.txt
> +'
OK.
Show 23 quoted lines
> +test_expect_success 'report contains wanted template (before first section)' '
> +	sed -ne "/^\[/q;p" git-bugreport-format.txt >actual &&
> +	cat >expect <<-\EOF &&
> +	Thank you for filling out a Git bug report!
> +	Please answer the following questions to help us understand your issue.
> +
> +	What did you do before the bug happened? (Steps to reproduce your issue)
> +
> +	What did you expect to happen? (Expected behavior)
> +
> +	What happened instead? (Actual behavior)
> +
> +	What'\''s different between what you expected and what actually happened?
> +
> +	Anything else you want to add:
> +
> +	Please review the rest of the bug report below.
> +	You can delete any lines you don'\''t wish to share.
> +
> +
> +	EOF
> +	test_cmp expect actual
> +'

I am not sure about the value of the bit-for-bit test here, but OK. It is not like we will be changing this piece of text every week.

Show 11 quoted lines
> +test_expect_success 'sanity check "System Info" section' '
> +	test_when_finished rm -f git-bugreport-format.txt &&
> +
> +	sed -ne "/^\[System Info\]$/,/^$/p" <git-bugreport-format.txt >system &&
> +
> +	# The beginning should match "git version --build-info" verbatim,
> +	# but rather than checking bit-for-bit equality, just test some basics.
> +	grep "git version [0-9]." system &&
> +	grep "shell-path: ." system &&
> +
> +	# After the version, there should be some more info.

Do you want to assert the "after" part? "grep" alone does not do anything of that sort.

Show 5 quoted lines
> +	# This is bound to differ from environment to environment,
> +	# so we just do some rather high-level checks.
> +	grep "uname: ." system &&
> +	grep "compiler info: ." system
>  '

Don't we at least want to anchor all these patterns with "^" or something?

Alternatively, since we do not expect the values of the fields are useful at all, perhaps doing something like this

    sed -n -e '/^\[System Info\]/,/\[Enabled Hooks]/s/^\([^:]*):.*/\1/p' >names
to ensure that we have the fields we expect in the output makes more sense?

I notice that "git version:" does not have its value on its line. Isn't it a bug we would rather fix before writing this "sanity check" test, I have to wonder.

Thanks.
Previous: Martin ÅgrenNext: Junio C Hamano
Message 3 of 5 in “t0091-bugreport.sh: actually verify some content of report”
  1. t0091-bugreport.sh: actually verify some content of reportMartin Ågren, Jul 5, 2023
  2. Martin ÅgrenJul 5, 2023
  3. Junio C HamanoJul 5, 2023
  4. Junio C HamanoJul 5, 2023
  5. Martin ÅgrenJul 7, 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.