]> Cypherpunks repositories - gostls13.git/commitdiff
test: use testlib in a few more cases (part 2)
authorShenghou Ma <minux.ma@gmail.com>
Fri, 20 Apr 2012 15:45:43 +0000 (23:45 +0800)
committerShenghou Ma <minux.ma@gmail.com>
Fri, 20 Apr 2012 15:45:43 +0000 (23:45 +0800)
        Introduced "runoutput" cmd for running generated program

R=golang-dev, iant, bradfitz, remyoudompheng
CC=golang-dev
https://golang.org/cl/5869049

test/64bit.go
test/chan/select5.go
test/crlf.go
test/run
test/run.go
test/testlib

index 9e91a97fd5781b1fced3388844f50c1e0e7c16c1..7ad28ad4bc0e13bda3f0082aec42928352b6f38b 100644 (file)
@@ -1,6 +1,4 @@
-// $G $D/$F.go && $L $F.$A && ./$A.out >tmp.go &&
-// $G tmp.go && $L tmp.$A && ./$A.out || echo BUG: 64bit
-// rm -f tmp.go
+// runoutput
 
 // Copyright 2009 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
index 13cde1afe58e8ee0b7d6720e5056b1422006b83e..f72cfe4b461c2eee647ff4370b06af87d899288c 100644 (file)
@@ -1,6 +1,4 @@
-// $G $D/$F.go && $L $F.$A && ./$A.out >tmp.go &&
-// $G tmp.go && $L tmp.$A && ./$A.out || echo BUG: select5
-// rm -f tmp.go
+// runoutput
 
 // Copyright 2011 The Go Authors.  All rights reserved.
 // Use of this source code is governed by a BSD-style
index 292b63bf4b33bc6d6ff42a519ec8bf2993fd1069..2d56889b039abe6927d20f824616414997c782eb 100644 (file)
@@ -1,6 +1,4 @@
-// $G $D/$F.go && $L $F.$A && ./$A.out >tmp.go &&
-// $G tmp.go && $L tmp.$A && ./$A.out
-// rm -f tmp.go
+// runoutput
 
 // Copyright 2011 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
index 302578eaaa7a6dc9af66f9b3a41cea79ba966eb8..29a7905f0a480aa2dd06d45061f17c6bebba5934 100755 (executable)
--- a/test/run
+++ b/test/run
@@ -100,7 +100,7 @@ do
                        echo $i >>pass.out
                fi
                echo $(awk 'NR==1{print $2}' "$TMP2FILE") $D/$F >>times.out
-               rm -f $F.$A $A.out
+               rm -f $F.$A $A.out tmp.go
        ) done
 done | # clean up some stack noise
        egrep -v '^(r[0-9a-z]+|[cfg]s)  +0x'  |
index ac6e3c0e27600cd6bf1e5038f2c09baeac5f592f..198863eab8250f148781d4c123c9c88054963ff6 100644 (file)
@@ -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)
+               }
        }
 }
 
index 3858431a7e1b4b5a851d44112c149476693e12d8..9e0911526ac9c5dd679b9f1c2b6535a745367552 100644 (file)
@@ -13,6 +13,11 @@ build() {
        $G $D/$F.go && $L $F.$A
 }
 
+runoutput() {
+       go run "$D/$F.go" > tmp.go
+       go run tmp.go
+}
+
 run() {
        gofiles=""
        ingo=true