From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
"Emily Shaffer" <emilyshaffer@google.com>,
"Eric Sunshine" <sunshine@sunshineco.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH v3 02/13] hook tests: turn exit code assertions into a loop
Date: Thu, 17 Mar 2022 11:13:07 +0100 [thread overview]
Message-ID: <patch-v3-02.13-aa4ee4da289-20220317T100820Z-avarab@gmail.com> (raw)
In-Reply-To: <cover-v3-00.13-00000000000-20220317T100820Z-avarab@gmail.com>
Amend a test added in 96e7225b310 (hook: add 'run' subcommand,
2021-12-22) to use a for-loop instead of a copy/pasting the same test
for the four exit codes we test.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
t/t1800-hook.sh | 35 ++++++++++-------------------------
1 file changed, 10 insertions(+), 25 deletions(-)
diff --git a/t/t1800-hook.sh b/t/t1800-hook.sh
index 93540b1fa12..26ed5e11bc8 100755
--- a/t/t1800-hook.sh
+++ b/t/t1800-hook.sh
@@ -53,31 +53,16 @@ test_expect_success 'git hook run: stdout and stderr both write to our stderr' '
test_must_be_empty stdout.actual
'
-test_expect_success 'git hook run: exit codes are passed along' '
- write_script .git/hooks/test-hook <<-EOF &&
- exit 1
- EOF
-
- test_expect_code 1 git hook run test-hook &&
-
- write_script .git/hooks/test-hook <<-EOF &&
- exit 2
- EOF
-
- test_expect_code 2 git hook run test-hook &&
-
- write_script .git/hooks/test-hook <<-EOF &&
- exit 128
- EOF
-
- test_expect_code 128 git hook run test-hook &&
-
- write_script .git/hooks/test-hook <<-EOF &&
- exit 129
- EOF
-
- test_expect_code 129 git hook run test-hook
-'
+for code in 1 2 128 129
+do
+ test_expect_success "git hook run: exit code $code is passed along" '
+ test_hook test-hook <<-EOF &&
+ exit $code
+ EOF
+
+ test_expect_code $code git hook run test-hook
+ '
+done
test_expect_success 'git hook run arg u ments without -- is not allowed' '
test_expect_code 129 git hook run test-hook arg u ments
--
2.35.1.1384.g7d2906948a1
next prev parent reply other threads:[~2022-03-17 10:13 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-02 13:22 [PATCH 00/10] tests: add and use a "test_hook" wrapper + hook fixes Ævar Arnfjörð Bjarmason
2022-03-02 13:22 ` [PATCH 01/10] hook tests: turn exit code assertions into a loop Ævar Arnfjörð Bjarmason
2022-03-02 20:55 ` Junio C Hamano
2022-03-02 13:22 ` [PATCH 02/10] t5540: don't rely on "hook/post-update.sample" Ævar Arnfjörð Bjarmason
2022-03-02 21:06 ` Junio C Hamano
2022-03-02 13:22 ` [PATCH 03/10] tests: assume the hooks are disabled by default Ævar Arnfjörð Bjarmason
2022-03-02 21:13 ` Junio C Hamano
2022-03-02 13:22 ` [PATCH 04/10] bugreport tests: tighten up "git bugreport -s hooks" test Ævar Arnfjörð Bjarmason
2022-03-02 21:22 ` Junio C Hamano
2022-03-02 13:22 ` [PATCH 05/10] tests: indent and add hook setup to "test_expect_success" Ævar Arnfjörð Bjarmason
2022-03-02 21:27 ` Junio C Hamano
2022-03-02 13:22 ` [PATCH 06/10] hook tests: get rid of unnecessary sub-shells Ævar Arnfjörð Bjarmason
2022-03-02 21:31 ` Junio C Hamano
2022-03-02 13:22 ` [PATCH 07/10] fetch+push tests: have tests clean up their own mess Ævar Arnfjörð Bjarmason
2022-03-02 21:44 ` Junio C Hamano
2022-03-02 13:22 ` [PATCH 08/10] test-lib-functions: add and use a "test_hook" wrapper Ævar Arnfjörð Bjarmason
2022-03-02 21:59 ` Junio C Hamano
2022-03-02 13:22 ` [PATCH 09/10] tests: change "mkdir -p && write_script" to use "test_hook" Ævar Arnfjörð Bjarmason
2022-03-02 22:06 ` Junio C Hamano
2022-03-02 13:22 ` [PATCH 10/10] tests: change "cat && chmod +x" " Ævar Arnfjörð Bjarmason
2022-03-03 5:46 ` Eric Sunshine
2022-03-02 22:38 ` [PATCH 00/10] tests: add and use a "test_hook" wrapper + hook fixes Junio C Hamano
2022-03-07 12:43 ` [PATCH v2 " Ævar Arnfjörð Bjarmason
2022-03-07 12:43 ` [PATCH v2 01/10] hook tests: turn exit code assertions into a loop Ævar Arnfjörð Bjarmason
2022-03-07 12:43 ` [PATCH v2 02/10] t5540: don't rely on "hook/post-update.sample" Ævar Arnfjörð Bjarmason
2022-03-07 12:43 ` [PATCH v2 03/10] tests: assume the hooks are disabled by default Ævar Arnfjörð Bjarmason
2022-03-07 12:43 ` [PATCH v2 04/10] bugreport tests: tighten up "git bugreport -s hooks" test Ævar Arnfjörð Bjarmason
2022-03-07 12:43 ` [PATCH v2 05/10] tests: indent and add hook setup to "test_expect_success" Ævar Arnfjörð Bjarmason
2022-03-07 12:43 ` [PATCH v2 06/10] hook tests: get rid of unnecessary sub-shells Ævar Arnfjörð Bjarmason
2022-03-07 12:43 ` [PATCH v2 07/10] fetch+push tests: have tests clean up their own mess Ævar Arnfjörð Bjarmason
2022-03-07 12:43 ` [PATCH v2 08/10] test-lib-functions: add and use a "test_hook" wrapper Ævar Arnfjörð Bjarmason
2022-03-07 12:43 ` [PATCH v2 09/10] tests: change "mkdir -p && write_script" to use "test_hook" Ævar Arnfjörð Bjarmason
2022-03-07 12:43 ` [PATCH v2 10/10] tests: change "cat && chmod +x" " Ævar Arnfjörð Bjarmason
2022-03-07 21:26 ` [PATCH v2 00/10] tests: add and use a "test_hook" wrapper + hook fixes Junio C Hamano
2022-03-17 10:13 ` [PATCH v3 00/13] " Ævar Arnfjörð Bjarmason
2022-03-17 10:13 ` [PATCH v3 01/13] test-lib-functions: add and use a "test_hook" wrapper Ævar Arnfjörð Bjarmason
2022-03-17 10:13 ` Ævar Arnfjörð Bjarmason [this message]
2022-03-17 10:13 ` [PATCH v3 03/13] http tests: don't rely on "hook/post-update.sample" Ævar Arnfjörð Bjarmason
2022-03-17 10:13 ` [PATCH v3 04/13] tests: assume the hooks are disabled by default Ævar Arnfjörð Bjarmason
2022-03-17 10:13 ` [PATCH v3 05/13] bugreport tests: tighten up "git bugreport -s hooks" test Ævar Arnfjörð Bjarmason
2022-03-17 10:13 ` [PATCH v3 06/13] fetch+push tests: use "test_hook" and "test_when_finished" pattern Ævar Arnfjörð Bjarmason
2022-03-17 10:13 ` [PATCH v3 07/13] gc + p4 tests: use "test_hook", remove sub-shells Ævar Arnfjörð Bjarmason
2022-03-17 10:13 ` [PATCH v3 08/13] tests: change "cat && chmod +x" to use "test_hook" Ævar Arnfjörð Bjarmason
2022-03-17 10:13 ` [PATCH v3 09/13] tests: change "mkdir -p && write_script" " Ævar Arnfjörð Bjarmason
2022-03-17 10:13 ` [PATCH v3 10/13] tests: use "test_hook" for misc "mkdir -p" and "chmod" cases Ævar Arnfjörð Bjarmason
2022-03-17 10:13 ` [PATCH v3 11/13] tests: extend "test_hook" for "rm" and "chmod -x", convert "$HOOK" Ævar Arnfjörð Bjarmason
2022-03-17 10:13 ` [PATCH v3 12/13] proc-receive hook tests: use "test_hook" instead of "write_script" Ævar Arnfjörð Bjarmason
2022-03-17 10:13 ` [PATCH v3 13/13] http tests: use "test_hook" for "smart" and "dumb" http tests Ævar Arnfjörð Bjarmason
2022-03-17 16:31 ` [PATCH v3 00/13] tests: add and use a "test_hook" wrapper + hook fixes Junio C Hamano
2022-03-17 21:04 ` Ævar Arnfjörð Bjarmason
2022-03-17 21:40 ` Junio C Hamano
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=patch-v3-02.13-aa4ee4da289-20220317T100820Z-avarab@gmail.com \
--to=avarab@gmail.com \
--cc=emilyshaffer@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sunshine@sunshineco.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).