You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have unit tests that cover creating cobra commands, and when I run them using Ginkgo, I get an error about an unknown flag that I never explicitly added to the command:
The --test.timeout flag is one of the arguments that Ginkgo passes to the compiled Ginkgo test binary and has nothing to do with the command under test.
This only happens with commands that have no arguments and seems to be related to this line of code:
Problem
I have unit tests that cover creating cobra commands, and when I run them using Ginkgo, I get an error about an unknown flag that I never explicitly added to the command:
The
--test.timeout
flag is one of the arguments that Ginkgo passes to the compiled Ginkgo test binary and has nothing to do with the command under test.This only happens with commands that have no arguments and seems to be related to this line of code:
cobra/command.go
Line 1080 in bcfcff7
Expected behavior
Cobra does not add the os.Args to the command's args when they are testing-related.
Steps to reproduce
To reproduce, please see my gist where I have recreated the problem with minimal code: https://gist.github.com/kate-osborn/f21aec497bf7ccb81d73ffcfc5e963b0.
The gist includes instructions on how to run the tests.
Environment
cobra version: v1.8.0
ginkgo version: v2.15.0
The text was updated successfully, but these errors were encountered: