Commit 8cc6cb2f authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

test: return errors earlier in run.go

Fixes #8184.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/137510043
parent fcb4cabb
...@@ -626,6 +626,7 @@ func (t *test) run() { ...@@ -626,6 +626,7 @@ func (t *test) run() {
out, err := runcmd(append([]string{"go", "run", t.goFileName()}, args...)...) out, err := runcmd(append([]string{"go", "run", t.goFileName()}, args...)...)
if err != nil { if err != nil {
t.err = err t.err = err
return
} }
if strings.Replace(string(out), "\r\n", "\n", -1) != t.expectedOutput() { if strings.Replace(string(out), "\r\n", "\n", -1) != t.expectedOutput() {
t.err = fmt.Errorf("incorrect output\n%s", out) t.err = fmt.Errorf("incorrect output\n%s", out)
...@@ -640,6 +641,7 @@ func (t *test) run() { ...@@ -640,6 +641,7 @@ func (t *test) run() {
out, err := runcmd(append([]string{"go", "run", t.goFileName()}, args...)...) out, err := runcmd(append([]string{"go", "run", t.goFileName()}, args...)...)
if err != nil { if err != nil {
t.err = err t.err = err
return
} }
tfile := filepath.Join(t.tempDir, "tmp__.go") tfile := filepath.Join(t.tempDir, "tmp__.go")
if err := ioutil.WriteFile(tfile, out, 0666); err != nil { if err := ioutil.WriteFile(tfile, out, 0666); err != nil {
...@@ -649,6 +651,7 @@ func (t *test) run() { ...@@ -649,6 +651,7 @@ func (t *test) run() {
out, err = runcmd("go", "run", tfile) out, err = runcmd("go", "run", tfile)
if err != nil { if err != nil {
t.err = err t.err = err
return
} }
if string(out) != t.expectedOutput() { if string(out) != t.expectedOutput() {
t.err = fmt.Errorf("incorrect output\n%s", out) t.err = fmt.Errorf("incorrect output\n%s", out)
...@@ -659,6 +662,7 @@ func (t *test) run() { ...@@ -659,6 +662,7 @@ func (t *test) run() {
out, err := runcmd(append([]string{"go", "run", t.goFileName()}, args...)...) out, err := runcmd(append([]string{"go", "run", t.goFileName()}, args...)...)
if err != nil { if err != nil {
t.err = err t.err = err
return
} }
tfile := filepath.Join(t.tempDir, "tmp__.go") tfile := filepath.Join(t.tempDir, "tmp__.go")
err = ioutil.WriteFile(tfile, out, 0666) err = ioutil.WriteFile(tfile, out, 0666)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment