t1507-rev-parse-upstream: don't check the stderr of a shell function

Three tests in 't1507-rev-parse-upstream.sh' fail when the test script
is run with '-x' tracing (and using a shell other than a Bash version
supporting BASH_XTRACEFD).  The reason for those failures is that the
tests check the stderr of the function 'error_message', which includes
the trace of commands executed in that function as well, throwing off
the comparison with the expected output.

Save stderr of 'git rev-parse' only instead of the whole function, so
it remains free from tracing output.

After this change t1507 passes with '-x', even when running with
/bin/sh.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
SZEDER Gábor 2018-02-24 00:39:43 +01:00 committed by Junio C Hamano
parent 5fc98e79fc
commit c3a4456243

View file

@ -42,7 +42,7 @@ commit_subject () {
error_message () {
(cd clone &&
test_must_fail git rev-parse --verify "$@")
test_must_fail git rev-parse --verify "$@" 2>../error)
}
test_expect_success '@{upstream} resolves to correct full name' '
@ -159,8 +159,8 @@ test_expect_success 'branch@{u} error message when no upstream' '
cat >expect <<-EOF &&
fatal: no upstream configured for branch ${sq}non-tracking${sq}
EOF
error_message non-tracking@{u} 2>actual &&
test_i18ncmp expect actual
error_message non-tracking@{u} &&
test_i18ncmp expect error
'
test_expect_success '@{u} error message when no upstream' '
@ -175,8 +175,8 @@ test_expect_success 'branch@{u} error message with misspelt branch' '
cat >expect <<-EOF &&
fatal: no such branch: ${sq}no-such-branch${sq}
EOF
error_message no-such-branch@{u} 2>actual &&
test_i18ncmp expect actual
error_message no-such-branch@{u} &&
test_i18ncmp expect error
'
test_expect_success '@{u} error message when not on a branch' '
@ -192,8 +192,8 @@ test_expect_success 'branch@{u} error message if upstream branch not fetched' '
cat >expect <<-EOF &&
fatal: upstream branch ${sq}refs/heads/side${sq} not stored as a remote-tracking branch
EOF
error_message bad-upstream@{u} 2>actual &&
test_i18ncmp expect actual
error_message bad-upstream@{u} &&
test_i18ncmp expect error
'
test_expect_success 'pull works when tracking a local branch' '