diff mbox series

[v9,4/8] t2400: add tests to verify --quiet

Message ID 20230417093255.31079-5-jacobabel@nullpo.dev (mailing list archive)
State Superseded
Headers show
Series worktree: Support `--orphan` when creating new worktrees | expand

Commit Message

Jacob Abel April 17, 2023, 9:34 a.m. UTC
Add tests to verify that the command performs operations the same with
`--quiet` as without it. Additionally verifies that all non-fatal output
is suppressed.

Signed-off-by: Jacob Abel <jacobabel@nullpo.dev>
---
 t/t2400-worktree-add.sh | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

--
2.39.2

Comments

Junio C Hamano April 17, 2023, 9:33 p.m. UTC | #1
Jacob Abel <jacobabel@nullpo.dev> writes:

> +test_expect_success 'add --quiet -b' '
> +	test_when_finished "git branch -D quietnewbranch" &&
> +	test_when_finished "git worktree remove -f -f another-worktree" &&
> +	test_when_finished cat actual >&2 &&
> +	git worktree add --quiet -b quietnewbranch another-worktree 2>actual &&
> +	test_must_be_empty actual
> +'

It is good to test the --quiet option.  It is not good to have the
ineffective "cat actual" when test_must_be_empty is already used.
Probably the same comment applies to the rest of the patch.

Thanks.
Jacob Abel April 20, 2023, 2:48 a.m. UTC | #2
On 23/04/17 02:33PM, Junio C Hamano wrote:
> Jacob Abel <jacobabel@nullpo.dev> writes:
>
> > [...]
>
> It is good to test the --quiet option.  It is not good to have the
> ineffective "cat actual" when test_must_be_empty is already used.
> Probably the same comment applies to the rest of the patch.
>
> Thanks.

Understood. As mentioned in the patch 2/8 discussion, this change (the `cat
actual`) will be reverted in the next revision.
diff mbox series

Patch

diff --git a/t/t2400-worktree-add.sh b/t/t2400-worktree-add.sh
index 6822be4666..18831c4d93 100755
--- a/t/t2400-worktree-add.sh
+++ b/t/t2400-worktree-add.sh
@@ -336,6 +336,14 @@  test_expect_success 'add --quiet' '
 	test_must_be_empty actual
 '

+test_expect_success 'add --quiet -b' '
+	test_when_finished "git branch -D quietnewbranch" &&
+	test_when_finished "git worktree remove -f -f another-worktree" &&
+	test_when_finished cat actual >&2 &&
+	git worktree add --quiet -b quietnewbranch another-worktree 2>actual &&
+	test_must_be_empty actual
+'
+
 test_expect_success 'local clone from linked checkout' '
 	git clone --local here here-clone &&
 	( cd here-clone && git fsck )
@@ -534,6 +542,36 @@  test_expect_success 'git worktree add --guess-remote sets up tracking' '
 		test_cmp_rev refs/remotes/repo_a/foo refs/heads/foo
 	)
 '
+test_expect_success 'git worktree add --guess-remote sets up tracking (quiet)' '
+	test_when_finished rm -rf repo_a repo_b foo &&
+	test_when_finished cat repo_b/actual >&2 &&
+	setup_remote_repo repo_a repo_b &&
+	(
+		cd repo_b &&
+		git worktree add --quiet --guess-remote ../foo 2>actual &&
+		test_must_be_empty actual
+	) &&
+	(
+		cd foo &&
+		test_branch_upstream foo repo_a foo &&
+		test_cmp_rev refs/remotes/repo_a/foo refs/heads/foo
+	)
+'
+
+test_expect_success 'git worktree --no-guess-remote (quiet)' '
+	test_when_finished rm -rf repo_a repo_b foo &&
+	setup_remote_repo repo_a repo_b &&
+	(
+		cd repo_b &&
+		git worktree add --quiet --no-guess-remote ../foo
+	) &&
+	(
+		cd foo &&
+		test_must_fail git config "branch.foo.remote" &&
+		test_must_fail git config "branch.foo.merge" &&
+		test_cmp_rev ! refs/remotes/repo_a/foo refs/heads/foo
+	)
+'

 test_expect_success 'git worktree add with worktree.guessRemote sets up tracking' '
 	test_when_finished rm -rf repo_a repo_b foo &&