git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shanthanu <shanthanu.s.rai9@gmail.com>
To: git@vger.kernel.org
Cc: Shanthanu <shanthanu.s.rai9@gmail.com>, tboegi@web.de
Subject: [PATCH v2] t9116: avoid using pipes
Date: Tue, 24 Mar 2020 15:05:02 +0530	[thread overview]
Message-ID: <20200324093502.32394-1-shanthanu.s.rai9@gmail.com> (raw)
In-Reply-To: <20200322124619.30853-1-shanthanu.s.rai9@gmail.com>

Commit c6f44e1da5 (t9813: avoid using pipes, 2017-01-04) recommends to
avoid using pipes, since the exit code of upstream in the pipe is
ignored. Hence, redirect the output to a file and parse that file.

Commit de26f02db1 (t9001, t9116: avoid pipes, 2020-02-14) noted that
this also allows easy debugging in case the test fails, since the file
will be left on disk and can be manually inspected.

Signed-off-by: Shanthanu <shanthanu.s.rai9@gmail.com>
---
 t/t9116-git-svn-log.sh | 53 +++++++++++++++++++++++++++++++-----------
 1 file changed, 39 insertions(+), 14 deletions(-)

diff --git a/t/t9116-git-svn-log.sh b/t/t9116-git-svn-log.sh
index 0a9f1ef366..56d68e4aed 100755
--- a/t/t9116-git-svn-log.sh
+++ b/t/t9116-git-svn-log.sh
@@ -61,12 +61,16 @@ printf 'r1 \nr2 \nr4 \n' > expected-range-r1-r2-r4
 
 test_expect_success 'test ascending revision range' "
 	git reset --hard origin/trunk &&
-	git svn log -r 1:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2-r4 -
+	git svn log -r 1:4 >out &&
+	grep '^r[0-9]' out | cut -d'|' -f1 >actual &&
+	test_cmp expected-range-r1-r2-r4 actual
 	"
 
 test_expect_success 'test ascending revision range with --show-commit' "
 	git reset --hard origin/trunk &&
-	git svn log --show-commit -r 1:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2-r4 -
+	git svn log --show-commit -r 1:4 >out &&
+	grep '^r[0-9]' out | cut -d'|' -f1 >actual &&
+	test_cmp expected-range-r1-r2-r4 actual
 	"
 
 test_expect_success 'test ascending revision range with --show-commit (sha1)' "
@@ -74,7 +78,8 @@ test_expect_success 'test ascending revision range with --show-commit (sha1)' "
 	git svn find-rev r2 >>expected-range-r1-r2-r4-sha1 &&
 	git svn find-rev r4 >>expected-range-r1-r2-r4-sha1 &&
 	git reset --hard origin/trunk &&
-	git svn log --show-commit -r 1:4 | grep '^r[0-9]' | cut -d'|' -f2 >out &&
+	git svn log --show-commit -r 1:4 >out1 &&
+	grep '^r[0-9]' out1 | cut -d'|' -f2 >out &&
 	git rev-parse \$(cat out) >actual &&
 	test_cmp expected-range-r1-r2-r4-sha1 actual
 	"
@@ -83,67 +88,87 @@ printf 'r4 \nr2 \nr1 \n' > expected-range-r4-r2-r1
 
 test_expect_success 'test descending revision range' "
 	git reset --hard origin/trunk &&
-	git svn log -r 4:1 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4-r2-r1 -
+	git svn log -r 4:1 >out &&
+	grep '^r[0-9]' out | cut -d'|' -f1 >actual &&
+	test_cmp expected-range-r4-r2-r1 actual
 	"
 
 printf 'r1 \nr2 \n' > expected-range-r1-r2
 
 test_expect_success 'test ascending revision range with unreachable revision' "
 	git reset --hard origin/trunk &&
-	git svn log -r 1:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2 -
+	git svn log -r 1:3 >out &&
+	grep '^r[0-9]' out | cut -d'|' -f1 >actual &&
+	test_cmp expected-range-r1-r2 actual
 	"
 
 printf 'r2 \nr1 \n' > expected-range-r2-r1
 
 test_expect_success 'test descending revision range with unreachable revision' "
 	git reset --hard origin/trunk &&
-	git svn log -r 3:1 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2-r1 -
+	git svn log -r 3:1 >out &&
+	grep '^r[0-9]' out | cut -d'|' -f1 >actual &&
+	test_cmp expected-range-r2-r1 actual
 	"
 
 printf 'r2 \n' > expected-range-r2
 
 test_expect_success 'test ascending revision range with unreachable upper boundary revision and 1 commit' "
 	git reset --hard origin/trunk &&
-	git svn log -r 2:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2 -
+	git svn log -r 2:3 >out &&
+	grep '^r[0-9]' out | cut -d'|' -f1 >actual &&
+	test_cmp expected-range-r2 actual
 	"
 
 test_expect_success 'test descending revision range with unreachable upper boundary revision and 1 commit' "
 	git reset --hard origin/trunk &&
-	git svn log -r 3:2 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2 -
+	git svn log -r 3:2 >out &&
+	grep '^r[0-9]' out | cut -d'|' -f1 >actual &&
+	test_cmp expected-range-r2 actual
 	"
 
 printf 'r4 \n' > expected-range-r4
 
 test_expect_success 'test ascending revision range with unreachable lower boundary revision and 1 commit' "
 	git reset --hard origin/trunk &&
-	git svn log -r 3:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
+	git svn log -r 3:4 >out &&
+	grep '^r[0-9]' out | cut -d'|' -f1 >actual &&
+	test_cmp expected-range-r4 actual
 	"
 
 test_expect_success 'test descending revision range with unreachable lower boundary revision and 1 commit' "
 	git reset --hard origin/trunk &&
-	git svn log -r 4:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
+	git svn log -r 4:3 >out &&
+	grep '^r[0-9]' out | cut -d'|' -f1 >actual &&
+	test_cmp expected-range-r4 actual
 	"
 
 printf -- '------------------------------------------------------------------------\n' > expected-separator
 
 test_expect_success 'test ascending revision range with unreachable boundary revisions and no commits' "
 	git reset --hard origin/trunk &&
-	git svn log -r 5:6 | test_cmp expected-separator -
+	git svn log -r 5:6 >actual &&
+	test_cmp expected-separator actual
 	"
 
 test_expect_success 'test descending revision range with unreachable boundary revisions and no commits' "
 	git reset --hard origin/trunk &&
-	git svn log -r 6:5 | test_cmp expected-separator -
+	git svn log -r 6:5 >actual &&
+	test_cmp expected-separator actual
 	"
 
 test_expect_success 'test ascending revision range with unreachable boundary revisions and 1 commit' "
 	git reset --hard origin/trunk &&
-	git svn log -r 3:5 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
+	git svn log -r 3:5 >out &&
+	grep '^r[0-9]' out | cut -d'|' -f1 >actual &&
+	test_cmp expected-range-r4 actual
 	"
 
 test_expect_success 'test descending revision range with unreachable boundary revisions and 1 commit' "
 	git reset --hard origin/trunk &&
-	git svn log -r 5:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
+	git svn log -r 5:3 >out &&
+	grep '^r[0-9]' out | cut -d'|' -f1 >actual &&
+	test_cmp expected-range-r4 actual
 	"
 
 test_done
-- 
2.26.0.rc2.28.g7fcb965970


  parent reply	other threads:[~2020-03-24  9:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-22 12:46 [GSoC][PATCH 0/1] Microproject Submission Shanthanu
2020-03-22 12:46 ` [GSoC][PATCH 1/1] t9116: avoid using pipes Shanthanu
2020-03-22 17:36   ` Torsten Bögershausen
2020-03-23  7:04     ` Shanthanu
2020-03-24  9:35 ` Shanthanu [this message]
2020-03-24 18:34   ` [PATCH v2] " Christian Couder
2020-03-25 14:00     ` Shanthanu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200324093502.32394-1-shanthanu.s.rai9@gmail.com \
    --to=shanthanu.s.rai9@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=tboegi@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).