diff options
author | Jiang Xin <worldhello.net@gmail.com> | 2021-06-17 11:17:25 +0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-06-17 14:12:21 +0900 |
commit | 2bafb3d702d4cd77de0d3e68f13188980e0de734 (patch) | |
tree | 6f394212728100328ee3baa90c79298fdd5d272e /t/t5411/test-0001-standard-git-push--porcelain.sh | |
parent | sideband: don't lose clear-to-eol at packet boundary (diff) | |
download | tgif-2bafb3d702d4cd77de0d3e68f13188980e0de734.tar.xz |
test: compare raw output, not mangle tabs and spaces
Before comparing with the expect file, we used to call function
"make_user_friendly_and_stable_output" to filter out trailing spaces in
output. Ævar recommends using pattern "s/Z$//" to prepare expect file,
and then compare it with raw output.
Since we have fixed the issue of occasionally missing the clear-to-eol
suffix when displaying sideband #2 messages, it is safe and stable to
test against raw output.
Suggested-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5411/test-0001-standard-git-push--porcelain.sh')
-rw-r--r-- | t/t5411/test-0001-standard-git-push--porcelain.sh | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/t/t5411/test-0001-standard-git-push--porcelain.sh b/t/t5411/test-0001-standard-git-push--porcelain.sh index bcbda72341..2078d0a027 100644 --- a/t/t5411/test-0001-standard-git-push--porcelain.sh +++ b/t/t5411/test-0001-standard-git-push--porcelain.sh @@ -7,17 +7,17 @@ test_expect_success "git-push ($PROTOCOL/porcelain)" ' HEAD:refs/heads/next \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/main - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next - remote: # post-receive hook - remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/main - remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next - To <URL/of/upstream.git> - <COMMIT-B>:refs/heads/main <OID-A>..<OID-B> - * HEAD:refs/heads/next [new branch] - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/main Z + > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next Z + > remote: # post-receive hook Z + > remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/main Z + > remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next Z + > To <URL/of/upstream.git> + > <COMMIT-B>:refs/heads/main <OID-A>..<OID-B> + > * HEAD:refs/heads/next [new branch] + > Done EOF test_cmp expect actual && @@ -38,12 +38,12 @@ test_expect_success "git-push --atomic ($PROTOCOL/porcelain)" ' filter_out_user_friendly_and_stable_output \ -e "s/^# GETTEXT POISON #//" \ -e "/^To / { p; }" \ - -e "/^! / { p; }" \ + -e "/^!/ { p; }" \ <out-$test_count >actual && - cat >expect <<-EOF && - To <URL/of/upstream.git> - ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward) - ! <COMMIT-B>:refs/heads/next [rejected] (atomic push failed) + format_and_save_expect <<-EOF && + > To <URL/of/upstream.git> + > ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward) + > ! <COMMIT-B>:refs/heads/next [rejected] (atomic push failed) EOF test_cmp expect actual && @@ -65,15 +65,15 @@ test_expect_success "non-fast-forward git-push ($PROTOCOL/porcelain)" ' $B:refs/heads/next \ >out-$test_count 2>&1 && make_user_friendly_and_stable_output <out-$test_count >actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/next - remote: # post-receive hook - remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/next - To <URL/of/upstream.git> - <COMMIT-B>:refs/heads/next <OID-A>..<OID-B> - ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward) - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/next Z + > remote: # post-receive hook Z + > remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/next Z + > To <URL/of/upstream.git> + > <COMMIT-B>:refs/heads/next <OID-A>..<OID-B> + > ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward) + > Done EOF test_cmp expect actual && @@ -95,26 +95,26 @@ test_expect_success "git-push -f ($PROTOCOL/porcelain)" ' HEAD:refs/heads/a/b/c \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< <COMMIT-B> <COMMIT-A> refs/heads/main - remote: pre-receive< <COMMIT-B> <ZERO-OID> refs/heads/next - remote: pre-receive< <ZERO-OID> <TAG-v123> refs/tags/v123 - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/review/main/topic - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/a/b/c - remote: # post-receive hook - remote: post-receive< <COMMIT-B> <COMMIT-A> refs/heads/main - remote: post-receive< <COMMIT-B> <ZERO-OID> refs/heads/next - remote: post-receive< <ZERO-OID> <TAG-v123> refs/tags/v123 - remote: post-receive< <ZERO-OID> <COMMIT-A> refs/review/main/topic - remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/a/b/c - To <URL/of/upstream.git> - + refs/heads/main:refs/heads/main <OID-B>...<OID-A> (forced update) - - :refs/heads/next [deleted] - * refs/tags/v123:refs/tags/v123 [new tag] - * refs/heads/main:refs/review/main/topic [new reference] - * HEAD:refs/heads/a/b/c [new branch] - Done + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< <COMMIT-B> <COMMIT-A> refs/heads/main Z + > remote: pre-receive< <COMMIT-B> <ZERO-OID> refs/heads/next Z + > remote: pre-receive< <ZERO-OID> <TAG-v123> refs/tags/v123 Z + > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/review/main/topic Z + > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/a/b/c Z + > remote: # post-receive hook Z + > remote: post-receive< <COMMIT-B> <COMMIT-A> refs/heads/main Z + > remote: post-receive< <COMMIT-B> <ZERO-OID> refs/heads/next Z + > remote: post-receive< <ZERO-OID> <TAG-v123> refs/tags/v123 Z + > remote: post-receive< <ZERO-OID> <COMMIT-A> refs/review/main/topic Z + > remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/a/b/c Z + > To <URL/of/upstream.git> + > + refs/heads/main:refs/heads/main <OID-B>...<OID-A> (forced update) + > - :refs/heads/next [deleted] + > * refs/tags/v123:refs/tags/v123 [new tag] + > * refs/heads/main:refs/review/main/topic [new reference] + > * HEAD:refs/heads/a/b/c [new branch] + > Done EOF test_cmp expect actual && |