diff options
Diffstat (limited to 't/t5411/test-0013-bad-protocol.sh')
-rw-r--r-- | t/t5411/test-0013-bad-protocol.sh | 157 |
1 files changed, 65 insertions, 92 deletions
diff --git a/t/t5411/test-0013-bad-protocol.sh b/t/t5411/test-0013-bad-protocol.sh index b9be12be77..c08a00ded2 100644 --- a/t/t5411/test-0013-bad-protocol.sh +++ b/t/t5411/test-0013-bad-protocol.sh @@ -11,8 +11,8 @@ test_expect_success "setup proc-receive hook (unknown version, $PROTOCOL)" ' test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL)" ' test_must_fail git -C workbench push origin \ HEAD:refs/for/main/topic \ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && # Check status report for git-push sed -n \ @@ -29,17 +29,14 @@ test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL)" ' # message ("remote: fatal: the remote end hung up unexpectedly") which # is different from the remote HTTP server with different locale settings. grep "^remote: error:" <actual >actual-error && - cat >expect <<-EOF && - remote: error: proc-receive version "2" is not supported + format_and_save_expect <<-EOF && + > remote: error: proc-receive version "2" is not supported Z EOF test_cmp expect actual-error && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "setup proc-receive hook (hook --die-read-version, $PROTOCOL)" ' @@ -55,25 +52,22 @@ test_expect_success "setup proc-receive hook (hook --die-read-version, $PROTOCOL test_expect_success "proc-receive: bad protocol (hook --die-read-version, $PROTOCOL)" ' test_must_fail git -C workbench push origin \ HEAD:refs/for/main/topic \ - >out 2>&1 && + >out-$test_count 2>&1 && filter_out_user_friendly_and_stable_output \ -e "/^To / { p; }" \ -e "/^ ! / { p; }" \ - <out >actual && + <out-$test_count >actual && cat >expect <<-EOF && To <URL/of/upstream.git> ! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook) EOF test_cmp expect actual && - grep "remote: fatal: die with the --die-read-version option" out && - grep "remote: error: fail to negotiate version with proc-receive hook" out && + grep "remote: fatal: die with the --die-read-version option" out-$test_count && + grep "remote: error: fail to negotiate version with proc-receive hook" out-$test_count && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "setup proc-receive hook (hook --die-write-version, $PROTOCOL)" ' @@ -89,25 +83,22 @@ test_expect_success "setup proc-receive hook (hook --die-write-version, $PROTOCO test_expect_success "proc-receive: bad protocol (hook --die-write-version, $PROTOCOL)" ' test_must_fail git -C workbench push origin \ HEAD:refs/for/main/topic \ - >out 2>&1 && + >out-$test_count 2>&1 && filter_out_user_friendly_and_stable_output \ -e "/^To / { p; }" \ -e "/^ ! / { p; }" \ - <out >actual && + <out-$test_count >actual && cat >expect <<-EOF && To <URL/of/upstream.git> ! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook) EOF test_cmp expect actual && - grep "remote: fatal: die with the --die-write-version option" out && - grep "remote: error: fail to negotiate version with proc-receive hook" out && + grep "remote: fatal: die with the --die-write-version option" out-$test_count && + grep "remote: error: fail to negotiate version with proc-receive hook" out-$test_count && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "setup proc-receive hook (hook --die-read-commands, $PROTOCOL)" ' @@ -123,24 +114,21 @@ test_expect_success "setup proc-receive hook (hook --die-read-commands, $PROTOCO test_expect_success "proc-receive: bad protocol (hook --die-read-commands, $PROTOCOL)" ' test_must_fail git -C workbench push origin \ HEAD:refs/for/main/topic \ - >out 2>&1 && + >out-$test_count 2>&1 && filter_out_user_friendly_and_stable_output \ -e "/^To / { p; }" \ -e "/^ ! / { p; }" \ - <out >actual && + <out-$test_count >actual && cat >expect <<-EOF && To <URL/of/upstream.git> ! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook) EOF test_cmp expect actual && - grep "remote: fatal: die with the --die-read-commands option" out && + grep "remote: fatal: die with the --die-read-commands option" out-$test_count && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "setup proc-receive hook (hook --die-read-push-options, $PROTOCOL)" ' @@ -158,24 +146,21 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-push-options, $ test_must_fail git -C workbench push origin \ -o reviewers=user1,user2 \ HEAD:refs/for/main/topic \ - >out 2>&1 && + >out-$test_count 2>&1 && filter_out_user_friendly_and_stable_output \ -e "/^To / { p; }" \ -e "/^ ! / { p; }" \ - <out >actual && + <out-$test_count >actual && cat >expect <<-EOF && To <URL/of/upstream.git> ! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook) EOF test_cmp expect actual && - grep "remote: fatal: die with the --die-read-push-options option" out && + grep "remote: fatal: die with the --die-read-push-options option" out-$test_count && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "setup proc-receive hook (hook --die-write-report, $PROTOCOL)" ' @@ -191,24 +176,21 @@ test_expect_success "setup proc-receive hook (hook --die-write-report, $PROTOCOL test_expect_success "proc-receive: bad protocol (hook --die-write-report, $PROTOCOL)" ' test_must_fail git -C workbench push origin \ HEAD:refs/for/main/topic \ - >out 2>&1 && + >out-$test_count 2>&1 && filter_out_user_friendly_and_stable_output \ -e "/^To / { p; }" \ -e "/^ ! / { p; }" \ - <out >actual && + <out-$test_count >actual && cat >expect <<-EOF && To <URL/of/upstream.git> ! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook) EOF test_cmp expect actual && - grep "remote: fatal: die with the --die-write-report option" out && + grep "remote: fatal: die with the --die-write-report option" out-$test_count && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "setup proc-receive hook (no report, $PROTOCOL)" ' @@ -224,29 +206,26 @@ test_expect_success "setup proc-receive hook (no report, $PROTOCOL)" ' test_expect_success "proc-receive: bad protocol (no report, $PROTOCOL)" ' test_must_fail git -C workbench push origin \ HEAD:refs/heads/next \ - HEAD:refs/for/main/topic >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic - remote: # post-receive hook - remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next - To <URL/of/upstream.git> - * [new branch] HEAD -> next - ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status) + HEAD:refs/for/main/topic >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next Z + > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z + > remote: # post-receive hook Z + > remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next Z + > To <URL/of/upstream.git> + > * [new branch] HEAD -> next + > ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status) EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main <COMMIT-A> refs/heads/next EOF - test_cmp expect actual ' # Refs of upstream : main(A) next(A) @@ -270,26 +249,23 @@ test_expect_success "setup proc-receive hook (no ref, $PROTOCOL)" ' test_expect_success "proc-receive: bad protocol (no ref, $PROTOCOL)" ' test_must_fail git -C workbench push origin \ HEAD:refs/for/main/topic\ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic - remote: proc-receive> ok - remote: error: proc-receive reported incomplete status line: "ok" - To <URL/of/upstream.git> - ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status) + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z + > remote: proc-receive> ok Z + > remote: error: proc-receive reported incomplete status line: "ok" Z + > To <URL/of/upstream.git> + > ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status) EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' test_expect_success "setup proc-receive hook (unknown status, $PROTOCOL)" ' @@ -306,24 +282,21 @@ test_expect_success "setup proc-receive hook (unknown status, $PROTOCOL)" ' test_expect_success "proc-receive: bad protocol (unknown status, $PROTOCOL)" ' test_must_fail git -C workbench push origin \ HEAD:refs/for/main/topic \ - >out 2>&1 && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && - remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic - remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic - remote: proc-receive> xx refs/for/main/topic - remote: error: proc-receive reported bad status "xx" on ref "refs/for/main/topic" - To <URL/of/upstream.git> - ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status) + >out-$test_count 2>&1 && + make_user_friendly_and_stable_output <out-$test_count >actual && + format_and_save_expect <<-EOF && + > remote: # pre-receive hook Z + > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z + > remote: # proc-receive hook Z + > remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z + > remote: proc-receive> xx refs/for/main/topic Z + > remote: error: proc-receive reported bad status "xx" on ref "refs/for/main/topic" Z + > To <URL/of/upstream.git> + > ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status) EOF test_cmp expect actual && - git -C "$upstream" show-ref >out && - make_user_friendly_and_stable_output <out >actual && - cat >expect <<-EOF && + test_cmp_refs -C "$upstream" <<-EOF <COMMIT-A> refs/heads/main EOF - test_cmp expect actual ' |