diff options
Diffstat (limited to 'vendor/github.com/spf13/cobra/bash_completions_test.go')
-rw-r--r-- | vendor/github.com/spf13/cobra/bash_completions_test.go | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/vendor/github.com/spf13/cobra/bash_completions_test.go b/vendor/github.com/spf13/cobra/bash_completions_test.go index 185570b2b..7511376ae 100644 --- a/vendor/github.com/spf13/cobra/bash_completions_test.go +++ b/vendor/github.com/spf13/cobra/bash_completions_test.go @@ -2,16 +2,12 @@ package cobra import ( "bytes" - "fmt" "os" "os/exec" "strings" "testing" ) -var _ = fmt.Println -var _ = os.Stderr - func checkOmit(t *testing.T, found, unexpected string) { if strings.Contains(found, unexpected) { t.Errorf("Unexpected response.\nGot: %q\nBut should not have!\n", unexpected) @@ -178,3 +174,19 @@ func TestBashCompletionDeprecatedFlag(t *testing.T) { t.Errorf("expected completion to not include %q flag: Got %v", flagName, bashCompletion) } } + +func BenchmarkBashCompletion(b *testing.B) { + c := initializeWithRootCmd() + cmdEcho.AddCommand(cmdTimes) + c.AddCommand(cmdEcho, cmdPrint, cmdDeprecated, cmdColon) + + buf := new(bytes.Buffer) + + b.ResetTimer() + for i := 0; i < b.N; i++ { + buf.Reset() + if err := c.GenBashCompletion(buf); err != nil { + b.Fatal(err) + } + } +} |