aboutsummaryrefslogtreecommitdiff
path: root/src/encoding
diff options
context:
space:
mode:
authorZiheng Liu <lzhfromustc@gmail.com>2020-02-13 16:20:30 -0500
committerIan Lance Taylor <iant@golang.org>2020-02-27 19:04:17 +0000
commit42f8199290f27a65f2aba9f1f6b9bdfd2406612e (patch)
tree572e42c6d0be4d1a9daf2987f1704d43a05093cf /src/encoding
parentea3bfba87cfd7141870f975102029e2e341b4af3 (diff)
downloadgo-42f8199290f27a65f2aba9f1f6b9bdfd2406612e.tar.gz
go-42f8199290f27a65f2aba9f1f6b9bdfd2406612e.zip
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>
Diffstat (limited to 'src/encoding')
-rw-r--r--src/encoding/base64/base64_test.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/encoding/base64/base64_test.go b/src/encoding/base64/base64_test.go
index bc67036f5b..c2c9478a43 100644
--- a/src/encoding/base64/base64_test.go
+++ b/src/encoding/base64/base64_test.go
@@ -401,7 +401,7 @@ func TestDecoderIssue3577(t *testing.T) {
source: "VHdhcyBicmlsbGlnLCBhbmQgdGhlIHNsaXRoeSB0b3Zlcw==", // twas brillig...
nextc: next,
})
- errc := make(chan error)
+ errc := make(chan error, 1)
go func() {
_, err := ioutil.ReadAll(d)
errc <- err