Skip to content

Commit

Permalink
Limit the verbose test workaround to "cobra.test" only
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
anthonyfok committed Nov 8, 2015
1 parent 62e859a commit e576205
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion command.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"io"
"os"
"path/filepath"
"runtime"
"strings"
"time"
Expand Down Expand Up @@ -618,7 +619,8 @@ func (c *Command) Execute() (err error) {

var args []string

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

0 comments on commit e576205

Please sign in to comment.