Skip to content
Myr

Add benchmark for GenBashCompletion

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Albert Nigmatzianov · committed by Albert Nigmatzianov · parent de6b168 · Browse files · 1 file+20 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+20 added−0 removed

  • other:+20 added−0 removed

1 file+20 added−0 removed

modified:bash_completions_test.go+20 added
1package cobra23import (4 "bytes"5 "io/ioutil"6 "os"7 "os/exec"8 "strings"9 "testing"
164 unmodified lines
174 if strings.Contains(bashCompletion, flagName) {175 t.Errorf("expected completion to not include %q flag: Got %v", flagName, bashCompletion)176 }177}178179func BenchmarkBashCompletion(b *testing.B) {180 c := initializeWithRootCmd()181 cmdEcho.AddCommand(cmdTimes)182 c.AddCommand(cmdEcho, cmdPrint, cmdDeprecated, cmdColon)183184 file, err := ioutil.TempFile("", "")185 if err != nil {186 b.Fatal(err)187 }188 defer os.Remove(file.Name())189190 b.ResetTimer()191 for i := 0; i < b.N; i++ {192 if err := c.GenBashCompletion(file); err != nil {193 b.Fatal(err)194 }195 }196}