diff mbox series

[v2,1/7] t3416: tighten two tests

Message ID 12fb0ac6d5d932f9a8685d803ed017c357182768.1662561470.git.gitgitgadget@gmail.com (mailing list archive)
State Accepted
Commit 96601a26b4cdb2184b79b63aa670f695f5690183
Headers show
Series rebase --keep-base: imply --reapply-cherry-picks and --no-fork-point | expand

Commit Message

Phillip Wood Sept. 7, 2022, 2:37 p.m. UTC
From: Phillip Wood <phillip.wood@dunelm.org.uk>

Add a check for the correct error message to the tests that check we
require a single merge base so we can be sure the rebase failed for
the correct reason. Also rename the tests to reflect what they are
testing.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
---
 t/t3416-rebase-onto-threedots.sh | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Junio C Hamano Sept. 7, 2022, 6:12 p.m. UTC | #1
"Phillip Wood via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Phillip Wood <phillip.wood@dunelm.org.uk>
>
> Add a check for the correct error message to the tests that check we
> require a single merge base so we can be sure the rebase failed for
> the correct reason. Also rename the tests to reflect what they are
> testing.
>
> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
> ---

It is very sensible to ensure that a test that is expected to fail
does fail for the right reason, not by accident.  Looks good.

>  t/t3416-rebase-onto-threedots.sh | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/t/t3416-rebase-onto-threedots.sh b/t/t3416-rebase-onto-threedots.sh
> index 3e04802cb00..dc67d2308f3 100755
> --- a/t/t3416-rebase-onto-threedots.sh
> +++ b/t/t3416-rebase-onto-threedots.sh
> @@ -97,13 +97,14 @@ test_expect_success 'rebase -i --onto main...' '
>  	test_cmp expect actual
>  '
>  
> -test_expect_success 'rebase -i --onto main...side' '
> +test_expect_success 'rebase --onto main...side requires a single merge-base' '
>  	git reset --hard &&
>  	git checkout side &&
>  	git reset --hard K &&
>  
>  	set_fake_editor &&
> -	test_must_fail git rebase -i --onto main...side J
> +	test_must_fail git rebase -i --onto main...side J 2>err &&
> +	grep "need exactly one merge base" err
>  '
>  
>  test_expect_success 'rebase --keep-base --onto incompatible' '
> @@ -182,13 +183,14 @@ test_expect_success 'rebase -i --keep-base main topic from main' '
>  	test_cmp expect actual
>  '
>  
> -test_expect_success 'rebase -i --keep-base main from side' '
> +test_expect_success 'rebase --keep-base requires a single merge base' '
>  	git reset --hard &&
>  	git checkout side &&
>  	git reset --hard K &&
>  
>  	set_fake_editor &&
> -	test_must_fail git rebase -i --keep-base main
> +	test_must_fail git rebase -i --keep-base main 2>err &&
> +	grep "need exactly one merge base with branch" err
>  '
>  
>  test_done
diff mbox series

Patch

diff --git a/t/t3416-rebase-onto-threedots.sh b/t/t3416-rebase-onto-threedots.sh
index 3e04802cb00..dc67d2308f3 100755
--- a/t/t3416-rebase-onto-threedots.sh
+++ b/t/t3416-rebase-onto-threedots.sh
@@ -97,13 +97,14 @@  test_expect_success 'rebase -i --onto main...' '
 	test_cmp expect actual
 '
 
-test_expect_success 'rebase -i --onto main...side' '
+test_expect_success 'rebase --onto main...side requires a single merge-base' '
 	git reset --hard &&
 	git checkout side &&
 	git reset --hard K &&
 
 	set_fake_editor &&
-	test_must_fail git rebase -i --onto main...side J
+	test_must_fail git rebase -i --onto main...side J 2>err &&
+	grep "need exactly one merge base" err
 '
 
 test_expect_success 'rebase --keep-base --onto incompatible' '
@@ -182,13 +183,14 @@  test_expect_success 'rebase -i --keep-base main topic from main' '
 	test_cmp expect actual
 '
 
-test_expect_success 'rebase -i --keep-base main from side' '
+test_expect_success 'rebase --keep-base requires a single merge base' '
 	git reset --hard &&
 	git checkout side &&
 	git reset --hard K &&
 
 	set_fake_editor &&
-	test_must_fail git rebase -i --keep-base main
+	test_must_fail git rebase -i --keep-base main 2>err &&
+	grep "need exactly one merge base with branch" err
 '
 
 test_done