1
0
mirror of https://github.com/golang/go synced 2024-11-25 03:27:58 -07:00

builder: drop recover blocks

The one time they recovered from anything they obscured a useful stack
trace. We're better off just crashing hard.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5577073
This commit is contained in:
Andrew Gerrand 2012-01-30 14:53:48 +11:00
parent faa1bf04fd
commit 0f2659a323

View File

@ -230,12 +230,6 @@ func (b *Builder) buildExternal() {
// and builds it if one is found. // and builds it if one is found.
// It returns true if a build was attempted. // It returns true if a build was attempted.
func (b *Builder) build() bool { func (b *Builder) build() bool {
defer func() {
err := recover()
if err != nil {
log.Println(b.name, "build:", err)
}
}()
hash, err := b.todo("build-go-commit", "", "") hash, err := b.todo("build-go-commit", "", "")
if err != nil { if err != nil {
log.Println(err) log.Println(err)
@ -245,7 +239,6 @@ func (b *Builder) build() bool {
return false return false
} }
// Look for hash locally before running hg pull. // Look for hash locally before running hg pull.
if _, err := fullHash(goroot, hash[:12]); err != nil { if _, err := fullHash(goroot, hash[:12]); err != nil {
// Don't have hash, so run hg pull. // Don't have hash, so run hg pull.
if err := run(nil, goroot, "hg", "pull"); err != nil { if err := run(nil, goroot, "hg", "pull"); err != nil {
@ -260,33 +253,24 @@ func (b *Builder) build() bool {
return true return true
} }
func (b *Builder) buildHash(hash string) (err error) { func (b *Builder) buildHash(hash string) error {
defer func() {
if err != nil {
err = fmt.Errorf("%s build: %s: %s", b.name, hash, err)
}
}()
log.Println(b.name, "building", hash) log.Println(b.name, "building", hash)
// create place in which to do work // create place in which to do work
workpath := path.Join(*buildroot, b.name+"-"+hash[:12]) workpath := path.Join(*buildroot, b.name+"-"+hash[:12])
err = os.Mkdir(workpath, mkdirPerm) if err := os.Mkdir(workpath, mkdirPerm); err != nil {
if err != nil { return err
return
} }
defer os.RemoveAll(workpath) defer os.RemoveAll(workpath)
// clone repo // clone repo
err = run(nil, workpath, "hg", "clone", goroot, "go") if err := run(nil, workpath, "hg", "clone", goroot, "go"); err != nil {
if err != nil { return err
return
} }
// update to specified revision // update to specified revision
err = run(nil, path.Join(workpath, "go"), "hg", "update", hash) if err := run(nil, path.Join(workpath, "go"), "hg", "update", hash); err != nil {
if err != nil { return err
return
} }
srcDir := path.Join(workpath, "go", "src") srcDir := path.Join(workpath, "go", "src")
@ -323,24 +307,22 @@ func (b *Builder) buildHash(hash string) (err error) {
// finish here if codeUsername and codePassword aren't set // finish here if codeUsername and codePassword aren't set
if b.codeUsername == "" || b.codePassword == "" || !*buildRelease { if b.codeUsername == "" || b.codePassword == "" || !*buildRelease {
return return nil
} }
// if this is a release, create tgz and upload to google code // if this is a release, create tgz and upload to google code
releaseHash, release, err := firstTag(binaryTagRe) releaseHash, release, err := firstTag(binaryTagRe)
if hash == releaseHash { if hash == releaseHash {
// clean out build state // clean out build state
err = run(b.envv(), srcDir, "./clean.bash", "--nopkg") if err := run(b.envv(), srcDir, "./clean.bash", "--nopkg"); err != nil {
if err != nil {
return fmt.Errorf("clean.bash: %s", err) return fmt.Errorf("clean.bash: %s", err)
} }
// upload binary release // upload binary release
fn := fmt.Sprintf("go.%s.%s-%s.tar.gz", release, b.goos, b.goarch) fn := fmt.Sprintf("go.%s.%s-%s.tar.gz", release, b.goos, b.goarch)
err = run(nil, workpath, "tar", "czf", fn, "go") if err := run(nil, workpath, "tar", "czf", fn, "go"); err != nil {
if err != nil {
return fmt.Errorf("tar: %s", err) return fmt.Errorf("tar: %s", err)
} }
err = run(nil, workpath, path.Join(goroot, codePyScript), err := run(nil, workpath, path.Join(goroot, codePyScript),
"-s", release, "-s", release,
"-p", codeProject, "-p", codeProject,
"-u", b.codeUsername, "-u", b.codeUsername,
@ -352,7 +334,7 @@ func (b *Builder) buildHash(hash string) (err error) {
} }
} }
return return nil
} }
func (b *Builder) buildSubrepos(goRoot, goHash string) { func (b *Builder) buildSubrepos(goRoot, goHash string) {
@ -571,13 +553,6 @@ const xmlLogTemplate = `
// commitPoll pulls any new revisions from the hg server // commitPoll pulls any new revisions from the hg server
// and tells the server about them. // and tells the server about them.
func commitPoll(key, pkg string) { func commitPoll(key, pkg string) {
// Catch unexpected panics.
defer func() {
if err := recover(); err != nil {
log.Printf("commitPoll panic: %s", err)
}
}()
pkgRoot := goroot pkgRoot := goroot
if pkg != "" { if pkg != "" {
@ -687,12 +662,7 @@ func addCommit(pkg, hash, key string) bool {
} }
// fullHash returns the full hash for the given Mercurial revision. // fullHash returns the full hash for the given Mercurial revision.
func fullHash(root, rev string) (hash string, err error) { func fullHash(root, rev string) (string, error) {
defer func() {
if err != nil {
err = fmt.Errorf("fullHash: %s: %s", rev, err)
}
}()
s, _, err := runLog(nil, "", root, s, _, err := runLog(nil, "", root,
"hg", "log", "hg", "log",
"--encoding=utf-8", "--encoding=utf-8",
@ -701,7 +671,7 @@ func fullHash(root, rev string) (hash string, err error) {
"--template={node}", "--template={node}",
) )
if err != nil { if err != nil {
return return "", nil
} }
s = strings.TrimSpace(s) s = strings.TrimSpace(s)
if s == "" { if s == "" {