mirror of
https://github.com/golang/go
synced 2024-11-22 00:44:39 -07:00
gobuilder: write build and benchmarking logs to disk
R=rsc CC=golang-dev https://golang.org/cl/2637041
This commit is contained in:
parent
7de5e6e84d
commit
b3601a5c5b
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"exec"
|
"exec"
|
||||||
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@ -21,8 +22,9 @@ func run(envv []string, dir string, argv ...string) os.Error {
|
|||||||
return p.Close()
|
return p.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// runLog runs a process and returns the combined stdout/stderr
|
// runLog runs a process and returns the combined stdout/stderr,
|
||||||
func runLog(envv []string, dir string, argv ...string) (output string, exitStatus int, err os.Error) {
|
// 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) {
|
||||||
bin, err := pathLookup(argv[0])
|
bin, err := pathLookup(argv[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -34,15 +36,24 @@ func runLog(envv []string, dir string, argv ...string) (output string, exitStatu
|
|||||||
}
|
}
|
||||||
defer p.Close()
|
defer p.Close()
|
||||||
b := new(bytes.Buffer)
|
b := new(bytes.Buffer)
|
||||||
_, err = b.ReadFrom(p.Stdout)
|
var w io.Writer = b
|
||||||
|
if logfile != "" {
|
||||||
|
f, err := os.Open(logfile, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
w = io.MultiWriter(f, b)
|
||||||
|
}
|
||||||
|
_, err = io.Copy(w, p.Stdout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w, err := p.Wait(0)
|
wait, err := p.Wait(0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return b.String(), w.WaitStatus.ExitStatus(), nil
|
return b.String(), wait.WaitStatus.ExitStatus(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find bin in PATH if a relative or absolute path hasn't been specified
|
// Find bin in PATH if a relative or absolute path hasn't been specified
|
||||||
|
@ -45,7 +45,7 @@ func getCommit(rev string) (c Commit, err os.Error) {
|
|||||||
|
|
||||||
func getCommitParts(rev string) (parts []string, err os.Error) {
|
func getCommitParts(rev string) (parts []string, err os.Error) {
|
||||||
const format = "{rev}>{node}>{author|escape}>{date}>{desc}"
|
const format = "{rev}>{node}>{author|escape}>{date}>{desc}"
|
||||||
s, _, err := runLog(nil, goroot,
|
s, _, err := runLog(nil, "", goroot,
|
||||||
"hg", "log", "-r", rev, "-l", "1", "--template", format)
|
"hg", "log", "-r", rev, "-l", "1", "--template", format)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
@ -82,7 +82,7 @@ func main() {
|
|||||||
if *buildRevision != "" {
|
if *buildRevision != "" {
|
||||||
c, err := getCommit(*buildRevision)
|
c, err := getCommit(*buildRevision)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Exit("Error finding revision:", err)
|
log.Exit("Error finding revision: ", err)
|
||||||
}
|
}
|
||||||
for _, b := range builders {
|
for _, b := range builders {
|
||||||
if err := b.buildCommit(c); err != nil {
|
if err := b.buildCommit(c); err != nil {
|
||||||
@ -138,7 +138,8 @@ func runBenchmark(r BenchRequest) {
|
|||||||
"GOARCH=" + r.builder.goarch,
|
"GOARCH=" + r.builder.goarch,
|
||||||
"PATH=" + bin + ":" + os.Getenv("PATH"),
|
"PATH=" + bin + ":" + os.Getenv("PATH"),
|
||||||
}
|
}
|
||||||
benchLog, _, err := runLog(env, pkg, "gomake", "bench")
|
logfile := path.Join(r.path, "bench.log")
|
||||||
|
benchLog, _, err := runLog(env, logfile, pkg, "gomake", "bench")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(r.builder.name, "gomake bench:", err)
|
log.Println(r.builder.name, "gomake bench:", err)
|
||||||
return
|
return
|
||||||
@ -195,7 +196,6 @@ func (b *Builder) build() bool {
|
|||||||
if c == nil {
|
if c == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
log.Println(b.name, "building", c.num)
|
|
||||||
err = b.buildCommit(*c)
|
err = b.buildCommit(*c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
@ -233,6 +233,8 @@ func (b *Builder) buildCommit(c Commit) (err os.Error) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
log.Println(b.name, "building", c.num)
|
||||||
|
|
||||||
// create place in which to do work
|
// create place in which to do work
|
||||||
workpath := path.Join(buildroot, b.name+"-"+strconv.Itoa(c.num))
|
workpath := path.Join(buildroot, b.name+"-"+strconv.Itoa(c.num))
|
||||||
err = os.Mkdir(workpath, mkdirPerm)
|
err = os.Mkdir(workpath, mkdirPerm)
|
||||||
@ -269,7 +271,8 @@ func (b *Builder) buildCommit(c Commit) (err os.Error) {
|
|||||||
srcDir := path.Join(workpath, "go", "src")
|
srcDir := path.Join(workpath, "go", "src")
|
||||||
|
|
||||||
// build
|
// build
|
||||||
buildLog, status, err := runLog(env, srcDir, *buildCmd)
|
logfile := path.Join(workpath, "build.log")
|
||||||
|
buildLog, status, err := runLog(env, logfile, srcDir, *buildCmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("all.bash: %s", err)
|
return fmt.Errorf("all.bash: %s", err)
|
||||||
}
|
}
|
||||||
@ -311,8 +314,7 @@ func (b *Builder) buildCommit(c Commit) (err os.Error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("tar: %s", err)
|
return fmt.Errorf("tar: %s", err)
|
||||||
}
|
}
|
||||||
err = run(nil, workpath, "python",
|
err = run(nil, workpath, path.Join(goroot, codePyScript),
|
||||||
path.Join(goroot, codePyScript),
|
|
||||||
"-s", release,
|
"-s", release,
|
||||||
"-p", codeProject,
|
"-p", codeProject,
|
||||||
"-u", b.codeUsername,
|
"-u", b.codeUsername,
|
||||||
|
Loading…
Reference in New Issue
Block a user