Skip to content

Commit e576205

Browse files
committed
Limit the verbose test workaround to "cobra.test" only
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.
1 parent 62e859a commit e576205

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

command.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"fmt"
2121
"io"
2222
"os"
23+
"path/filepath"
2324
"runtime"
2425
"strings"
2526
"time"
@@ -618,7 +619,8 @@ func (c *Command) Execute() (err error) {
618619

619620
var args []string
620621

621-
if len(c.args) == 0 && os.Args[0] == c.Name() {
622+
// Workaround FAIL with "go test -v" or "cobra.test -test.v", see #155
623+
if len(c.args) == 0 && filepath.Base(os.Args[0]) != "cobra.test" {
622624
args = os.Args[1:]
623625
} else {
624626
args = c.args

0 commit comments

Comments
 (0)