Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After go upgrade to 1.15, the test code that can pass 1.13 cannot pass #42390

yangyiwei1143323451 opened this issue Nov 5, 2020 · 2 comments


Copy link

@yangyiwei1143323451 yangyiwei1143323451 commented Nov 5, 2020

What version of Go are you using (go version)?

$ go version
go 1.15

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
ubuntu 18.04
Linux mi 5.4.0-48-generic #52~18.04.1-Ubuntu SMP Thu Sep 10 12:50:22 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

What did you do?

I have a http server code and a test code for it. I can pass the test normally using go test -coverprofile=coverage.out -v in go1.13, but use go test -coverprofile=coverage.out in go1.15 -v will display could not shutdown the server: context canceled. There is no problem when using go test -v -cover, that is, only using go test -coverprofile=coverage.out -v in go1.15 will cause an error and fail the test
this is my server_test.go

	var wg sync.WaitGroup
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()
	go func() {
		defer wg.Done()

What did you expect to see?

=== RUN   TestServ
--- PASS: TestServ (2.79s)
INFO[0031] server is shutting down                       
INFO[0031] http server exited                            
coverage: xx of statements
ok  	xxxx/xxxx/xxxx/http	31.989s

What did you see instead?

=== RUN   TestServ
--- PASS: TestServ (2.79s)
INFO[0030] server is shutting down                       
INFO[0030] could not shutdown the server: context canceled
exit status 1
FAIL		xxxx/xxxx/xxxx/http	30.117s
Copy link

@ianlancetaylor ianlancetaylor commented Nov 5, 2020

Can you show us a complete, standalone example that demonstrates the problem? Not a code fragment, but a complete program that we can run. Thanks.

Copy link

@gopherbot gopherbot commented Dec 5, 2020

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@gopherbot gopherbot closed this Dec 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants