Skip to content

cmd/go: go test -parallel=1 (disable parallel tests?) output is confusing #18118

@smcquay

Description

@smcquay

The tool behaves correctly but the output is misleading.

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

go version go1.7.3 darwin/amd64

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/sm"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/zv/dcwk1sd562z4rcl72g3vygqh0000gn/T/go-build135886187=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"

What did you do?

https://play.golang.org/p/uNOBr95MKU

then run

go test -v -parallel 1

What did you expect to see?

=== RUN   TestA
--- PASS: TestA (1.00s)
	foo_test.go:9: A
=== RUN   TestB
--- PASS: TestB (1.00s)
	foo_test.go:14: B
=== RUN   TestC
--- PASS: TestC (1.00s)
	foo_test.go:19: C
=== RUN   TestD
--- PASS: TestD (1.00s)
	foo_test.go:24: D
=== RUN   TestE
--- PASS: TestE (1.01s)
	foo_test.go:29: E
PASS
ok  	mcquay.me/ptest	5.023s

What did you see instead?

go test -v -parallel 1                                                                                                          
=== RUN   TestA
=== RUN   TestB
=== RUN   TestC
=== RUN   TestD
=== RUN   TestE
--- PASS: TestA (1.00s)
	foo_test.go:10: A
--- PASS: TestD (1.00s)
	foo_test.go:28: D
--- PASS: TestE (1.00s)
	foo_test.go:34: E
--- PASS: TestC (1.00s)
	foo_test.go:22: C
--- PASS: TestB (1.00s)
	foo_test.go:16: B
PASS
ok  	mcquay.me/ptest	5.011s

Note that it truly runs the tests serially, but the bunch of ===RUN output at the beginning makes one think it's still running in parallel.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions