]> Cypherpunks repositories - gostls13.git/commitdiff
gobuilder: number of fixes
authorAlex Brainman <alex.brainman@gmail.com>
Mon, 6 Jun 2011 12:17:28 +0000 (22:17 +1000)
committerAlex Brainman <alex.brainman@gmail.com>
Mon, 6 Jun 2011 12:17:28 +0000 (22:17 +1000)
1) runLog to return err==nil if program runs, but returns exitcode!=0;
2) runLog to return err!=nil when fails to create log file;
3) print failed program name, not just "all.bash".

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4532117

misc/dashboard/builder/exec.go
misc/dashboard/builder/main.go

index 0db50913650a3971748a70a39cd898de7e4555d1..a042c569944bc6521327837a97028318b5059acd 100644 (file)
@@ -27,8 +27,11 @@ func run(envv []string, dir string, argv ...string) os.Error {
 }
 
 // runLog runs a process and returns the combined stdout/stderr, 
-// as well as writing it to logfile (if specified).
-func runLog(envv []string, logfile, dir string, argv ...string) (output string, exitStatus int, err os.Error) {
+// as well as writing it to logfile (if specified). It returns
+// process combined stdout and stderr output, exit status and error.
+// The error returned is nil, if process is started successfully,
+// even if exit status is not 0.
+func runLog(envv []string, logfile, dir string, argv ...string) (string, int, os.Error) {
        if *verbose {
                log.Println("runLog", argv)
        }
@@ -39,7 +42,7 @@ func runLog(envv []string, logfile, dir string, argv ...string) (output string,
        if logfile != "" {
                f, err := os.OpenFile(logfile, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0666)
                if err != nil {
-                       return
+                       return "", 0, err
                }
                defer f.Close()
                w = io.MultiWriter(f, b)
@@ -51,15 +54,13 @@ func runLog(envv []string, logfile, dir string, argv ...string) (output string,
        cmd.Stdout = w
        cmd.Stderr = w
 
-       err = cmd.Run()
-       output = b.String()
+       err := cmd.Run()
        if err != nil {
                if ws, ok := err.(*os.Waitmsg); ok {
-                       exitStatus = ws.ExitStatus()
+                       return b.String(), ws.ExitStatus(), nil
                }
-               return
        }
-       return
+       return b.String(), 0, nil
 }
 
 // useBash prefixes a list of args with 'bash' if the first argument
index 5ba5c11c3443acc2247b707d8aeb66d7e7ad261a..9377fbe3261105f317aac35d1d0f1d17b0b59122 100644 (file)
@@ -294,7 +294,7 @@ func (b *Builder) buildHash(hash string) (err os.Error) {
        logfile := path.Join(workpath, "build.log")
        buildLog, status, err := runLog(b.envv(), logfile, srcDir, *buildCmd)
        if err != nil {
-               return fmt.Errorf("all.bash: %s", err)
+               return fmt.Errorf("%s: %s", *buildCmd, err)
        }
 
        // if we're in external mode, build all packages and return