Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2022-03-17 13:13:10 +0300
committerJunio C Hamano <gitster@pobox.com>2022-03-17 18:40:26 +0300
commit003cdf8882fe9a57a056ab91d2dd9088624c01a2 (patch)
tree548180e1aaf2d920fd18e5ea7c1c08e59523e93d /t/t0091-bugreport.sh
parentee32abda28299bfb03e1c3239b95182579569012 (diff)
bugreport tests: tighten up "git bugreport -s hooks" test
Amend a test added in 788a776069b (bugreport: collect list of populated hooks, 2020-05-07) to "test_cmp" for the expected output, instead of selectively using "grep" to check for specific things we either expect or don't expect in the output. As noted in a preceding commit our .git/hooks directory already contains *.sample hooks, so we have no need to clobber the prepare-commit-msg.sample hook in particular. Instead we should assert that those *.sample hooks are not included in the output, and for good measure let's add a new "unknown-hook", to check that we only look through our own known hooks. See cfe853e66be (hook-list.h: add a generated list of hooks, like config-list.h, 2021-09-26) for how we generate that data. We're intentionally not piping the "actual" output through "sort" or similar, we'd also like to check that our reported hooks are sorted. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t0091-bugreport.sh')
-rwxr-xr-xt/t0091-bugreport.sh26
1 files changed, 15 insertions, 11 deletions
diff --git a/t/t0091-bugreport.sh b/t/t0091-bugreport.sh
index eeedbfa919..08f5fe9cae 100755
--- a/t/t0091-bugreport.sh
+++ b/t/t0091-bugreport.sh
@@ -60,18 +60,22 @@ test_expect_success 'can create leading directories outside of a git dir' '
test_expect_success 'indicates populated hooks' '
test_when_finished rm git-bugreport-hooks.txt &&
- test_when_finished rm -fr .git/hooks &&
- rm -fr .git/hooks &&
- mkdir .git/hooks &&
- for hook in applypatch-msg prepare-commit-msg.sample
- do
- write_script ".git/hooks/$hook" <<-EOF || return 1
- echo "hook $hook exists"
- EOF
- done &&
+
+ test_hook applypatch-msg <<-\EOF &&
+ true
+ EOF
+ test_hook unknown-hook <<-\EOF &&
+ true
+ EOF
git bugreport -s hooks &&
- grep applypatch-msg git-bugreport-hooks.txt &&
- ! grep prepare-commit-msg git-bugreport-hooks.txt
+
+ sort >expect <<-\EOF &&
+ [Enabled Hooks]
+ applypatch-msg
+ EOF
+
+ sed -ne "/^\[Enabled Hooks\]$/,/^$/p" <git-bugreport-hooks.txt >actual &&
+ test_cmp expect actual
'
test_done