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 <predatoramigo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Pratik Karki
2018-03-27 23:16:37 +05:45
committed by Junio C Hamano
parent d32eb83c1d
commit a4d4e32a70
15 changed files with 179 additions and 159 deletions

View File

@ -33,8 +33,8 @@ test_expect_success 'init and fetch a moved directory' '
git svn fetch -i thunk &&
test "$(git rev-parse --verify refs/remotes/thunk@2)" \
= "$(git rev-parse --verify refs/remotes/thunk~1)" &&
test "$(git cat-file blob refs/remotes/thunk:readme |\
sed -n -e "3p")" = goodbye &&
git cat-file blob refs/remotes/thunk:readme >actual &&
test "$(sed -n -e "3p" actual)" = goodbye &&
test -z "$(git config --get svn-remote.svn.fetch \
"^trunk:refs/remotes/thunk@2$")"
'
@ -48,8 +48,8 @@ test_expect_success 'init and fetch from one svn-remote' '
git svn fetch -i svn/thunk &&
test "$(git rev-parse --verify refs/remotes/svn/trunk)" \
= "$(git rev-parse --verify refs/remotes/svn/thunk~1)" &&
test "$(git cat-file blob refs/remotes/svn/thunk:readme |\
sed -n -e "3p")" = goodbye
git cat-file blob refs/remotes/svn/thunk:readme >actual &&
test "$(sed -n -e "3p" actual)" = goodbye
'
test_expect_success 'follow deleted parent' '
@ -107,7 +107,8 @@ test_expect_success 'follow deleted directory' '
git svn init --minimize-url -i glob "$svnrepo"/glob &&
git svn fetch -i glob &&
test "$(git cat-file blob refs/remotes/glob:blob/bye)" = hi &&
test "$(git ls-tree refs/remotes/glob | wc -l )" -eq 1
git ls-tree refs/remotes/glob >actual &&
test_line_count = 1 actual
'
# ref: r9270 of the Subversion repository: (http://svn.collab.net/repos/svn)
@ -204,8 +205,9 @@ test_expect_success "follow-parent is atomic" '
test_expect_success "track multi-parent paths" '
svn_cmd cp -m "resurrect /glob" "$svnrepo"/r9270 "$svnrepo"/glob &&
git svn multi-fetch &&
test $(git cat-file commit refs/remotes/glob | \
grep "^parent " | wc -l) -eq 2
git cat-file commit refs/remotes/glob >actual &&
grep "^parent " actual >actual2 &&
test_line_count = 2 actual2
'
test_expect_success "multi-fetch continues to work" "