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

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

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Apr 13, 2021, 19:44 UTC
Message-ID
<20210413194415.GK2947267@szeder.dev>
In-Reply-To
<20210411143354.25134-1-martin.agren@gmail.com>
On Sun, Apr 11, 2021 at 04:33:54PM +0200, Martin Ågren wrote:
Show 43 quoted lines
> 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.31.1.164.g984c2561cd: No such file
> 
> 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 grep for some contents that we expect to find in a bug
> report. We won't verify that they appear in the right order, but at
> least we end up verifying the contents more than before this commit.
> 
> Reported-by: SZEDER Gábor <szeder.dev@gmail.com>
> Signed-off-by: Martin Ågren <martin.agren@gmail.com>
> ---
>  > It does scare me..
> 
>  Maybe something like this?
Thanks!
Show 36 quoted lines
>  t/t0091-bugreport.sh | 26 +++++---------------------
>  1 file changed, 5 insertions(+), 21 deletions(-)
> 
> diff --git a/t/t0091-bugreport.sh b/t/t0091-bugreport.sh
> index 526304ff95..9111c4c26f 100755
> --- a/t/t0091-bugreport.sh
> +++ b/t/t0091-bugreport.sh
> @@ -4,29 +4,13 @@ test_description='git bugreport'
>  
>  . ./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_expect_success 'creates a report with content' '
>  	test_when_finished rm git-bugreport-check-headers.txt &&
>  	git bugreport -s check-headers &&
> -	check_all_headers_populated <git-bugreport-check-headers.txt
> +	grep "^Please answer " git-bugreport-check-headers.txt &&

This "Please answer" is translated and you look for it with plain 'grep' instead of 'test_i18ngrep', which is fine nowadays... However, Junio queued this patch on top of v2.29.3, which is old enough to still have the GETTEXT_POISON CI job, and fails because of this.

> +	grep "^\[System Info\]$" git-bugreport-check-headers.txt &&
> +	grep "^git version:$" git-bugreport-check-headers.txt &&
> +	grep "^\[Enabled Hooks\]$" git-bugreport-check-headers.txt
>  '
I have to wonder, however, whether this is worth testing at all.
Show 5 quoted lines
>  
>  test_expect_success 'dies if file with same name as report already exists' '
> -- 
> 2.31.1.163.ga65ce7f831
> 
Previous: Phillip WoodNext: Emily Shaffer
Message 36 of 40 in “git-bugreport with fixed VS build”
  1. 0/5 git-bugreport with fixed VS buildEmily Shaffer, Apr 16, 2020
  2. 1/5 help: move list_config_help to builtin/helpEmily Shaffer, Apr 16, 2020
  3. Junio C HamanoApr 16, 2020
  4. Junio C HamanoApr 16, 2020
  5. Emily ShafferApr 17, 2020
  6. Danh DoanApr 17, 2020
  7. Danh DoanApr 17, 2020
  8. Makefile: add missing dependencies of 'config-list.h'SZEDER Gábor, Apr 8, 2021
  9. Ævar Arnfjörð BjarmasonApr 8, 2021
  10. Jeff KingApr 8, 2021
  11. SZEDER GáborApr 9, 2021
  12. Junio C HamanoApr 16, 2021
  13. SZEDER GáborApr 16, 2021
  14. Junio C HamanoApr 16, 2021
  15. Ævar Arnfjörð BjarmasonApr 13, 2021
  16. 2/5 bugreport: add tool to generate debugging infoEmily Shaffer, Apr 16, 2020
  17. SZEDER GáborAug 12, 2020
  18. SZEDER GáborApr 8, 2021
  19. 4/5 bugreport: add uname infoEmily Shaffer, Apr 16, 2020
  20. Ævar Arnfjörð BjarmasonApr 8, 2021
  21. Junio C HamanoApr 8, 2021
  22. Ævar Arnfjörð BjarmasonApr 8, 2021
  23. Emily ShafferApr 8, 2021
  24. Junio C HamanoApr 8, 2021
  25. SZEDER GáborApr 9, 2021
  26. t0091-bugreport.sh: actually verify some content of reportMartin Ågren, Apr 11, 2021
  27. Junio C HamanoApr 12, 2021
  28. Martin ÅgrenApr 13, 2021
  29. Ævar Arnfjörð BjarmasonApr 13, 2021
  30. Emily ShafferApr 13, 2021
  31. t0091-bugreport.sh: actually verify some content of reportMartin Ågren, Jul 1, 2023
  32. Phillip WoodJul 3, 2023
  33. Martin ÅgrenJul 5, 2023
  34. t0091-bugreport.sh: actually verify some content of reportMartin Ågren, Jul 5, 2023
  35. Phillip WoodJul 5, 2023
  36. SZEDER GáborApr 13, 2021
  37. 3/5 bugreport: gather git version and build infoEmily Shaffer, Apr 16, 2020
  38. 5/5 bugreport: add compiler infoEmily Shaffer, Apr 16, 2020
  39. Ævar Arnfjörð BjarmasonApr 8, 2021
  40. Đoàn Trần Công DanhApr 8, 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.