git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Martin Ågren" <martin.agren@gmail.com>
Cc: git@vger.kernel.org, "Phillip Wood" <phillip.wood123@gmail.com>,
	"Emily Shaffer" <emilyshaffer@google.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"SZEDER Gábor" <szeder.dev@gmail.com>
Subject: Re: [PATCH v3] t0091-bugreport.sh: actually verify some content of report
Date: Wed, 05 Jul 2023 12:53:11 -0700	[thread overview]
Message-ID: <xmqqv8eyyw2g.fsf@gitster.g> (raw)
In-Reply-To: <20230705183532.3057433-1-martin.agren@gmail.com> ("Martin Ågren"'s message of "Wed, 5 Jul 2023 20:35:27 +0200")

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.

> +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.

> +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.

> +	# 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.

  parent reply	other threads:[~2023-07-05 19:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <AN0heSrMCnygWUC5Sh1UA9v2JGtjcxYDKPFE0xUPddGEW29c3w@mail.gmail.com>
2023-07-05 18:35 ` [PATCH v3] t0091-bugreport.sh: actually verify some content of report Martin Ågren
2023-07-05 18:43   ` Martin Ågren
2023-07-05 19:53   ` Junio C Hamano [this message]
2023-07-05 19:54     ` Junio C Hamano
2023-07-07 12:26     ` Martin Ågren
2023-07-05 18:31 [PATCH v2] " Martin Ågren
2023-07-05 18:40 ` [PATCH v3] " Martin Ågren
2023-07-05 19:46   ` Phillip Wood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqv8eyyw2g.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=emilyshaffer@google.com \
    --cc=git@vger.kernel.org \
    --cc=martin.agren@gmail.com \
    --cc=phillip.wood123@gmail.com \
    --cc=szeder.dev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).