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.
This commit is contained in:
parent
62e859a9ed
commit
e5762054c9
@ -20,6 +20,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -618,7 +619,8 @@ func (c *Command) Execute() (err error) {
|
|||||||
|
|
||||||
var args []string
|
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:]
|
args = os.Args[1:]
|
||||||
} else {
|
} else {
|
||||||
args = c.args
|
args = c.args
|
||||||
|
Loading…
Reference in New Issue
Block a user