[PATCH v2] t2027: avoid using pipes
- From
Prathamesh Chavan <pc44800@gmail.com>
- Date
- Mar 9, 2017, 09:39 UTC
- Message-ID
- <0102015ab26fcf13-1659be12-a85c-47be-9a77-8f1b0b8a3897-000000@eu-west-1.amazonses.com>
- In-Reply-To
- <0102015aae7b8536-00c57d0a-1d48-4153-a202-87c4ea9e0e19-000000@eu-west-1.amazonses.com>
The exit code of the upstream of a pipe is ignored thus we should avoid using it. By writing out the output of the git command to a file, we can test the exit codes of both the commands.
Signed-off-by: Prathamesh <pc44800@gmail.com> --- t/t2027-worktree-list.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/t/t2027-worktree-list.sh b/t/t2027-worktree-list.sh index 848da5f..daa7a04 100755 --- a/t/t2027-worktree-list.sh +++ b/t/t2027-worktree-list.sh @@ -31,7 +31,7 @@ test_expect_success '"list" all worktrees from main' ' test_when_finished "rm -rf here && git worktree prune" && git worktree add --detach here master && echo "$(git -C here rev-parse --show-toplevel) $(git rev-parse --short HEAD) (detached HEAD)" >>expect && - git worktree list | sed "s/ */ /g" >actual && + git worktree list >out && sed "s/ */ /g" <out >actual && test_cmp expect actual ' @@ -40,7 +40,7 @@ test_expect_success '"list" all worktrees from linked' ' test_when_finished "rm -rf here && git worktree prune" && git worktree add --detach here master && echo "$(git -C here rev-parse --show-toplevel) $(git rev-parse --short HEAD) (detached HEAD)" >>expect && - git -C here worktree list | sed "s/ */ /g" >actual && + git -C here worktree list >out && sed "s/ */ /g" <out >actual && test_cmp expect actual ' @@ -73,7 +73,7 @@ test_expect_success '"list" all worktrees from bare main' ' git -C bare1 worktree add --detach ../there master && echo "$(pwd)/bare1 (bare)" >expect && echo "$(git -C there rev-parse --show-toplevel) $(git -C there rev-parse --short HEAD) (detached HEAD)" >>expect && - git -C bare1 worktree list | sed "s/ */ /g" >actual && + git -C bare1 worktree list >out && sed "s/ */ /g" <out >actual && test_cmp expect actual ' @@ -96,7 +96,7 @@ test_expect_success '"list" all worktrees from linked with a bare main' ' git -C bare1 worktree add --detach ../there master && echo "$(pwd)/bare1 (bare)" >expect && echo "$(git -C there rev-parse --show-toplevel) $(git -C there rev-parse --short HEAD) (detached HEAD)" >>expect && - git -C there worktree list | sed "s/ */ /g" >actual && + git -C there worktree list >out && sed "s/ */ /g" <out >actual && test_cmp expect actual ' @@ -118,9 +118,9 @@ test_expect_success 'broken main worktree still at the top' ' cd linked && echo "worktree $(pwd)" >expected && echo "ref: .broken" >../.git/HEAD && - git worktree list --porcelain | head -n 3 >actual && + git worktree list --porcelain >out && head -n 3 out >actual && test_cmp ../expected actual && - git worktree list | head -n 1 >actual.2 && + git worktree list >out && head -n 1 out >actual.2 && grep -F "(error)" actual.2 ) ' @@ -134,7 +134,7 @@ test_expect_success 'linked worktrees are sorted' ' test_commit new && git worktree add ../first && git worktree add ../second && - git worktree list --porcelain | grep ^worktree >actual + git worktree list --porcelain >out && grep ^worktree out >actual ) && cat >expected <<-EOF && worktree $(pwd)/sorted/main -- https://github.com/git/git/pull/336