]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t5534: split stdout and stderr redirection
authorĐoàn Trần Công Danh <congdanhqx@gmail.com>
Tue, 6 Oct 2020 15:08:18 +0000 (22:08 +0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 6 Oct 2020 19:14:14 +0000 (12:14 -0700)
On atomic pushing failure with GnuPG, we expect a very specific output
in stdout due to `--porcelain` switch.

On such failure, we also write down some helpful hint into stderr
in order to help user understand what happens and how to continue from
those failures.

On a lot of system, those hint (in stderr) will be flushed first,
then those messages in stdout will be flushed. In such systems, the
current test code is fine as is.

However, we don't have such guarantee, (at least) there're some real
systems that writes those stream interleaved. On such systems, we may
see the stderr stream written in the middle of stdout stream.

Let's split those stream redirection. By splitting those stream,
the output stream will contain exactly what we want to compare,
thus, saving us a "sed" invocation.

While we're at it, change the `test_i18ncmp` to `test_cmp` because we
will never translate those messages (because of `--porcelain`).

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t5534-push-signed.sh

index 7e928aff669e550a01dafc8c0afc4bbd271d1d07..af0385fb89bdc2711153546dc3bb876ecf630e50 100755 (executable)
@@ -282,10 +282,9 @@ test_expect_success GPG 'failed atomic push does not execute GPG' '
        EOF
        test_must_fail env PATH="$TRASH_DIRECTORY:$PATH" git push \
                        --signed --atomic --porcelain \
-                       dst noop ff noff >out 2>&1 &&
+                       dst noop ff noff >out 2>err &&
 
-       test_i18ngrep ! "gpg failed to sign" out &&
-       sed -n -e "/^To dst/,$ p" out >actual &&
+       test_i18ngrep ! "gpg failed to sign" err &&
        cat >expect <<-EOF &&
        To dst
        =       refs/heads/noop:refs/heads/noop [up to date]
@@ -293,7 +292,7 @@ test_expect_success GPG 'failed atomic push does not execute GPG' '
        !       refs/heads/noff:refs/heads/noff [rejected] (non-fast-forward)
        Done
        EOF
-       test_i18ncmp expect actual
+       test_cmp expect out
 '
 
 test_done