Skip to content

Commit

Permalink
mage: Restore -v behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Nov 25, 2019
1 parent a8e9f83 commit 71597bd
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
}
Expand Down

0 comments on commit 71597bd

Please sign in to comment.