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>

SZEDER Gábor committed Feb 24, 2018 at 00:39 UTC c3a44562431515210197b1344d7285be2763e8f5
1 file changed +7 -7
t/t1507-rev-parse-upstream.sh
+7 -7
@@ -42,7 +42,7 @@ commit_subject () {
42
43 error_message () {
44 (cd clone &&
45 - test_must_fail git rev-parse --verify "$@")
45 + test_must_fail git rev-parse --verify "$@" 2>../error)
46 }
47
48 test_expect_success '@{upstream} resolves to correct full name' '
@@ -159,8 +159,8 @@ test_expect_success 'branch@{u} error message when no upstream' '
159 cat >expect <<-EOF &&
160 fatal: no upstream configured for branch ${sq}non-tracking${sq}
161 EOF
162 - error_message non-tracking@{u} 2>actual &&
163 - test_i18ncmp expect actual
162 + error_message non-tracking@{u} &&
163 + test_i18ncmp expect error
164 '
165
166 test_expect_success '@{u} error message when no upstream' '
@@ -175,8 +175,8 @@ test_expect_success 'branch@{u} error message with misspelt branch' '
175 cat >expect <<-EOF &&
176 fatal: no such branch: ${sq}no-such-branch${sq}
177 EOF
178 - error_message no-such-branch@{u} 2>actual &&
179 - test_i18ncmp expect actual
178 + error_message no-such-branch@{u} &&
179 + test_i18ncmp expect error
180 '
181
182 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' '
192 cat >expect <<-EOF &&
193 fatal: upstream branch ${sq}refs/heads/side${sq} not stored as a remote-tracking branch
194 EOF
195 - error_message bad-upstream@{u} 2>actual &&
196 - test_i18ncmp expect actual
195 + error_message bad-upstream@{u} &&
196 + test_i18ncmp expect error
197 '
198
199 test_expect_success 'pull works when tracking a local branch' '