ginkgo: flag provided but not defined: -test.timeout (Go 1.13)
When trying to run the apt-buildpack integration tests on a computer running Go 1.13, we were unable to and got the following error:
-------------------------------------------------------------------
| |
| Ginkgo timed out waiting for all parallel nodes to report back! |
| |
-------------------------------------------------------------------
integration timed out. path: .
[1] flag provided but not defined: -test.timeout
[1] Usage of /tmp/ginkgo538951234/integration.test:
...
Our integration test script:
#!/usr/bin/env bash
set -euo pipefail
cd "$( dirname "${BASH_SOURCE[0]}" )/.."
source .envrc
./scripts/install_tools.sh
GINKGO_NODES=${GINKGO_NODES:-3}
GINKGO_ATTEMPTS=${GINKGO_ATTEMPTS:-2}
export CF_STACK=${CF_STACK:-cflinuxfs3}
UNCACHED_BUILDPACK_FILE=${UNCACHED_BUILDPACK_FILE:-""}
cd src/*/integration
echo "Run Uncached Buildpack"
BUILDPACK_FILE="$UNCACHED_BUILDPACK_FILE" \
ginkgo -r -mod vendor --flakeAttempts=$GINKGO_ATTEMPTS -nodes $GINKGO_NODES --slowSpecThreshold=60 -- --cached=false
Env:
root@b349d15677b6:/app# go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/app/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build280745408=/tmp/go-build -gno-record-gcc-switches"
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 18 (1 by maintainers)
Commits related to this issue
- Adapt test suites to Go 1.13 https://github.com/onsi/ginkgo/issues/602#issuecomment-555502868 https://github.com/SUSE/cf-nodejs-buildpack/commit/5e687e5c9548a6846627963a2c1bd6ff068e58bc — committed to SUSE/cf-php-buildpack by mudler 5 years ago
- Work around go issue with flag.Parse https://github.com/onsi/ginkgo/issues/602#issuecomment-559421839 — committed to brightbox/brightbox-cloud-controller-manager by NeilW 4 years ago
I can confirm that replacing
with
solves the issue.
As @dfreilich correctly pointed out, the
flag provided but not definederror occurs because of https://golang.org/doc/go1.13#testing:It occurs when
flag.Parseis called within theinitfunction. The solution is to moveflag.Parsefrom theinitfunction to somewhere else (e.g. tomainorBeforeSuite) For the example above this line must be moved.An example how to reproduce this error without using ginkgo can be found here. (I can reproduce it with the latest
go version go1.13.4 darwin/amd64.)I agree with @zhubuntu that this is not a Ginkgo issue. I therefore suggest to close this issue.
Looks like it’s a breaking change in Go 1.13. The solution is for users not to call
flag.Parse()in aninit()function. Please let us know if that does not work for you.In some cases explicit call for
testing.Init()before init() functions in suites may help:any update? are you planning to fix that?
Suspect this is the cause https://golang.org/doc/go1.13#testing
@patelpayal, there is a suggested approach here: https://github.com/onsi/ginkgo/issues/602#issuecomment-557313846
I am hitting this error
flag provided but not defined: -test.timeoutwithout having to use theflag.Parseanywhere in my codebase. Nor there is anyinitfunc My env:I think this is the test case problem, not the ginkgoproblem. As kubernetes/kubernetes#82742