The exit code of the upstream in 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: Jonathan Chang <ttjt...@gmail.com>

diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
index 71e63d8b50..14274f1ced 100755
--- a/t/t0003-attributes.sh
+++ b/t/t0003-attributes.sh
@@ -203,15 +203,18 @@ test_expect_success 'attribute test: read paths from 
stdin' '
 test_expect_success 'attribute test: --all option' '
        grep -v unspecified <expect-all | sort >specified-all &&
        sed -e "s/:.*//" <expect-all | uniq >stdin-all &&
-       git check-attr --stdin --all <stdin-all | sort >actual &&
+       git check-attr --stdin --all <stdin-all >actual &&
+       sort -o actual actual &&
        test_cmp specified-all actual
 '
 
 test_expect_success 'attribute test: --cached option' '
-       git check-attr --cached --stdin --all <stdin-all | sort >actual &&
+       git check-attr --cached --stdin --all <stdin-all >actual &&
+       sort -o actual actual &&
        test_must_be_empty actual &&
        git add .gitattributes a/.gitattributes a/b/.gitattributes &&
-       git check-attr --cached --stdin --all <stdin-all | sort >actual &&
+       git check-attr --cached --stdin --all <stdin-all >actual &&
+       sort -o actual actual &&
        test_cmp specified-all actual
 '
 
@@ -301,8 +304,8 @@ test_expect_success 'bare repository: check that --cached 
honors index' '
        (
                cd bare.git &&
                GIT_INDEX_FILE=../.git/index \
-               git check-attr --cached --stdin --all <../stdin-all |
-               sort >actual &&
+               git check-attr --cached --stdin --all <../stdin-all >actual &&
+               sort -o actual actual &&
                test_cmp ../specified-all actual
        )
 '
-- 
2.21.0

Reply via email to