go test broken with parameters

Created on 27 Aug 2019  路  4Comments  路  Source: golang/go

It looks like go test fails if any parameters are passed to it.

For example:

$ go test ./...
flag provided but not defined: -test.testlogfile
Usage of /var/folders/g0/pp3c88hj5k50_zsc55c3wnb00000gn/T/go-build565133450/b001/dcrd.test:
FAIL    github.com/decred/dcrd  0.048s
...
$ go test -v . 
flag provided but not defined: -test.testlogfile
Usage of /var/folders/g0/pp3c88hj5k50_zsc55c3wnb00000gn/T/go-build782636389/b001/dcrd.test:
FAIL    github.com/decred/dcrd  0.046s
FAIL
### What version of Go are you using (`go version`)?
$ go version
go version go1.13rc1 darwin/amd64

and

$ go version
go version devel +1a423be Tue Aug 27 01:12:00 2019 +0000 openbsd/amd64

Does this issue reproduce with the latest release?

It works fine with 1.12

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

go env Output

$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/marco/Library/Caches/go-build"
GOENV="/Users/marco/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/marco/Documents/gopath"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/marco/Documents/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/marco/Documents/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/marco/Documents/gopath/src/github.com/decred/dcrd/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/g0/pp3c88hj5k50_zsc55c3wnb00000gn/T/go-build489241021=/tmp/go-build -gno-record-gcc-switches -fno-common"

and

$ gotip env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jrick/.cache/go-build"
GOENV="/home/jrick/.config/go/env"
GOEXE=""
GOFLAGS="-tags=netgo -ldflags=-extldflags=-static"
GOHOSTARCH="amd64"
GOHOSTOS="openbsd"
GONOPROXY=""
GONOSUMDB=""
GOOS="openbsd"
GOPATH="/home/jrick/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/jrick/sdk/gotip"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/jrick/sdk/gotip/pkg/tool/openbsd_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"

What did you do?

go test -v

What did you expect to see?

Tests running.

What did you see instead?

$ go test -v 
flag provided but not defined: -test.v
Usage of /var/folders/g0/pp3c88hj5k50_zsc55c3wnb00000gn/T/go-build958647978/b001/dcrd.test:
exit status 2
FAIL    github.com/decred/dcrd  0.279s
FrozenDueToAge WaitingForInfo

Most helpful comment

this works on some platforms (windows) and not on others (darwin/openbsd)

It should fail on all platforms: the underlying problem is due to init functions calling flag.Parse before the testing flags have been registered, and to my knowledge the testing init and registration order is the same across platforms.

All 4 comments

I just noticed that this is a duplicate of https://github.com/golang/go/issues/33774 however I'd like to point out that this works on some platforms (windows) and not on others (darwin/openbsd). This inconsistent behavior between platforms will cause all kinds of headaches for people working on multiplatform code. Can all platforms at least fail the same way so that when a repo is migrated to 1.13 at least the tests will fail everywhere the same?

this works on some platforms (windows) and not on others (darwin/openbsd)

It should fail on all platforms: the underlying problem is due to init functions calling flag.Parse before the testing flags have been registered, and to my knowledge the testing init and registration order is the same across platforms.

This is likely a duplicate of #31859, but it would be helpful to get more detail on the cross-platform aspect.

Ignore the part about windows. Our developer on windows was not testing in the same directory.

This can be closed as a duplicate.

Was this page helpful?
0 / 5 - 0 ratings