From: Phillip Wood <phillip.wood123@gmail.com>
To: "Martin Ågren" <martin.agren@gmail.com>, git@vger.kernel.org
Cc: "Emily Shaffer" <emilyshaffer@google.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Junio C Hamano" <gitster@pobox.com>,
"SZEDER Gábor" <szeder.dev@gmail.com>
Subject: Re: [PATCH v3] t0091-bugreport.sh: actually verify some content of report
Date: Wed, 5 Jul 2023 20:46:43 +0100 [thread overview]
Message-ID: <161932f5-ae8f-cfaa-a6b0-ab140d0f002e@gmail.com> (raw)
In-Reply-To: <20230705184058.3057709-1-martin.agren@gmail.com>
Hi Martin
This version looks good to me, thanks for re-rolling
Phillip
On 05/07/2023 19:40, Martin Ågren wrote:
> In the first test in this script, 'creates a report with content in the
> right places', we generate a report and pipe it into our helper
> `check_all_headers_populated()`. The idea of the helper is to find all
> lines that look like headers ("[Some Header Here]") and to check that
> the next line is non-empty. This is supposed to catch erroneous outputs
> such as the following:
>
> [A Header]
> something
> more here
>
> [Another Header]
>
> [Too Early Header]
> contents
>
> However, we provide the lines of the bug report as filenames to grep,
> meaning we mostly end up spewing errors:
>
> grep: : No such file or directory
> grep: [System Info]: No such file or directory
> grep: git version:: No such file or directory
> grep: git version 2.41.0.2.gfb7d80edca: No such file or directory
>
> This doesn't disturb the test, which tugs along and reports success, not
> really having verified the contents of the report at all.
>
> Note that after 788a776069 ("bugreport: collect list of populated
> hooks", 2020-05-07), the bug report, which is created in our hook-less
> test repo, contains an empty section with the enabled hooks. Thus, even
> the intention of our helper is a bit misguided: there is nothing
> inherently wrong with having an empty section in the bug report.
>
> Let's instead split this test into three: first verify that we generate
> a report at all, then check that the introductory blurb looks the way it
> should, then verify that the "[System Info]" seems to contain the right
> things. (The "[Enabled Hooks]" section is tested later in the script.)
>
> Reported-by: SZEDER Gábor <szeder.dev@gmail.com>
> Helped-by: Phillip Wood <phillip.wood123@gmail.com>
> Signed-off-by: Martin Ågren <martin.agren@gmail.com>
> ---
> (Resend of v3, now with correct In-Reply-To.)
>
> t/t0091-bugreport.sh | 67 +++++++++++++++++++++++++++++---------------
> 1 file changed, 44 insertions(+), 23 deletions(-)
>
> diff --git a/t/t0091-bugreport.sh b/t/t0091-bugreport.sh
> index b6d2f591ac..f6998269be 100755
> --- a/t/t0091-bugreport.sh
> +++ b/t/t0091-bugreport.sh
> @@ -5,29 +5,50 @@ test_description='git bugreport'
> TEST_PASSES_SANITIZE_LEAK=true
> . ./test-lib.sh
>
> -# Headers "[System Info]" will be followed by a non-empty line if we put some
> -# information there; we can make sure all our headers were followed by some
> -# information to check if the command was successful.
> -HEADER_PATTERN="^\[.*\]$"
> -
> -check_all_headers_populated () {
> - while read -r line
> - do
> - if test "$(grep "$HEADER_PATTERN" "$line")"
> - then
> - echo "$line"
> - read -r nextline
> - if test -z "$nextline"; then
> - return 1;
> - fi
> - fi
> - done
> -}
> -
> -test_expect_success 'creates a report with content in the right places' '
> - test_when_finished rm git-bugreport-check-headers.txt &&
> - git bugreport -s check-headers &&
> - check_all_headers_populated <git-bugreport-check-headers.txt
> +test_expect_success 'create a report' '
> + git bugreport -s format &&
> + test_file_not_empty git-bugreport-format.txt
> +'
> +
> +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
> +'
> +
> +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.
> + # 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
> '
>
> test_expect_success 'dies if file with same name as report already exists' '
next prev parent reply other threads:[~2023-07-05 19:46 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-16 21:18 [PATCH v13 0/5] git-bugreport with fixed VS build Emily Shaffer
2020-04-16 21:18 ` [PATCH v13 1/5] help: move list_config_help to builtin/help Emily Shaffer
2020-04-16 22:21 ` Junio C Hamano
2020-04-16 22:28 ` Junio C Hamano
2020-04-17 19:36 ` Emily Shaffer
2020-04-17 2:04 ` Danh Doan
2020-04-17 2:11 ` Danh Doan
2021-04-08 21:29 ` [PATCH] Makefile: add missing dependencies of 'config-list.h' SZEDER Gábor
2021-04-08 22:08 ` Ævar Arnfjörð Bjarmason
2021-04-08 23:40 ` Jeff King
2021-04-09 21:20 ` SZEDER Gábor
2021-04-16 19:03 ` Junio C Hamano
2021-04-16 21:33 ` SZEDER Gábor
2021-04-16 22:25 ` Junio C Hamano
2021-04-13 19:07 ` Ævar Arnfjörð Bjarmason
2020-04-16 21:18 ` [PATCH v13 2/5] bugreport: add tool to generate debugging info Emily Shaffer
2020-08-12 15:53 ` SZEDER Gábor
2021-04-08 21:36 ` SZEDER Gábor
2020-04-16 21:18 ` [PATCH v13 3/5] bugreport: gather git version and build info Emily Shaffer
2020-04-16 21:18 ` [PATCH v13 4/5] bugreport: add uname info Emily Shaffer
2021-04-08 22:19 ` Ævar Arnfjörð Bjarmason
2021-04-08 22:25 ` Junio C Hamano
2021-04-08 22:33 ` Ævar Arnfjörð Bjarmason
2021-04-08 23:41 ` Emily Shaffer
2021-04-08 23:58 ` Junio C Hamano
2021-04-09 21:27 ` SZEDER Gábor
2021-04-11 14:33 ` [PATCH] t0091-bugreport.sh: actually verify some content of report Martin Ågren
2021-04-12 17:17 ` Junio C Hamano
2021-04-13 18:32 ` Martin Ågren
2021-04-13 19:27 ` Ævar Arnfjörð Bjarmason
2021-04-13 22:21 ` Emily Shaffer
2023-07-01 19:26 ` [PATCH v2] " Martin Ågren
2023-07-03 15:47 ` Phillip Wood
2023-07-05 18:31 ` Martin Ågren
2023-07-05 18:40 ` [PATCH v3] " Martin Ågren
2023-07-05 19:46 ` Phillip Wood [this message]
2021-04-13 19:44 ` [PATCH] " SZEDER Gábor
2020-04-16 21:18 ` [PATCH v13 5/5] bugreport: add compiler info Emily Shaffer
2021-04-08 22:23 ` Ævar Arnfjörð Bjarmason
2021-04-08 22:59 ` Đoàn Trần Công Danh
[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
2023-07-05 19:54 ` Junio C Hamano
2023-07-07 12:26 ` Martin Ågren
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=161932f5-ae8f-cfaa-a6b0-ab140d0f002e@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=avarab@gmail.com \
--cc=emilyshaffer@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=martin.agren@gmail.com \
--cc=phillip.wood@dunelm.org.uk \
--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.
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).