Skip to content

Commit

Permalink
In "go test" 1.13 and higher, you cannot call parse.Flags in init()
Browse files Browse the repository at this point in the history
In https://golang.org/doc/go1.13#testing

    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.

See:
  https://groups.google.com/d/msg/golang-nuts/rkCdS1EQwSM/4gbwNh0QAwAJ
  golang/go#21051
  https://go-review.googlesource.com/c/go/+/173722/
  • Loading branch information
Craig Rodrigues committed Feb 5, 2020
1 parent 425cb6d commit 54b127a
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions tests/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,6 @@ func ParseFlags() {
flag.StringVar(&bundleLocation, "bundle-location", defaultBundleLocation, "Path to support bundle output files")
flag.StringVar(&customConfigPath, "custom-config", "", "Path to custom configuration files")

flag.Parse()

appList, err := splitCsv(appListCSV)
if err != nil {
logrus.Fatalf("failed to parse app list: %v. err: %v", appListCSV, err)
Expand Down

0 comments on commit 54b127a

Please sign in to comment.