]> Cypherpunks.ru repositories - gostls13.git/commit
all: fix incorrect channel and API usage in some unit tests
authorZiheng Liu <lzhfromustc@gmail.com>
Thu, 13 Feb 2020 21:20:30 +0000 (16:20 -0500)
committerIan Lance Taylor <iant@golang.org>
Thu, 27 Feb 2020 19:04:17 +0000 (19:04 +0000)
commit42f8199290f27a65f2aba9f1f6b9bdfd2406612e
tree572e42c6d0be4d1a9daf2987f1704d43a05093cf
parentea3bfba87cfd7141870f975102029e2e341b4af3
all: fix incorrect channel and API usage in some unit tests

This CL changes some unit test functions, making sure that these tests (and goroutines spawned during test) won't block.
Since they are just test functions, I use one CL to fix them all. I hope this won't cause trouble to reviewers and can save time for us.
There are three main categories of incorrect logic fixed by this CL:
1. Use testing.Fatal()/Fatalf() in spawned goroutines, which is forbidden by Go's document.
2. Channels are used in such a way that, when errors or timeout happen, the test will be blocked and never return.
3. Channels are used in such a way that, when errors or timeout happen, the test can return but some spawned goroutines will be leaked, occupying resource until all other tests return and the process is killed.

Change-Id: I3df931ec380794a0cf1404e632c1dd57c65d63e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/219380
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
14 files changed:
src/cmd/compile/internal/gc/lex_test.go
src/cmd/compile/internal/gc/testdata/dupLoad_test.go
src/crypto/tls/handshake_client_test.go
src/crypto/tls/handshake_server_test.go
src/crypto/tls/tls_test.go
src/encoding/base64/base64_test.go
src/expvar/expvar_test.go
src/go/printer/printer_test.go
src/internal/poll/fd_mutex_test.go
src/log/syslog/syslog_test.go
src/net/http/serve_test.go
src/net/http/transport_test.go
src/os/os_test.go
src/sync/atomic/value_test.go