summaryrefslogtreecommitdiffstats
path: root/magefile.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-11-25 11:26:47 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-11-25 18:59:06 +0100
commit71597bd1adfb016a3ea1977068c37dce92d49458 (patch)
treedb44cac75323fc0b9e253aa687b9fb0d7491c2ff /magefile.go
parenta8e9f8389a61471fa372c815b216511201b56823 (diff)
mage: Restore -v behaviour
Diffstat (limited to 'magefile.go')
-rw-r--r--magefile.go30
1 files changed, 15 insertions, 15 deletions
diff --git a/magefile.go b/magefile.go
index 6fcf17b13..a888fb78d 100644
--- a/magefile.go
+++ b/magefile.go
@@ -159,31 +159,19 @@ func testGoFlags() string {
// Note that we don't run with the extended tag. Currently not supported in 32 bit.
func Test386() error {
env := map[string]string{"GOARCH": "386", "GOFLAGS": testGoFlags()}
- output, err := sh.OutputWith(env, goexe, "test", "./...")
- if err != nil {
- fmt.Printf(output)
- }
- return err
+ return runCmd(env, goexe, "test", "./...")
}
// Run tests
func Test() error {
env := map[string]string{"GOFLAGS": testGoFlags()}
- output, err := sh.OutputWith(env, goexe, "test", "./...", "-tags", buildTags())
- if err != nil {
- fmt.Printf(output)
- }
- return err
+ return runCmd(env, goexe, "test", "./...", "-tags", buildTags())
}
// Run tests with race detector
func TestRace() error {
env := map[string]string{"GOFLAGS": testGoFlags()}
- output, err := sh.OutputWith(env, goexe, "test", "-race", "./...", "-tags", buildTags())
- if err != nil {
- fmt.Printf(output)
- }
- return err
+ return runCmd(env, goexe, "test", "-race", "./...", "-tags", buildTags())
}
// Run gofmt linter
@@ -319,6 +307,18 @@ func TestCoverHTML() error {
return sh.Run(goexe, "tool", "cover", "-html="+coverAll)
}
+func runCmd(env map[string]string, cmd string, args ...string) error {
+ if mg.Verbose() {
+ return sh.RunWith(env, cmd, args...)
+ }
+ output, err := sh.OutputWith(env, cmd, args...)
+ if err != nil {
+ fmt.Fprint(os.Stderr, output)
+ }
+
+ return err
+}
+
func isGoLatest() bool {
return strings.Contains(runtime.Version(), "1.12")
}