diff mbox series

[06/15] t3432: make these tests work with either am or merge backends

Message ID 9b1ad46c58b7f8397acbf2a8339e150dfb04c956.1576861788.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series rebase: make the default backend configurable | expand

Commit Message

Johannes Schindelin via GitGitGadget Dec. 20, 2019, 5:09 p.m. UTC
From: Elijah Newren <newren@gmail.com>

t3432 had several stress tests for can_fast_forward(), whose intent was
to ensure we were using the optimization of just fast forwarding when
possible.  However, these tests verified that fast forwards had happened
based on the output that rebase printed to the terminal.  We can instead
test more directly that we actually fast-forwarded by checking the
reflog, which also has the side effect of making the tests applicable
for the merge/interactive backend.

This change does lose the distinction between "noop" and "noop-force",
but as stated in commit c9efc216830f ("t3432: test for --no-ff's
interaction with fast-forward", 2019-08-27) which introduced that
distinction: "These tests aren't supposed to endorse the status quo,
just test for what we're currently doing.".

This change does not actually run these tests with the merge/interactive
backend; instead this is just a preparatory commit.  A subsequent commit
which fixes can_fast_forward() to work with that backend will then also
change t3432 to add tests of that backend as well.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 t/t3432-rebase-fast-forward.sh | 53 ++++++++++++++++------------------
 1 file changed, 25 insertions(+), 28 deletions(-)

Comments

Denton Liu Dec. 22, 2019, 5:11 a.m. UTC | #1
Hi Elijah,

On Fri, Dec 20, 2019 at 05:09:39PM +0000, Elijah Newren via GitGitGadget wrote:
> diff --git a/t/t3432-rebase-fast-forward.sh b/t/t3432-rebase-fast-forward.sh
> index 92f95b57da..3879a43fa0 100755
> --- a/t/t3432-rebase-fast-forward.sh
> +++ b/t/t3432-rebase-fast-forward.sh
> @@ -44,19 +44,16 @@ test_rebase_same_head_ () {
>  	test_expect_$status "git rebase$flag $* with $changes is $what with $cmp HEAD" "
>  		oldhead=\$(git rev-parse HEAD) &&
>  		test_when_finished 'git reset --hard \$oldhead' &&
> +		cp .git/logs/HEAD expect &&
>  		git rebase$flag $* >stdout &&
>  		if test $what = work
>  		then
> -			# Must check this case first, for 'is up to
> -			# date, rebase forced[...]rewinding head' cases
> -			test_i18ngrep 'rewinding head' stdout
> +			wc -l .git/logs/HEAD >old &&
> +			wc -l .git/logs/HEAD >new &&

Are the above two lines some yet-to-be cleaned up leftovers? I can't see
where `old` and `new` are being used elsewhere.

> +			test_line_count '-gt' $(($old + 2)) .git/logs/HEAD
>  		elif test $what = noop
>  		then
> -			test_i18ngrep 'is up to date' stdout &&
> -			test_i18ngrep ! 'rebase forced' stdout
> -		elif test $what = noop-force
> -		then
> -			test_i18ngrep 'is up to date, rebase forced' stdout
> +			test_cmp expect .git/logs/HEAD
>  		fi &&
>  		newhead=\$(git rev-parse HEAD) &&
>  		if test $cmp = same
Elijah Newren Dec. 23, 2019, 5:17 p.m. UTC | #2
On Sat, Dec 21, 2019 at 9:11 PM Denton Liu <liu.denton@gmail.com> wrote:
>
> Hi Elijah,
>
> On Fri, Dec 20, 2019 at 05:09:39PM +0000, Elijah Newren via GitGitGadget wrote:
> > diff --git a/t/t3432-rebase-fast-forward.sh b/t/t3432-rebase-fast-forward.sh
> > index 92f95b57da..3879a43fa0 100755
> > --- a/t/t3432-rebase-fast-forward.sh
> > +++ b/t/t3432-rebase-fast-forward.sh
> > @@ -44,19 +44,16 @@ test_rebase_same_head_ () {
> >       test_expect_$status "git rebase$flag $* with $changes is $what with $cmp HEAD" "
> >               oldhead=\$(git rev-parse HEAD) &&
> >               test_when_finished 'git reset --hard \$oldhead' &&
> > +             cp .git/logs/HEAD expect &&
> >               git rebase$flag $* >stdout &&
> >               if test $what = work
> >               then
> > -                     # Must check this case first, for 'is up to
> > -                     # date, rebase forced[...]rewinding head' cases
> > -                     test_i18ngrep 'rewinding head' stdout
> > +                     wc -l .git/logs/HEAD >old &&
> > +                     wc -l .git/logs/HEAD >new &&
>
> Are the above two lines some yet-to-be cleaned up leftovers? I can't see
> where `old` and `new` are being used elsewhere.

Um, this whole section is broken and causes it to pass the test for
stupid reasons.  Not sure how I bungled that so badly.  I'll send a
re-roll with a corrected 6/15.

>
> > +                     test_line_count '-gt' $(($old + 2)) .git/logs/HEAD
> >               elif test $what = noop
> >               then
> > -                     test_i18ngrep 'is up to date' stdout &&
> > -                     test_i18ngrep ! 'rebase forced' stdout
> > -             elif test $what = noop-force
> > -             then
> > -                     test_i18ngrep 'is up to date, rebase forced' stdout
> > +                     test_cmp expect .git/logs/HEAD
> >               fi &&
> >               newhead=\$(git rev-parse HEAD) &&
> >               if test $cmp = same
diff mbox series

Patch

diff --git a/t/t3432-rebase-fast-forward.sh b/t/t3432-rebase-fast-forward.sh
index 92f95b57da..3879a43fa0 100755
--- a/t/t3432-rebase-fast-forward.sh
+++ b/t/t3432-rebase-fast-forward.sh
@@ -44,19 +44,16 @@  test_rebase_same_head_ () {
 	test_expect_$status "git rebase$flag $* with $changes is $what with $cmp HEAD" "
 		oldhead=\$(git rev-parse HEAD) &&
 		test_when_finished 'git reset --hard \$oldhead' &&
+		cp .git/logs/HEAD expect &&
 		git rebase$flag $* >stdout &&
 		if test $what = work
 		then
-			# Must check this case first, for 'is up to
-			# date, rebase forced[...]rewinding head' cases
-			test_i18ngrep 'rewinding head' stdout
+			wc -l .git/logs/HEAD >old &&
+			wc -l .git/logs/HEAD >new &&
+			test_line_count '-gt' $(($old + 2)) .git/logs/HEAD
 		elif test $what = noop
 		then
-			test_i18ngrep 'is up to date' stdout &&
-			test_i18ngrep ! 'rebase forced' stdout
-		elif test $what = noop-force
-		then
-			test_i18ngrep 'is up to date, rebase forced' stdout
+			test_cmp expect .git/logs/HEAD
 		fi &&
 		newhead=\$(git rev-parse HEAD) &&
 		if test $cmp = same
@@ -71,14 +68,14 @@  test_rebase_same_head_ () {
 
 changes='no changes'
 test_rebase_same_head success noop same success work same
-test_rebase_same_head success noop same success noop-force same master
-test_rebase_same_head success noop same success noop-force diff --onto B B
-test_rebase_same_head success noop same success noop-force diff --onto B... B
-test_rebase_same_head success noop same success noop-force same --onto master... master
-test_rebase_same_head success noop same success noop-force same --keep-base master
-test_rebase_same_head success noop same success noop-force same --keep-base
-test_rebase_same_head success noop same success noop-force same --no-fork-point
-test_rebase_same_head success noop same success noop-force same --keep-base --no-fork-point
+test_rebase_same_head success noop same success work same master
+test_rebase_same_head success noop same success work diff --onto B B
+test_rebase_same_head success noop same success work diff --onto B... B
+test_rebase_same_head success noop same success work same --onto master... master
+test_rebase_same_head success noop same success work same --keep-base master
+test_rebase_same_head success noop same success work same --keep-base
+test_rebase_same_head success noop same success work same --no-fork-point
+test_rebase_same_head success noop same success work same --keep-base --no-fork-point
 test_rebase_same_head success noop same success work same --fork-point master
 test_rebase_same_head success noop same success work diff --fork-point --onto B B
 test_rebase_same_head success noop same success work diff --fork-point --onto B... B
@@ -91,14 +88,14 @@  test_expect_success 'add work same to side' '
 
 changes='our changes'
 test_rebase_same_head success noop same success work same
-test_rebase_same_head success noop same success noop-force same master
-test_rebase_same_head success noop same success noop-force diff --onto B B
-test_rebase_same_head success noop same success noop-force diff --onto B... B
-test_rebase_same_head success noop same success noop-force same --onto master... master
-test_rebase_same_head success noop same success noop-force same --keep-base master
-test_rebase_same_head success noop same success noop-force same --keep-base
-test_rebase_same_head success noop same success noop-force same --no-fork-point
-test_rebase_same_head success noop same success noop-force same --keep-base --no-fork-point
+test_rebase_same_head success noop same success work same master
+test_rebase_same_head success noop same success work diff --onto B B
+test_rebase_same_head success noop same success work diff --onto B... B
+test_rebase_same_head success noop same success work same --onto master... master
+test_rebase_same_head success noop same success work same --keep-base master
+test_rebase_same_head success noop same success work same --keep-base
+test_rebase_same_head success noop same success work same --no-fork-point
+test_rebase_same_head success noop same success work same --keep-base --no-fork-point
 test_rebase_same_head success noop same success work same --fork-point master
 test_rebase_same_head success noop same success work diff --fork-point --onto B B
 test_rebase_same_head success noop same success work diff --fork-point --onto B... B
@@ -112,13 +109,13 @@  test_expect_success 'add work same to upstream' '
 '
 
 changes='our and their changes'
-test_rebase_same_head success noop same success noop-force diff --onto B B
-test_rebase_same_head success noop same success noop-force diff --onto B... B
+test_rebase_same_head success noop same success work diff --onto B B
+test_rebase_same_head success noop same success work diff --onto B... B
 test_rebase_same_head success noop same success work diff --onto master... master
 test_rebase_same_head success noop same success work diff --keep-base master
 test_rebase_same_head success noop same success work diff --keep-base
-test_rebase_same_head failure work same success work diff --fork-point --onto B B
-test_rebase_same_head failure work same success work diff --fork-point --onto B... B
+test_rebase_same_head success work same success work diff --fork-point --onto B B
+test_rebase_same_head success work same success work diff --fork-point --onto B... B
 test_rebase_same_head success noop same success work diff --fork-point --onto master... master
 test_rebase_same_head success noop same success work diff --fork-point --keep-base master