From: "SZEDER Gábor" <szeder.dev@gmail.com>
To: git@vger.kernel.org
Cc: "Jeff King" <peff@peff.net>, "SZEDER Gábor" <szeder.dev@gmail.com>
Subject: [PATCH 3/3] t1404: use 'test_must_fail stderr=<file>'
Date: Fri, 9 Feb 2018 03:42:35 +0100 [thread overview]
Message-ID: <20180209024235.3431-4-szeder.dev@gmail.com> (raw)
In-Reply-To: <20180209024235.3431-1-szeder.dev@gmail.com>
Instead of 'test_must_fail git cmd... 2>output.err', which redirects
the standard error of the 'test_must_fail' helper function as well,
causing various issues as discussed in the previous patch.
With this patch t1404 succeeds when run with '-x', even with shells
not supporting $BASH_XTRACEFD.
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
---
t/t1404-update-ref-errors.sh | 46 ++++++++++++++++++++++----------------------
1 file changed, 23 insertions(+), 23 deletions(-)
diff --git a/t/t1404-update-ref-errors.sh b/t/t1404-update-ref-errors.sh
index 3a887b5113..91250bc6a0 100755
--- a/t/t1404-update-ref-errors.sh
+++ b/t/t1404-update-ref-errors.sh
@@ -26,7 +26,7 @@ test_update_rejected () {
git pack-refs --all
fi &&
printf "create $prefix/%s $C\n" $create >input &&
- test_must_fail git update-ref --stdin <input 2>output.err &&
+ test_must_fail stderr=output.err git update-ref --stdin <input &&
grep -F "$error" output.err &&
git for-each-ref $prefix >actual &&
test_cmp unchanged actual
@@ -102,7 +102,7 @@ df_test() {
else
printf "%s\n" "delete $delname" "create $addname $D"
fi >commands &&
- test_must_fail git update-ref --stdin <commands 2>output.err &&
+ test_must_fail stderr=output.err git update-ref --stdin <commands &&
test_cmp expected-err output.err &&
printf "%s\n" "$C $delref" >expected-refs &&
git for-each-ref --format="%(objectname) %(refname)" $prefix/r >actual-refs &&
@@ -337,7 +337,7 @@ test_expect_success 'missing old value blocks update' '
fatal: cannot lock ref $Q$prefix/foo$Q: unable to resolve reference $Q$prefix/foo$Q
EOF
printf "%s\n" "update $prefix/foo $E $D" |
- test_must_fail git update-ref --stdin 2>output.err &&
+ test_must_fail stderr=output.err git update-ref --stdin &&
test_cmp expected output.err
'
@@ -348,7 +348,7 @@ test_expect_success 'incorrect old value blocks update' '
fatal: cannot lock ref $Q$prefix/foo$Q: is at $C but expected $D
EOF
printf "%s\n" "update $prefix/foo $E $D" |
- test_must_fail git update-ref --stdin 2>output.err &&
+ test_must_fail stderr=output.err git update-ref --stdin &&
test_cmp expected output.err
'
@@ -359,7 +359,7 @@ test_expect_success 'existing old value blocks create' '
fatal: cannot lock ref $Q$prefix/foo$Q: reference already exists
EOF
printf "%s\n" "create $prefix/foo $E" |
- test_must_fail git update-ref --stdin 2>output.err &&
+ test_must_fail stderr=output.err git update-ref --stdin &&
test_cmp expected output.err
'
@@ -370,7 +370,7 @@ test_expect_success 'incorrect old value blocks delete' '
fatal: cannot lock ref $Q$prefix/foo$Q: is at $C but expected $D
EOF
printf "%s\n" "delete $prefix/foo $D" |
- test_must_fail git update-ref --stdin 2>output.err &&
+ test_must_fail stderr=output.err git update-ref --stdin &&
test_cmp expected output.err
'
@@ -381,7 +381,7 @@ test_expect_success 'missing old value blocks indirect update' '
fatal: cannot lock ref $Q$prefix/symref$Q: unable to resolve reference $Q$prefix/foo$Q
EOF
printf "%s\n" "update $prefix/symref $E $D" |
- test_must_fail git update-ref --stdin 2>output.err &&
+ test_must_fail stderr=output.err git update-ref --stdin &&
test_cmp expected output.err
'
@@ -393,7 +393,7 @@ test_expect_success 'incorrect old value blocks indirect update' '
fatal: cannot lock ref $Q$prefix/symref$Q: is at $C but expected $D
EOF
printf "%s\n" "update $prefix/symref $E $D" |
- test_must_fail git update-ref --stdin 2>output.err &&
+ test_must_fail stderr=output.err git update-ref --stdin &&
test_cmp expected output.err
'
@@ -405,7 +405,7 @@ test_expect_success 'existing old value blocks indirect create' '
fatal: cannot lock ref $Q$prefix/symref$Q: reference already exists
EOF
printf "%s\n" "create $prefix/symref $E" |
- test_must_fail git update-ref --stdin 2>output.err &&
+ test_must_fail stderr=output.err git update-ref --stdin &&
test_cmp expected output.err
'
@@ -417,7 +417,7 @@ test_expect_success 'incorrect old value blocks indirect delete' '
fatal: cannot lock ref $Q$prefix/symref$Q: is at $C but expected $D
EOF
printf "%s\n" "delete $prefix/symref $D" |
- test_must_fail git update-ref --stdin 2>output.err &&
+ test_must_fail stderr=output.err git update-ref --stdin &&
test_cmp expected output.err
'
@@ -428,7 +428,7 @@ test_expect_success 'missing old value blocks indirect no-deref update' '
fatal: cannot lock ref $Q$prefix/symref$Q: reference is missing but expected $D
EOF
printf "%s\n" "option no-deref" "update $prefix/symref $E $D" |
- test_must_fail git update-ref --stdin 2>output.err &&
+ test_must_fail stderr=output.err git update-ref --stdin &&
test_cmp expected output.err
'
@@ -440,7 +440,7 @@ test_expect_success 'incorrect old value blocks indirect no-deref update' '
fatal: cannot lock ref $Q$prefix/symref$Q: is at $C but expected $D
EOF
printf "%s\n" "option no-deref" "update $prefix/symref $E $D" |
- test_must_fail git update-ref --stdin 2>output.err &&
+ test_must_fail stderr=output.err git update-ref --stdin &&
test_cmp expected output.err
'
@@ -452,7 +452,7 @@ test_expect_success 'existing old value blocks indirect no-deref create' '
fatal: cannot lock ref $Q$prefix/symref$Q: reference already exists
EOF
printf "%s\n" "option no-deref" "create $prefix/symref $E" |
- test_must_fail git update-ref --stdin 2>output.err &&
+ test_must_fail stderr=output.err git update-ref --stdin &&
test_cmp expected output.err
'
@@ -464,7 +464,7 @@ test_expect_success 'incorrect old value blocks indirect no-deref delete' '
fatal: cannot lock ref $Q$prefix/symref$Q: is at $C but expected $D
EOF
printf "%s\n" "option no-deref" "delete $prefix/symref $D" |
- test_must_fail git update-ref --stdin 2>output.err &&
+ test_must_fail stderr=output.err git update-ref --stdin &&
test_cmp expected output.err
'
@@ -477,13 +477,13 @@ test_expect_success 'non-empty directory blocks create' '
fatal: cannot lock ref $Q$prefix/foo$Q: there is a non-empty directory $Q.git/$prefix/foo$Q blocking reference $Q$prefix/foo$Q
EOF
printf "%s\n" "update $prefix/foo $C" |
- test_must_fail git update-ref --stdin 2>output.err &&
+ test_must_fail stderr=output.err git update-ref --stdin &&
test_cmp expected output.err &&
cat >expected <<-EOF &&
fatal: cannot lock ref $Q$prefix/foo$Q: unable to resolve reference $Q$prefix/foo$Q
EOF
printf "%s\n" "update $prefix/foo $D $C" |
- test_must_fail git update-ref --stdin 2>output.err &&
+ test_must_fail stderr=output.err git update-ref --stdin &&
test_cmp expected output.err
'
@@ -496,13 +496,13 @@ test_expect_success 'broken reference blocks create' '
fatal: cannot lock ref $Q$prefix/foo$Q: unable to resolve reference $Q$prefix/foo$Q: reference broken
EOF
printf "%s\n" "update $prefix/foo $C" |
- test_must_fail git update-ref --stdin 2>output.err &&
+ test_must_fail stderr=output.err git update-ref --stdin &&
test_cmp expected output.err &&
cat >expected <<-EOF &&
fatal: cannot lock ref $Q$prefix/foo$Q: unable to resolve reference $Q$prefix/foo$Q: reference broken
EOF
printf "%s\n" "update $prefix/foo $D $C" |
- test_must_fail git update-ref --stdin 2>output.err &&
+ test_must_fail stderr=output.err git update-ref --stdin &&
test_cmp expected output.err
'
@@ -516,13 +516,13 @@ test_expect_success 'non-empty directory blocks indirect create' '
fatal: cannot lock ref $Q$prefix/symref$Q: there is a non-empty directory $Q.git/$prefix/foo$Q blocking reference $Q$prefix/foo$Q
EOF
printf "%s\n" "update $prefix/symref $C" |
- test_must_fail git update-ref --stdin 2>output.err &&
+ test_must_fail stderr=output.err git update-ref --stdin &&
test_cmp expected output.err &&
cat >expected <<-EOF &&
fatal: cannot lock ref $Q$prefix/symref$Q: unable to resolve reference $Q$prefix/foo$Q
EOF
printf "%s\n" "update $prefix/symref $D $C" |
- test_must_fail git update-ref --stdin 2>output.err &&
+ test_must_fail stderr=output.err git update-ref --stdin &&
test_cmp expected output.err
'
@@ -535,13 +535,13 @@ test_expect_success 'broken reference blocks indirect create' '
fatal: cannot lock ref $Q$prefix/symref$Q: unable to resolve reference $Q$prefix/foo$Q: reference broken
EOF
printf "%s\n" "update $prefix/symref $C" |
- test_must_fail git update-ref --stdin 2>output.err &&
+ test_must_fail stderr=output.err git update-ref --stdin &&
test_cmp expected output.err &&
cat >expected <<-EOF &&
fatal: cannot lock ref $Q$prefix/symref$Q: unable to resolve reference $Q$prefix/foo$Q: reference broken
EOF
printf "%s\n" "update $prefix/symref $D $C" |
- test_must_fail git update-ref --stdin 2>output.err &&
+ test_must_fail stderr=output.err git update-ref --stdin &&
test_cmp expected output.err
'
@@ -612,7 +612,7 @@ test_expect_success 'delete fails cleanly if packed-refs file is locked' '
# Now try to delete it while the `packed-refs` lock is held:
: >.git/packed-refs.lock &&
test_when_finished "rm -f .git/packed-refs.lock" &&
- test_must_fail git update-ref -d $prefix/foo >out 2>err &&
+ test_must_fail stderr=err git update-ref -d $prefix/foo >out &&
git for-each-ref $prefix >actual &&
test_i18ngrep "Unable to create $Q.*packed-refs.lock$Q: File exists" err &&
test_cmp unchanged actual
--
2.16.1.180.g07550b0b1b
next prev parent reply other threads:[~2018-02-09 2:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-09 2:42 [PATCH 0/3] Teach 'test_must_fail' to save the command's stderr to a file SZEDER Gábor
2018-02-09 2:42 ` [PATCH 1/3] t: document 'test_must_fail ok=<signal-name>' SZEDER Gábor
2018-02-09 2:42 ` [PATCH 2/3] t: teach 'test_must_fail' to save the command's stderr to a file SZEDER Gábor
2018-02-09 3:11 ` Eric Sunshine
2018-02-09 14:21 ` Jeff King
2018-02-09 18:36 ` Junio C Hamano
2018-02-09 18:57 ` Jeff King
2018-02-09 19:03 ` Jeff King
2018-02-23 23:26 ` SZEDER Gábor
2018-02-09 2:42 ` SZEDER Gábor [this message]
2018-02-09 3:16 ` [PATCH 3/3] t1404: use 'test_must_fail stderr=<file>' Eric Sunshine
2018-02-09 3:33 ` SZEDER Gábor
2018-02-09 18:22 ` Junio C Hamano
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=20180209024235.3431-4-szeder.dev@gmail.com \
--to=szeder.dev@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/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).