Thread (29 messages) 29 messages, 5 authors, 2021-07-04
STALE1911d

Revision v2 of 3 in this series.

Revisions (3)
  1. v1 [diff vs current]
  2. v2 current
  3. v2 [diff vs current]

[PATCH v2 3/5] t0041: use test_line_count_cmd to check std{out,err}

From: Đoàn Trần Công Danh <hidden>
Date: 2021-06-15 17:21:08
Subsystem: the rest · Maintainer: Linus Torvalds

Signed-off-by: Đoàn Trần Công Danh <redacted>
---
 t/t0041-usage.sh | 53 ++++++++++++++++--------------------------------
 1 file changed, 17 insertions(+), 36 deletions(-)
diff --git a/t/t0041-usage.sh b/t/t0041-usage.sh
index c4fc34eb18..24e24f698c 100755
--- a/t/t0041-usage.sh
+++ b/t/t0041-usage.sh
@@ -12,98 +12,79 @@ test_expect_success 'setup ' '
 '
 
 test_expect_success 'tag --contains <existent_tag>' '
-	git tag --contains "v1.0" >actual 2>actual.err &&
-	grep "v1.0" actual &&
-	test_line_count = 0 actual.err
+	test_line_count_cmd --err = 0 git tag --contains v1.0 >actual &&
+	grep "v1.0" actual
 '
 
 test_expect_success 'tag --contains <inexistent_tag>' '
-	test_must_fail git tag --contains "notag" >actual 2>actual.err &&
-	test_line_count = 0 actual &&
+	test_line_count_cmd --out = 0 test_must_fail git tag --contains notag 2>actual.err &&
 	test_i18ngrep "error" actual.err &&
 	test_i18ngrep ! "usage" actual.err
 '
 
 test_expect_success 'tag --no-contains <existent_tag>' '
-	git tag --no-contains "v1.0" >actual 2>actual.err  &&
-	test_line_count = 0 actual &&
-	test_line_count = 0 actual.err
+	test_line_count_cmd --out = 0 --err = 0 git tag --no-contains v1.0
 '
 
 test_expect_success 'tag --no-contains <inexistent_tag>' '
-	test_must_fail git tag --no-contains "notag" >actual 2>actual.err &&
-	test_line_count = 0 actual &&
+	test_line_count_cmd --out = 0 test_must_fail git tag --no-contains notag 2>actual.err &&
 	test_i18ngrep "error" actual.err &&
 	test_i18ngrep ! "usage" actual.err
 '
 
 test_expect_success 'tag usage error' '
-	test_must_fail git tag --noopt >actual 2>actual.err &&
-	test_line_count = 0 actual &&
+	test_line_count_cmd --out = 0 test_must_fail git tag --noopt 2>actual.err &&
 	test_i18ngrep "usage" actual.err
 '
 
 test_expect_success 'branch --contains <existent_commit>' '
-	git branch --contains "main" >actual 2>actual.err &&
-	test_i18ngrep "main" actual &&
-	test_line_count = 0 actual.err
+	test_line_count_cmd --err = 0 git branch --contains main >actual &&
+	test_i18ngrep "main" actual
 '
 
 test_expect_success 'branch --contains <inexistent_commit>' '
-	test_must_fail git branch --no-contains "nocommit" >actual 2>actual.err &&
-	test_line_count = 0 actual &&
+	test_line_count_cmd --out = 0 test_must_fail git branch --no-contains "nocommit" 2>actual.err &&
 	test_i18ngrep "error" actual.err &&
 	test_i18ngrep ! "usage" actual.err
 '
 
 test_expect_success 'branch --no-contains <existent_commit>' '
-	git branch --no-contains "main" >actual 2>actual.err &&
-	test_line_count = 0 actual &&
-	test_line_count = 0 actual.err
+	test_line_count_cmd --out = 0 --err = 0 git branch --no-contains main
 '
 
 test_expect_success 'branch --no-contains <inexistent_commit>' '
-	test_must_fail git branch --no-contains "nocommit" >actual 2>actual.err &&
-	test_line_count = 0 actual &&
+	test_line_count_cmd --out = 0 test_must_fail git branch --no-contains "nocommit" 2>actual.err &&
 	test_i18ngrep "error" actual.err &&
 	test_i18ngrep ! "usage" actual.err
 '
 
 test_expect_success 'branch usage error' '
-	test_must_fail git branch --noopt >actual 2>actual.err &&
-	test_line_count = 0 actual &&
+	test_line_count_cmd --out = 0 test_must_fail git branch --noopt 2>actual.err &&
 	test_i18ngrep "usage" actual.err
 '
 
 test_expect_success 'for-each-ref --contains <existent_object>' '
-	git for-each-ref --contains "main" >actual 2>actual.err &&
-	test_line_count = 2 actual &&
-	test_line_count = 0 actual.err
+	test_line_count_cmd --out = 2 --err = 0 git for-each-ref --contains main
 '
 
 test_expect_success 'for-each-ref --contains <inexistent_object>' '
-	test_must_fail git for-each-ref --no-contains "noobject" >actual 2>actual.err &&
-	test_line_count = 0 actual &&
+	test_line_count_cmd --out = 0 test_must_fail git for-each-ref --no-contains "noobject" 2>actual.err &&
 	test_i18ngrep "error" actual.err &&
 	test_i18ngrep ! "usage" actual.err
 '
 
 test_expect_success 'for-each-ref --no-contains <existent_object>' '
-	git for-each-ref --no-contains "main" >actual 2>actual.err &&
-	test_line_count = 0 actual &&
-	test_line_count = 0 actual.err
+	test_line_count_cmd --out = 0 --err = 0 git for-each-ref --no-contains "main"
 '
 
 test_expect_success 'for-each-ref --no-contains <inexistent_object>' '
-	test_must_fail git for-each-ref --no-contains "noobject" >actual 2>actual.err &&
-	test_line_count = 0 actual &&
+	test_line_count_cmd --out = 0 test_must_fail git for-each-ref --no-contains "noobject" 2>actual.err &&
 	test_i18ngrep "error" actual.err &&
 	test_i18ngrep ! "usage" actual.err
 '
 
 test_expect_success 'for-each-ref usage error' '
-	test_must_fail git for-each-ref --noopt >actual 2>actual.err &&
-	test_line_count = 0 actual &&
+	test_line_count_cmd --out = 0 test_must_fail git for-each-ref --noopt 2>actual.err &&
 	test_i18ngrep "usage" actual.err
 '
 
-- 
2.32.0.278.gd42b80f139
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help