-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
adds check to see if command name and os.Args[0] is the same before... #155
Conversation
…pplying os.Args as it was leading appending false arguments from the test suite
what test was failing? |
The RunRoot with no args and the hidden command tests because it was trying
|
@eparis sorry, I wasn't at my computer but those are the two. Usage: Flags: Error: unknown shorthand flag: 't' in -test.v=true |
so you ran |
Yes because -v is just the verbose output of what you are running. The fact
|
The suite passes because it is correct and passing. Adding What's happening is that BUT cobra doesn't use the golang "flag" package, it uses "pflag" which does its own command line argument parsing. The pflag command line has no idea what Whew. Ok, maybe that makes sense why Thanks for sticking with me! |
Course. The patch just checks if the command is actually the cobra command
|
@eparis is there anything I need to do with this PR? |
Sure. I can put a PR up for it today again. |
Cool, thanks! :-) |
so that full path to the executable or a renamed executable parses command-line arguments correctly as before. Special thanks to @apriendeau for discovering "go test -v" failing and for providing the initial workaround, see #155 and subsequent discussions.
See spf13/cobra#155 Errors can still be encountered when, for example, using precomiled tests. Explicitly setting consttucted command args to the empty slice ensures hidding any futher edge cases.
See spf13/cobra#155 Errors can still be encountered when, for example, using precomiled tests. Explicitly setting constructed command args to the empty slice ensures we avoid hitting any futher edge cases.
* update root and version structure and help text * fix: limit openshift int test with tag * refactor: commands to use simplifed, unified constructor * fix ineffectual assignment lint error * cleanup * add repository to run command * callout for forthcoming s2i builder impl * lint errors * re-add the deferred client factory * remove setNamespaceFlag now that it is persistent * avoid side-effect of global-mutating deploy tests * reduce line-by-line difference for PR ease * simplificaiton of tests and comment lines for further PR ease purposes * reduce inconsequential differences for ease of PR * tests to RootCommandConfig * review comment updates * fix lint errors * replace stdlib Setenv in tests Using t.Setenv will require an update to go1.17, which is out of scope for this PR. * pass ClientFactory throughout * explicitly empty test command args See spf13/cobra#155 Errors can still be encountered when, for example, using precomiled tests. Explicitly setting constructed command args to the empty slice ensures we avoid hitting any futher edge cases.
* update root and version structure and help text * fix: limit openshift int test with tag * refactor: commands to use simplifed, unified constructor * fix ineffectual assignment lint error * cleanup * add repository to run command * callout for forthcoming s2i builder impl * lint errors * re-add the deferred client factory * remove setNamespaceFlag now that it is persistent * avoid side-effect of global-mutating deploy tests * reduce line-by-line difference for PR ease * simplificaiton of tests and comment lines for further PR ease purposes * reduce inconsequential differences for ease of PR * tests to RootCommandConfig * review comment updates * fix lint errors * replace stdlib Setenv in tests Using t.Setenv will require an update to go1.17, which is out of scope for this PR. * pass ClientFactory throughout * explicitly empty test command args See spf13/cobra#155 Errors can still be encountered when, for example, using precomiled tests. Explicitly setting constructed command args to the empty slice ensures we avoid hitting any futher edge cases.
applying os.Args as it was leading appending false arguments from the test suite. This was causing the test suite to fail. All tests should be passing now.