capture logs when executing goc run

This commit is contained in:
jichangjun 2020-06-15 15:54:36 +08:00
parent c82e61dcfe
commit 3dd2c9cd21
2 changed files with 9 additions and 4 deletions

View File

@ -40,6 +40,7 @@ goc run .
gocBuild.GoRunExecFlag = goRunExecFlag
gocBuild.GoRunArguments = goRunArguments
defer gocBuild.Clean()
// start goc server
var l = newLocalListener()
go cover.GocServer(ioutil.Discard).RunListener(l)

View File

@ -130,11 +130,15 @@ func (b *Build) Run() {
}
log.Printf("go build cmd is: %v", cmd.Args)
out, err := cmd.CombinedOutput()
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Start()
if err != nil {
log.Fatalf("Fail to execute: %v. The error is: %v, the stdout/stderr is: %v", cmd.Args, err, string(out))
log.Fatalf("Fail to start command: %v. The error is: %v", cmd.Args, err)
}
if len(out) > 0 {
fmt.Println(string(out))
if err = cmd.Wait(); err != nil {
log.Fatalf("Fail to execute command: %v. The error is: %v", cmd.Args, err)
}
}