Skip to content
Myr

Limit the verbose test workaround to "cobra.test" only

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

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.

authored by Anthony Fok · committed by Anthony Fok · parent 62e859a · Browse files · 1 file+3 added−1 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+3 added−1 removed

  • other:+3 added−1 removed

1 file+3 added−1 removed

modified:command.go+3 added-1 removed
18 unmodified lines
19 "bytes"20 "fmt"21 "io"22 "os"23 "path/filepath"24 "runtime"25 "strings"26 "time"27
590 unmodified lines
618 c.initHelpCmd()619620 var args []string621621 if len(c.args) == 0 && os.Args[0] == c.Name() {622 // Workaround FAIL with "go test -v" or "cobra.test -test.v", see #155623 if len(c.args) == 0 && filepath.Base(os.Args[0]) != "cobra.test" {624 args = os.Args[1:]625 } else {626 args = c.args627 }
553 unmodified lines