* [PATCH v10 3/8] t2400: refactor "worktree add" opt exclusion tests
@ 2023-05-07 12:06 Jacob Abel
0 siblings, 0 replies; only message in thread
From: Jacob Abel @ 2023-05-07 12:06 UTC (permalink / raw)
To: git
Cc: Jacob Abel, Ævar Arnfjörð Bjarmason, Eric Sunshine,
Junio C Hamano, Phillip Wood, Rubén Justo, Taylor Blau,
rsbecker
Pull duplicate test code into a function so that additional opt
combinations can be tested succinctly.
Signed-off-by: Jacob Abel <jacobabel@nullpo.dev>
---
t/t2400-worktree-add.sh | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/t/t2400-worktree-add.sh b/t/t2400-worktree-add.sh
index a3f108347a..0ca3ec2022 100755
--- a/t/t2400-worktree-add.sh
+++ b/t/t2400-worktree-add.sh
@@ -298,17 +298,20 @@ test_expect_success '"add" no auto-vivify with --detach and <branch> omitted' '
test_must_fail git -C mish/mash symbolic-ref HEAD
'
-test_expect_success '"add" -b/-B mutually exclusive' '
- test_must_fail git worktree add -b poodle -B poodle bamboo main
-'
-
-test_expect_success '"add" -b/--detach mutually exclusive' '
- test_must_fail git worktree add -b poodle --detach bamboo main
-'
+# Helper function to test mutually exclusive options.
+#
+# Note: Quoted arguments containing spaces are not supported.
+test_wt_add_excl () {
+ local opts="$*" &&
+ test_expect_success "'worktree add' with '$opts' has mutually exclusive options" '
+ test_must_fail git worktree add $opts 2>actual &&
+ grep -E "fatal:( options)? .* cannot be used together" actual
+ '
+}
-test_expect_success '"add" -B/--detach mutually exclusive' '
- test_must_fail git worktree add -B poodle --detach bamboo main
-'
+test_wt_add_excl -b poodle -B poodle bamboo main
+test_wt_add_excl -b poodle --detach bamboo main
+test_wt_add_excl -B poodle --detach bamboo main
test_expect_success '"add -B" fails if the branch is checked out' '
git rev-parse newmain >before &&
--
2.39.3
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-05-07 12:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-07 12:06 [PATCH v10 3/8] t2400: refactor "worktree add" opt exclusion tests Jacob Abel
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).