From a4d4e32a700df92ca576ce89110c075b8ce6da75 Mon Sep 17 00:00:00 2001 From: Pratik Karki Date: Tue, 27 Mar 2018 23:16:37 +0545 Subject: test: avoid pipes in git related commands for test Avoid using pipes downstream of Git commands since the exit codes of commands upstream of pipes get swallowed, thus potentially hiding failure of those commands. Instead, capture Git command output to a file and apply the downstream command(s) to that file. Signed-off-by: Pratik Karki Signed-off-by: Junio C Hamano --- t/t9109-git-svn-multi-glob.sh | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 't/t9109-git-svn-multi-glob.sh') diff --git a/t/t9109-git-svn-multi-glob.sh b/t/t9109-git-svn-multi-glob.sh index 8d99e848d4..c1e7542a37 100755 --- a/t/t9109-git-svn-multi-glob.sh +++ b/t/t9109-git-svn-multi-glob.sh @@ -47,8 +47,8 @@ test_expect_success 'test refspec globbing' ' git config --add svn-remote.svn.tags\ "tags/*/src/a:refs/remotes/tags/*" && git svn multi-fetch && - git log --pretty=oneline refs/remotes/tags/end | \ - sed -e "s/^.\{41\}//" > output.end && + git log --pretty=oneline refs/remotes/tags/end >actual && + sed -e "s/^.\{41\}//" actual >output.end && test_cmp expect.end output.end && test "$(git rev-parse refs/remotes/tags/end~1)" = \ "$(git rev-parse refs/remotes/branches/v1/start)" && @@ -75,14 +75,16 @@ test_expect_success 'test left-hand-side only globbing' ' svn_cmd commit -m "try to try" ) && git svn fetch two && - test $(git rev-list refs/remotes/two/tags/end | wc -l) -eq 6 && - test $(git rev-list refs/remotes/two/branches/v1/start | wc -l) -eq 3 && + git rev-list refs/remotes/two/tags/end >actual && + test_line_count = 6 actual && + git rev-list refs/remotes/two/branches/v1/start >actual && + test_line_count = 3 actual && test $(git rev-parse refs/remotes/two/branches/v1/start~2) = \ $(git rev-parse refs/remotes/two/trunk) && test $(git rev-parse refs/remotes/two/tags/end~3) = \ $(git rev-parse refs/remotes/two/branches/v1/start) && - git log --pretty=oneline refs/remotes/two/tags/end | \ - sed -e "s/^.\{41\}//" > output.two && + git log --pretty=oneline refs/remotes/two/tags/end >actual && + sed -e "s/^.\{41\}//" actual >output.two && test_cmp expect.two output.two ' cat > expect.four <actual && + test_line_count = 5 actual && + git rev-list refs/remotes/four/branches/v2/start >actual && + test_line_count = 3 actual && test $(git rev-parse refs/remotes/four/branches/v2/start~2) = \ $(git rev-parse refs/remotes/four/trunk) && test $(git rev-parse refs/remotes/four/tags/next~2) = \ $(git rev-parse refs/remotes/four/branches/v2/start) && - git log --pretty=oneline refs/remotes/four/tags/next | \ - sed -e "s/^.\{41\}//" > output.four && + git log --pretty=oneline refs/remotes/four/tags/next >actual && + sed -e "s/^.\{41\}//" actual >output.four && test_cmp expect.four output.four ' -- cgit v1.2.3