cucumber / godog

Cucumber for golang
MIT License
2.25k stars 249 forks source link

`godog.godog.BindCommandLineFlags` does not seems to work with custom godog.Options #369

Closed radtriste closed 3 years ago

radtriste commented 3 years ago

Please answer these questions before submitting a bug report.

What version of godog are you using?

v0.11.0

What version of Go are you using?

go version go1.14.13 linux/amd64

What did you do?

in my main_test.go

var (
    godogOpts = godog.Options{
        Output:    colors.Colored(os.Stdout),
        Format:    "junit",
        Randomize: time.Now().UTC().UnixNano(),
        Tags:      disabledTag,
    }
)

func init() {
    godog.BindCommandLineFlags("godog.", &godogOpts)
}

launching command go test ./test --godog.tags=@test

What did you expect to see?

Test should run

What did you see instead?

go test ./test --godog.tags=@test
flag provided but not defined: -godog.tags
Usage of /tmp/go-build429551473/b001/test.test:
  -kubeconfig string
        Paths to a kubeconfig. Only required if out-of-cluster.
  -master --kubeconfig
        (Deprecated: switch to --kubeconfig) The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
  -test.bench regexp
        run only benchmarks matching regexp
  -test.benchmem
        print memory allocations for benchmarks
  -test.benchtime d
        run each benchmark for duration d (default 1s)
  -test.blockprofile file
        write a goroutine blocking profile to file
  -test.blockprofilerate rate
        set blocking profile rate (see runtime.SetBlockProfileRate) (default 1)
  -test.count n
        run tests and benchmarks n times (default 1)
  -test.coverprofile file
        write a coverage profile to file
  -test.cpu list
        comma-separated list of cpu counts to run each test with
  -test.cpuprofile file
        write a cpu profile to file
  -test.failfast
        do not start new tests after the first test failure
  -test.list regexp
        list tests, examples, and benchmarks matching regexp then exit
  -test.memprofile file
        write an allocation profile to file
  -test.memprofilerate rate
        set memory allocation profiling rate (see runtime.MemProfileRate)
  -test.mutexprofile string
        write a mutex contention profile to the named file after execution
  -test.mutexprofilefraction int
        if >= 0, calls runtime.SetMutexProfileFraction() (default 1)
  -test.outputdir dir
        write profiles to dir
  -test.parallel n
        run at most n tests in parallel (default 8)
  -test.run regexp
        run only tests and examples matching regexp
  -test.short
        run smaller test suite to save time
  -test.testlogfile file
        write test action log to file (for use only by cmd/go)
  -test.timeout d
        panic test binary after duration d (default 0, timeout disabled)
  -test.trace file
        write an execution trace to file
  -test.v
        verbose: print additional output
FAIL    github.com/kiegroup/kogito-cloud-operator/test  0.036s
FAIL

Additional context

Not using godog app but running as go test framework It is working with v0.10.0 and line godog.BindFlags("godog.", flag.CommandLine, &godogOpts) which is now deprecated

radtriste commented 3 years ago

I followed as documented: https://github.com/cucumber/godog#running-godog-with-go-test

lonnblad commented 3 years ago

Hi @radtriste

Using BindCommandLineFlags(prefix, &opts) also requires you to use "github.com/spf13/pflag" to parse the flags. Could this be the issue?

release-notes

radtriste commented 3 years ago

my go.sum

github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.1-0.20171106142849-4c012f6dcd95/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=

so it is there

radtriste commented 3 years ago

oh I see now ... it seems the code is still using the internal flag let me update that and come back to you

radtriste commented 3 years ago

looks a bit better. Thank you (and closing this)

lonnblad commented 3 years ago

great! :)

radtriste commented 3 years ago

thx for reactivity and sorry for the time lost ...

lonnblad commented 3 years ago

no worries, happy to help! :)