diff mbox series

[v6,2/2] t3404: employing test_line_count() to replace test

Message ID b3d3deced25f038defe6afe7d474350464328299.1728299466.git.gitgitgadget@gmail.com (mailing list archive)
State Superseded
Headers show
Series t3404: avoid losing exit status to pipes | expand

Commit Message

Usman Akinyemi Oct. 7, 2024, 11:11 a.m. UTC
From: Usman Akinyemi <usmanakinyemi202@gmail.com>

Refactor t3404 to replace instances of `test` with `test_line_count()`
for checking line counts. This improves readability and aligns with Git's
current test practices.

Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
 t/t3404-rebase-interactive.sh | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

Comments

Phillip Wood Oct. 7, 2024, 3:07 p.m. UTC | #1
Hi Usman

I missed this when I read the earlier version of this series but our 
commit subjects use the imperative so we would say

     t3403: employ test_line_count() to replace test

or

     t3404: replace test with test_line_count()

I agree with Patrick that we should let this series settle for a couple 
of days to allow others to comment before sending any new version.

This series is looking good, congratulations

Phillip

On 07/10/2024 12:11, Usman Akinyemi via GitGitGadget wrote:
> From: Usman Akinyemi <usmanakinyemi202@gmail.com>
> 
> Refactor t3404 to replace instances of `test` with `test_line_count()`
> for checking line counts. This improves readability and aligns with Git's
> current test practices.
> 
> Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
> ---
>   t/t3404-rebase-interactive.sh | 28 ++++++++++++++--------------
>   1 file changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
> index 96a65783c47..2ab660ef30f 100755
> --- a/t/t3404-rebase-interactive.sh
> +++ b/t/t3404-rebase-interactive.sh
> @@ -281,8 +281,9 @@ test_expect_success 'stop on conflicting pick' '
>   	test_cmp expect2 file1 &&
>   	test "$(git diff --name-status |
>   		sed -n -e "/^U/s/^U[^a-z]*//p")" = file1 &&
> -	test 4 = $(grep -v "^#" < .git/rebase-merge/done | wc -l) &&
> -	test 0 = $(grep -c "^[^#]" < .git/rebase-merge/git-rebase-todo)
> +	grep -v "^#" <.git/rebase-merge/done >actual &&
> +	test_line_count = 4 actual &&
> +	test 0 = $(grep -c "^[^#]" <.git/rebase-merge/git-rebase-todo)
>   '
>   
>   test_expect_success 'show conflicted patch' '
> @@ -401,8 +402,8 @@ test_expect_success 'multi-squash only fires up editor once' '
>   	) &&
>   	test $base = $(git rev-parse HEAD^) &&
>   	git show >output &&
> -	count=$(grep ONCE output | wc -l) &&
> -	test 1 = $count
> +	grep ONCE output >actual &&
> +	test_line_count = 1 actual
>   '
>   
>   test_expect_success 'multi-fixup does not fire up editor' '
> @@ -416,8 +417,7 @@ test_expect_success 'multi-fixup does not fire up editor' '
>   	) &&
>   	test $base = $(git rev-parse HEAD^) &&
>   	git show >output &&
> -	count=$(grep NEVER output | wc -l) &&
> -	test 0 = $count &&
> +	! grep NEVER output &&
>   	git checkout @{-1} &&
>   	git branch -D multi-fixup
>   '
> @@ -436,8 +436,8 @@ test_expect_success 'commit message used after conflict' '
>   	) &&
>   	test $base = $(git rev-parse HEAD^) &&
>   	git show >output &&
> -	count=$(grep ONCE output | wc -l) &&
> -	test 1 = $count &&
> +	grep ONCE output >actual &&
> +	test_line_count = 1 actual &&
>   	git checkout @{-1} &&
>   	git branch -D conflict-fixup
>   '
> @@ -456,8 +456,8 @@ test_expect_success 'commit message retained after conflict' '
>   	) &&
>   	test $base = $(git rev-parse HEAD^) &&
>   	git show >output &&
> -	count=$(grep TWICE output | wc -l) &&
> -	test 2 = $count &&
> +	grep TWICE output >actual &&
> +	test_line_count = 2 actual &&
>   	git checkout @{-1} &&
>   	git branch -D conflict-squash
>   '
> @@ -501,8 +501,8 @@ test_expect_success 'squash ignores comments' '
>   	) &&
>   	test $base = $(git rev-parse HEAD^) &&
>   	git show >output &&
> -	count=$(grep ONCE output | wc -l) &&
> -	test 1 = $count &&
> +	grep ONCE output >actual &&
> +	test_line_count = 1 actual &&
>   	git checkout @{-1} &&
>   	git branch -D skip-comments
>   '
> @@ -519,8 +519,8 @@ test_expect_success 'squash ignores blank lines' '
>   	) &&
>   	test $base = $(git rev-parse HEAD^) &&
>   	git show >output &&
> -	count=$(grep ONCE output | wc -l) &&
> -	test 1 = $count &&
> +	grep ONCE output >actual &&
> +	test_line_count = 1 actual &&
>   	git checkout @{-1} &&
>   	git branch -D skip-blank-lines
>   '
Usman Akinyemi Oct. 7, 2024, 3:32 p.m. UTC | #2
On Mon, Oct 7, 2024 at 3:07 PM Phillip Wood <phillip.wood123@gmail.com> wrote:
>
> Hi Usman
>
> I missed this when I read the earlier version of this series but our
> commit subjects use the imperative so we would say
>
>      t3403: employ test_line_count() to replace test
>
> or
>
>      t3404: replace test with test_line_count()
>
Thanks for the review. I just improved the commit subject now.
> I agree with Patrick that we should let this series settle for a couple
> of days to allow others to comment before sending any new version.
>
> This series is looking good, congratulations
Thanks Philip.
>
> Phillip
>
> On 07/10/2024 12:11, Usman Akinyemi via GitGitGadget wrote:
> > From: Usman Akinyemi <usmanakinyemi202@gmail.com>
> >
> > Refactor t3404 to replace instances of `test` with `test_line_count()`
> > for checking line counts. This improves readability and aligns with Git's
> > current test practices.
> >
> > Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
> > ---
> >   t/t3404-rebase-interactive.sh | 28 ++++++++++++++--------------
> >   1 file changed, 14 insertions(+), 14 deletions(-)
> >
> > diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
> > index 96a65783c47..2ab660ef30f 100755
> > --- a/t/t3404-rebase-interactive.sh
> > +++ b/t/t3404-rebase-interactive.sh
> > @@ -281,8 +281,9 @@ test_expect_success 'stop on conflicting pick' '
> >       test_cmp expect2 file1 &&
> >       test "$(git diff --name-status |
> >               sed -n -e "/^U/s/^U[^a-z]*//p")" = file1 &&
> > -     test 4 = $(grep -v "^#" < .git/rebase-merge/done | wc -l) &&
> > -     test 0 = $(grep -c "^[^#]" < .git/rebase-merge/git-rebase-todo)
> > +     grep -v "^#" <.git/rebase-merge/done >actual &&
> > +     test_line_count = 4 actual &&
> > +     test 0 = $(grep -c "^[^#]" <.git/rebase-merge/git-rebase-todo)
> >   '
> >
> >   test_expect_success 'show conflicted patch' '
> > @@ -401,8 +402,8 @@ test_expect_success 'multi-squash only fires up editor once' '
> >       ) &&
> >       test $base = $(git rev-parse HEAD^) &&
> >       git show >output &&
> > -     count=$(grep ONCE output | wc -l) &&
> > -     test 1 = $count
> > +     grep ONCE output >actual &&
> > +     test_line_count = 1 actual
> >   '
> >
> >   test_expect_success 'multi-fixup does not fire up editor' '
> > @@ -416,8 +417,7 @@ test_expect_success 'multi-fixup does not fire up editor' '
> >       ) &&
> >       test $base = $(git rev-parse HEAD^) &&
> >       git show >output &&
> > -     count=$(grep NEVER output | wc -l) &&
> > -     test 0 = $count &&
> > +     ! grep NEVER output &&
> >       git checkout @{-1} &&
> >       git branch -D multi-fixup
> >   '
> > @@ -436,8 +436,8 @@ test_expect_success 'commit message used after conflict' '
> >       ) &&
> >       test $base = $(git rev-parse HEAD^) &&
> >       git show >output &&
> > -     count=$(grep ONCE output | wc -l) &&
> > -     test 1 = $count &&
> > +     grep ONCE output >actual &&
> > +     test_line_count = 1 actual &&
> >       git checkout @{-1} &&
> >       git branch -D conflict-fixup
> >   '
> > @@ -456,8 +456,8 @@ test_expect_success 'commit message retained after conflict' '
> >       ) &&
> >       test $base = $(git rev-parse HEAD^) &&
> >       git show >output &&
> > -     count=$(grep TWICE output | wc -l) &&
> > -     test 2 = $count &&
> > +     grep TWICE output >actual &&
> > +     test_line_count = 2 actual &&
> >       git checkout @{-1} &&
> >       git branch -D conflict-squash
> >   '
> > @@ -501,8 +501,8 @@ test_expect_success 'squash ignores comments' '
> >       ) &&
> >       test $base = $(git rev-parse HEAD^) &&
> >       git show >output &&
> > -     count=$(grep ONCE output | wc -l) &&
> > -     test 1 = $count &&
> > +     grep ONCE output >actual &&
> > +     test_line_count = 1 actual &&
> >       git checkout @{-1} &&
> >       git branch -D skip-comments
> >   '
> > @@ -519,8 +519,8 @@ test_expect_success 'squash ignores blank lines' '
> >       ) &&
> >       test $base = $(git rev-parse HEAD^) &&
> >       git show >output &&
> > -     count=$(grep ONCE output | wc -l) &&
> > -     test 1 = $count &&
> > +     grep ONCE output >actual &&
> > +     test_line_count = 1 actual &&
> >       git checkout @{-1} &&
> >       git branch -D skip-blank-lines
> >   '
>
diff mbox series

Patch

diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 96a65783c47..2ab660ef30f 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -281,8 +281,9 @@  test_expect_success 'stop on conflicting pick' '
 	test_cmp expect2 file1 &&
 	test "$(git diff --name-status |
 		sed -n -e "/^U/s/^U[^a-z]*//p")" = file1 &&
-	test 4 = $(grep -v "^#" < .git/rebase-merge/done | wc -l) &&
-	test 0 = $(grep -c "^[^#]" < .git/rebase-merge/git-rebase-todo)
+	grep -v "^#" <.git/rebase-merge/done >actual &&
+	test_line_count = 4 actual &&
+	test 0 = $(grep -c "^[^#]" <.git/rebase-merge/git-rebase-todo)
 '
 
 test_expect_success 'show conflicted patch' '
@@ -401,8 +402,8 @@  test_expect_success 'multi-squash only fires up editor once' '
 	) &&
 	test $base = $(git rev-parse HEAD^) &&
 	git show >output &&
-	count=$(grep ONCE output | wc -l) &&
-	test 1 = $count
+	grep ONCE output >actual &&
+	test_line_count = 1 actual
 '
 
 test_expect_success 'multi-fixup does not fire up editor' '
@@ -416,8 +417,7 @@  test_expect_success 'multi-fixup does not fire up editor' '
 	) &&
 	test $base = $(git rev-parse HEAD^) &&
 	git show >output &&
-	count=$(grep NEVER output | wc -l) &&
-	test 0 = $count &&
+	! grep NEVER output &&
 	git checkout @{-1} &&
 	git branch -D multi-fixup
 '
@@ -436,8 +436,8 @@  test_expect_success 'commit message used after conflict' '
 	) &&
 	test $base = $(git rev-parse HEAD^) &&
 	git show >output &&
-	count=$(grep ONCE output | wc -l) &&
-	test 1 = $count &&
+	grep ONCE output >actual &&
+	test_line_count = 1 actual &&
 	git checkout @{-1} &&
 	git branch -D conflict-fixup
 '
@@ -456,8 +456,8 @@  test_expect_success 'commit message retained after conflict' '
 	) &&
 	test $base = $(git rev-parse HEAD^) &&
 	git show >output &&
-	count=$(grep TWICE output | wc -l) &&
-	test 2 = $count &&
+	grep TWICE output >actual &&
+	test_line_count = 2 actual &&
 	git checkout @{-1} &&
 	git branch -D conflict-squash
 '
@@ -501,8 +501,8 @@  test_expect_success 'squash ignores comments' '
 	) &&
 	test $base = $(git rev-parse HEAD^) &&
 	git show >output &&
-	count=$(grep ONCE output | wc -l) &&
-	test 1 = $count &&
+	grep ONCE output >actual &&
+	test_line_count = 1 actual &&
 	git checkout @{-1} &&
 	git branch -D skip-comments
 '
@@ -519,8 +519,8 @@  test_expect_success 'squash ignores blank lines' '
 	) &&
 	test $base = $(git rev-parse HEAD^) &&
 	git show >output &&
-	count=$(grep ONCE output | wc -l) &&
-	test 1 = $count &&
+	grep ONCE output >actual &&
+	test_line_count = 1 actual &&
 	git checkout @{-1} &&
 	git branch -D skip-blank-lines
 '