From 5a4efa4e2730cd0417e36d714d14ac8bafd89575 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 7 Nov 2012 12:33:54 -0800 Subject: test: run index test by default Running this test via "bash run" uncovered three different bugs (4344, 4348, 4353). We need to run it by default. R=golang-dev, rsc CC=golang-dev http://codereview.appspot.com/6832043 --- test/run.go | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'test/run.go') diff --git a/test/run.go b/test/run.go index 6b881eb1f..2b874d7df 100644 --- a/test/run.go +++ b/test/run.go @@ -128,7 +128,7 @@ func main() { if !*verbose && test.err == nil { continue } - fmt.Printf("%-10s %-20s: %s\n", test.action, test.goFileName(), errStr) + fmt.Printf("%-20s %-20s: %s\n", test.action, test.goFileName(), errStr) } if *summary { @@ -198,7 +198,7 @@ type test struct { donec chan bool // closed when done src string - action string // "compile", "build", "run", "errorcheck", "skip", "runoutput", "compiledir" + action string // "compile", "build", etc. tempDir string err error @@ -300,7 +300,7 @@ func (t *test) run() { fallthrough case "compile", "compiledir", "build", "run", "runoutput", "rundir": t.action = action - case "errorcheck", "errorcheckdir": + case "errorcheck", "errorcheckdir", "errorcheckoutput": t.action = action wantError = true for len(args) > 0 && strings.HasPrefix(args[0], "-") { @@ -467,7 +467,7 @@ func (t *test) run() { case "runoutput": useTmp = false - out, err := runcmd("go", "run", t.goFileName()) + out, err := runcmd(append([]string{"go", "run", t.goFileName()}, args...)...) if err != nil { t.err = err } @@ -484,6 +484,36 @@ func (t *test) run() { if string(out) != t.expectedOutput() { t.err = fmt.Errorf("incorrect output\n%s", out) } + + case "errorcheckoutput": + useTmp = false + out, err := runcmd(append([]string{"go", "run", t.goFileName()}, args...)...) + if err != nil { + t.err = err + } + tfile := filepath.Join(t.tempDir, "tmp__.go") + err = ioutil.WriteFile(tfile, out, 0666) + if err != nil { + t.err = fmt.Errorf("write tempfile:%s", err) + return + } + cmdline := []string{"go", "tool", gc, "-e", "-o", "a." + letter} + cmdline = append(cmdline, flags...) + cmdline = append(cmdline, tfile) + out, err = runcmd(cmdline...) + if wantError { + if err == nil { + t.err = fmt.Errorf("compilation succeeded unexpectedly\n%s", out) + return + } + } else { + if err != nil { + t.err = err + return + } + } + t.err = t.errorCheck(string(out), tfile, "tmp__.go") + return } } -- cgit v1.2.1