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

flag provided but not defined: -test.timeout #33774

Closed
shawnps opened this issue Aug 22, 2019 · 2 comments
Closed

flag provided but not defined: -test.timeout #33774

shawnps opened this issue Aug 22, 2019 · 2 comments

Comments

@shawnps
Copy link
Member

shawnps commented Aug 22, 2019

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

$ go version
go version go1.13rc1 darwin/amd64

Does this issue reproduce with the latest release?

Yes, on the release candidate but not on Go 1.12.

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

go env Output
$ go env
GOARCH="amd64"
GOOS="darwin"

What did you do?

Wrote a small test for code which contains flags being parsed inside an init function. All the test does is t.Skip().

foo.go:

package main

import (
	"flag"
	"fmt"
)

var foo string

func init() {

	flag.StringVar(&foo, "foo", "foo", "foo")
	flag.Parse()
}

func main() {
	fmt.Println("vim-go")
}

foo_test.go:

package main

import "testing"

func TestFoo(t *testing.T) {
	t.Skip()
}

What did you expect to see?

No errors.

What did you see instead?

➜  flag-test go test
flag provided but not defined: -test.timeout
Usage of /var/folders/c_/zhpj7wdd3dgb52c4zpy3vj840000gn/T/go-build238457999/b001/flag-test.test:
  -foo string
    	foo (default "foo")
exit status 2
FAIL	_/Users/shawn/flag-test	0.005s
@cespare
Copy link
Contributor

cespare commented Aug 22, 2019

See the Go 1.13 release notes:

Testing flags are now registered in the new Init function, which is invoked by the generated main function for the test. As a result, testing flags are now only registered when running a test binary, and packages that call flag.Parse during package initialization may cause tests to fail.

@bcmills
Copy link
Contributor

bcmills commented Aug 22, 2019

Duplicate of #31859

@bcmills bcmills marked this as a duplicate of #31859 Aug 22, 2019
@bcmills bcmills closed this as completed Aug 22, 2019
tisnik added a commit to tisnik/insights-operator-cli that referenced this issue Nov 22, 2019
marclop added a commit to marclop/go-licenser that referenced this issue Jun 3, 2020
Releases a new version `v0.3.1` and fixes the broken tests in go 1.13,
see golang/go#33774.

Additionally, does some minor tidy of the installed Go binaries.

Signed-off-by: Marc Lopez <[email protected]>
marclop added a commit to elastic/go-licenser that referenced this issue Jun 4, 2020
Releases a new version `v0.3.1` and fixes the broken tests in go 1.13,
see golang/go#33774.

Additionally, does some minor tidy of the installed Go binaries.

Signed-off-by: Marc Lopez <[email protected]>
@golang golang locked and limited conversation to collaborators Aug 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants