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.