]> Cypherpunks repositories - gostls13.git/commit
net/http: refactor tests to run most in HTTP/1 and HTTP/2 modes
authorDamien Neil <dneil@google.com>
Mon, 3 Oct 2022 23:07:48 +0000 (16:07 -0700)
committerDamien Neil <dneil@google.com>
Fri, 7 Oct 2022 16:53:14 +0000 (16:53 +0000)
commit747e1961e95c2eb3df62e045b90b111c2ceea337
tree59a7c933ffe695cac3c9c48e8c8e8afa068b0985
parent5ca0cd3f1824f189b6c5edf59b669f22a393e2e1
net/http: refactor tests to run most in HTTP/1 and HTTP/2 modes

Replace the ad-hoc approach to running tests in HTTP/1 and HTTP/2
modes with a 'run' function that executes a test in various modes.
By default, these modes are HTTP/1 and HTTP/2, but tests can
opt-in to HTTPS/1 as well.

The 'run' function also takes care of post-test cleanup (running the
afterTest function).

The 'run' function runs tests in parallel by default. Tests which
can't run in parallel (generally because they use global test hooks)
pass a testNotParallel option to disable parallelism.

Update clientServerTest to use t.Cleanup to clean up after itself,
rather than leaving this up to tests to handle.

Drop an unnecessary mutex in SetReadLoopBeforeNextReadHook.
Test hooks can't be set in parallel, and we want the race detector
to notify us if two simultaneous tests try to set a hook.

Fixes #56032

Change-Id: I16be64913c426fc93d84abc6ad85dbd3bc191224
Reviewed-on: https://go-review.googlesource.com/c/go/+/438137
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: David Chase <drchase@google.com>
src/net/http/client_test.go
src/net/http/clientserver_test.go
src/net/http/export_test.go
src/net/http/fs_test.go
src/net/http/request_test.go
src/net/http/serve_test.go
src/net/http/sniff_test.go
src/net/http/transport_test.go