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

[PATCH v9 3/8] t2400: refactor "worktree add" opt exclusion tests

From
Jacob Abel <jacobabel@nullpo.dev>
Date
Apr 17, 2023, 09:33 UTC
Message-ID
<20230417093255.31079-4-jacobabel@nullpo.dev>
In-Reply-To
<20230417093255.31079-1-jacobabel@nullpo.dev>

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 | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/t/t2400-worktree-add.sh b/t/t2400-worktree-add.sh
index 9bc3db20e4..6822be4666 100755
--- a/t/t2400-worktree-add.sh
+++ b/t/t2400-worktree-add.sh
@@ -298,17 +298,21 @@ 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_when_finished cat actual >&2 &&
+		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.2
Previous: Jacob AbelNext: Junio C Hamano
Message 16 of 34 in “worktree: Support `--orphan` when creating new worktrees”
  1. 0/8 worktree: Support `--orphan` when creating new worktreesJacob Abel, Apr 17, 2023
  2. 1/8 worktree add: include -B in usage docsJacob Abel, Apr 17, 2023
  3. 2/8 t2400: print captured git output when finishedJacob Abel, Apr 17, 2023
  4. Junio C HamanoApr 17, 2023
  5. Jacob AbelApr 18, 2023
  6. Junio C HamanoApr 18, 2023
  7. Jacob AbelApr 19, 2023
  8. Jacob AbelApr 19, 2023
  9. Junio C HamanoApr 19, 2023
  10. Jacob AbelApr 19, 2023
  11. 4/8 t2400: add tests to verify --quietJacob Abel, Apr 17, 2023
  12. Junio C HamanoApr 17, 2023
  13. Jacob AbelApr 20, 2023
  14. 5/8 worktree add: add --orphan flagJacob Abel, Apr 17, 2023
  15. 7/8 worktree add: extend DWIM to infer --orphanJacob Abel, Apr 17, 2023
  16. 3/8 t2400: refactor "worktree add" opt exclusion testsJacob Abel, Apr 17, 2023
  17. Junio C HamanoApr 17, 2023
  18. Jacob AbelApr 20, 2023
  19. 6/8 worktree add: introduce "try --orphan" hintJacob Abel, Apr 17, 2023
  20. 8/8 worktree add: emit warn when there is a bad HEADJacob Abel, Apr 17, 2023
  21. Jacob AbelApr 20, 2023
  22. Junio C HamanoMay 1, 2023
  23. Jacob AbelMay 2, 2023
  24. 0/8 worktree: Support `--orphan` when creating new worktreesJacob Abel, May 17, 2023
  25. 1/8 worktree add: include -B in usage docsJacob Abel, May 17, 2023
  26. 2/8 t2400: cleanup created worktree in testJacob Abel, May 17, 2023
  27. 3/8 t2400: refactor "worktree add" opt exclusion testsJacob Abel, May 17, 2023
  28. 4/8 t2400: add tests to verify --quietJacob Abel, May 17, 2023
  29. 6/8 worktree add: introduce "try --orphan" hintJacob Abel, May 17, 2023
  30. 5/8 worktree add: add --orphan flagJacob Abel, May 17, 2023
  31. 7/8 worktree add: extend DWIM to infer --orphanJacob Abel, May 17, 2023
  32. RESEND [PATCH v10 7/8] worktree add: extend DWIM to infer --orphanTeng Long, Aug 9, 2023
  33. Jacob AbelAug 11, 2023
  34. 8/8 worktree add: emit warn when there is a bad HEADJacob Abel, May 17, 2023

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.