diff options
author | Shenghou Ma <minux.ma@gmail.com> | 2012-04-20 23:45:43 +0800 |
---|---|---|
committer | Shenghou Ma <minux.ma@gmail.com> | 2012-04-20 23:45:43 +0800 |
commit | 872940503e95dfff5a4b9b47f59c6200c6fa2b21 (patch) | |
tree | 17450eb6f9862d7f2802026374341385d0eed8cb /test/run.go | |
parent | 71dc8cf4f07986d363090748bb01bb7790528a67 (diff) | |
download | go-872940503e95dfff5a4b9b47f59c6200c6fa2b21.tar.gz |
test: use testlib in a few more cases (part 2)
Introduced "runoutput" cmd for running generated program
R=golang-dev, iant, bradfitz, remyoudompheng
CC=golang-dev
http://codereview.appspot.com/5869049
Diffstat (limited to 'test/run.go')
-rw-r--r-- | test/run.go | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/test/run.go b/test/run.go index ac6e3c0e2..198863eab 100644 --- a/test/run.go +++ b/test/run.go @@ -172,7 +172,7 @@ type test struct { donec chan bool // closed when done src string - action string // "compile", "build", "run", "errorcheck", "skip" + action string // "compile", "build", "run", "errorcheck", "skip", "runoutput" tempDir string err error @@ -251,7 +251,7 @@ func (t *test) run() { case "cmpout": action = "run" // the run case already looks for <dir>/<test>.out files fallthrough - case "compile", "build", "run", "errorcheck": + case "compile", "build", "run", "errorcheck", "runoutput": t.action = action case "skip": t.action = "skip" @@ -316,6 +316,26 @@ func (t *test) run() { if string(out) != t.expectedOutput() { t.err = fmt.Errorf("incorrect output\n%s", out) } + + case "runoutput": + useTmp = false + out, err := runcmd("go", "run", t.goFileName()) + if err != nil { + t.err = fmt.Errorf("%s\n%s", err, out) + } + 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 + } + out, err = runcmd("go", "run", tfile) + if err != nil { + t.err = fmt.Errorf("%s\n%s", err, out) + } + if string(out) != t.expectedOutput() { + t.err = fmt.Errorf("incorrect output\n%s", out) + } } } |