diff mbox series

[3/4] t6400: use test_line_count_cmd to count # of lines in stdout

Message ID 20210612042755.28342-4-congdanhqx@gmail.com (mailing list archive)
State Superseded
Headers show
Series t: new helper test_line_count_cmd | expand

Commit Message

Đoàn Trần Công Danh June 12, 2021, 4:27 a.m. UTC
Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 t/t6400-merge-df.sh | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Bagas Sanjaya June 12, 2021, 4:33 a.m. UTC | #1
Hi Đoàn,

> -	test 5 -eq $(git ls-files -s | wc -l) &&
> -	test 4 -eq $(git ls-files -u | wc -l) &&
> +	test_line_count_cmd --out = 5 git ls-files -s &&
> +	test_line_count_cmd --out = 4 git ls-files -u  &&

I read lines above as "Formerly I tested that 5/4 should be equal to 
output of git ls-files -s/-u piped to wc -l, now I do the same with 
test_line_count_cmd".

Am I right?
Eric Sunshine June 13, 2021, 3:39 a.m. UTC | #2
On Sat, Jun 12, 2021 at 12:28 AM Đoàn Trần Công Danh
<congdanhqx@gmail.com> wrote:
>
> Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
> ---
> diff --git a/t/t6400-merge-df.sh b/t/t6400-merge-df.sh
> @@ -82,13 +82,13 @@ test_expect_success 'modify/delete + directory/file conflict' '
> -       test 5 -eq $(git ls-files -s | wc -l) &&
> -       test 4 -eq $(git ls-files -u | wc -l) &&
> +       test_line_count_cmd --out = 5 git ls-files -s &&
> +       test_line_count_cmd --out = 4 git ls-files -u  &&

Nit: too many spaces before the `&&` on the second line: s/\s+/ /

> @@ -103,13 +103,13 @@ test_expect_success 'modify/delete + directory/file conflict; other way' '
> -       test 5 -eq $(git ls-files -s | wc -l) &&
> -       test 4 -eq $(git ls-files -u | wc -l) &&
> +       test_line_count_cmd --out = 5 git ls-files -s  &&
> +       test_line_count_cmd --out = 4 git ls-files -u  &&

Nit: too many spaces before the `&&` on both lines.
Đoàn Trần Công Danh June 13, 2021, 7:39 a.m. UTC | #3
On 2021-06-12 11:33:49+0700, Bagas Sanjaya <bagasdotme@gmail.com> wrote:
> Hi Đoàn,

It's better to call me Danh. Thanks. Don't worry, I was called Dan all
the time, too ;)

> 
> > -	test 5 -eq $(git ls-files -s | wc -l) &&
> > -	test 4 -eq $(git ls-files -u | wc -l) &&
> > +	test_line_count_cmd --out = 5 git ls-files -s &&
> > +	test_line_count_cmd --out = 4 git ls-files -u  &&
> 
> I read lines above as "Formerly I tested that 5/4 should be equal to output
> of git ls-files -s/-u piped to wc -l, now I do the same with
> test_line_count_cmd".
> 
> Am I right?

Yes, you read that right. This series is mostly a cleanup for
linting "test .* -o" (But that regex wouldn't be put to be used
anytime soon).
Đoàn Trần Công Danh June 13, 2021, 7:42 a.m. UTC | #4
On 2021-06-12 23:39:51-0400, Eric Sunshine <sunshine@sunshineco.com> wrote:
> On Sat, Jun 12, 2021 at 12:28 AM Đoàn Trần Công Danh
> <congdanhqx@gmail.com> wrote:
> >
> > Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
> > ---
> > diff --git a/t/t6400-merge-df.sh b/t/t6400-merge-df.sh
> > @@ -82,13 +82,13 @@ test_expect_success 'modify/delete + directory/file conflict' '
> > -       test 5 -eq $(git ls-files -s | wc -l) &&
> > -       test 4 -eq $(git ls-files -u | wc -l) &&
> > +       test_line_count_cmd --out = 5 git ls-files -s &&
> > +       test_line_count_cmd --out = 4 git ls-files -u  &&
> 
> Nit: too many spaces before the `&&` on the second line: s/\s+/ /

Thanks, I'll update them, later.
In my defence, this patch was generated mechanically with:

	:%s/test \([0-9]\+\) -eq "*[$][(]\(.*\)|.*[)]"*/test_line_count_cmd --out = \1 \2/gc

I forgot to include the space after final ")"

> > @@ -103,13 +103,13 @@ test_expect_success 'modify/delete + directory/file conflict; other way' '
> > -       test 5 -eq $(git ls-files -s | wc -l) &&
> > -       test 4 -eq $(git ls-files -u | wc -l) &&
> > +       test_line_count_cmd --out = 5 git ls-files -s  &&
> > +       test_line_count_cmd --out = 4 git ls-files -u  &&
> 
> Nit: too many spaces before the `&&` on both lines.
diff mbox series

Patch

diff --git a/t/t6400-merge-df.sh b/t/t6400-merge-df.sh
index 38700d29b5..9d7b9354c5 100755
--- a/t/t6400-merge-df.sh
+++ b/t/t6400-merge-df.sh
@@ -82,13 +82,13 @@  test_expect_success 'modify/delete + directory/file conflict' '
 	git checkout delete^0 &&
 	test_must_fail git merge modify &&
 
-	test 5 -eq $(git ls-files -s | wc -l) &&
-	test 4 -eq $(git ls-files -u | wc -l) &&
+	test_line_count_cmd --out = 5 git ls-files -s &&
+	test_line_count_cmd --out = 4 git ls-files -u  &&
 	if test "$GIT_TEST_MERGE_ALGORITHM" = ort
 	then
-		test 0 -eq $(git ls-files -o | wc -l)
+		test_line_count_cmd --out = 2 git ls-files -o
 	else
-		test 1 -eq $(git ls-files -o | wc -l)
+		test_line_count_cmd --out = 3 git ls-files -o
 	fi &&
 
 	test_path_is_file letters/file &&
@@ -103,13 +103,13 @@  test_expect_success 'modify/delete + directory/file conflict; other way' '
 
 	test_must_fail git merge delete &&
 
-	test 5 -eq $(git ls-files -s | wc -l) &&
-	test 4 -eq $(git ls-files -u | wc -l) &&
+	test_line_count_cmd --out = 5 git ls-files -s  &&
+	test_line_count_cmd --out = 4 git ls-files -u  &&
 	if test "$GIT_TEST_MERGE_ALGORITHM" = ort
 	then
-		test 0 -eq $(git ls-files -o | wc -l)
+		test_line_count_cmd --out = 2 git ls-files -o
 	else
-		test 1 -eq $(git ls-files -o | wc -l)
+		test_line_count_cmd --out = 3 git ls-files -o
 	fi &&
 
 	test_path_is_file letters/file &&