]> Cypherpunks repositories - gostls13.git/commitdiff
test: add a compiledir pattern in run.go
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Mon, 30 Jul 2012 19:12:05 +0000 (21:12 +0200)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Mon, 30 Jul 2012 19:12:05 +0000 (21:12 +0200)
The compiledir pattern compiles all files xxx.dir/*.go
in lexicographic order (which is assumed to coincide with
the topological order of dependencies).

R=rsc
CC=golang-dev, remy
https://golang.org/cl/6440048

test/fixedbugs/bug088.go
test/fixedbugs/bug106.go
test/fixedbugs/bug282.go
test/fixedbugs/bug306.go
test/fixedbugs/bug377.go
test/fixedbugs/bug396.go
test/fixedbugs/bug404.go
test/fixedbugs/bug407.go
test/run.go
test/testlib

index 9715a703cb156905cccc18da8e9581f60a5cf2c3..3b99da84d4ba1d6a0ae65397970314f5d08475f9 100644 (file)
@@ -1,4 +1,4 @@
-// $G $D/$F.dir/bug0.go && $G $D/$F.dir/bug1.go || echo BUG: fails incorrectly
+// compiledir
 
 // Copyright 2009 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
index 1874b204491203dee8e0f8976a8165ad053312d8..3b99da84d4ba1d6a0ae65397970314f5d08475f9 100644 (file)
@@ -1,4 +1,4 @@
-// $G $D/$F.dir/bug0.go && $G $D/$F.dir/bug1.go || echo BUG: failed to compile
+// compiledir
 
 // Copyright 2009 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
index 463f21e941a0a70b5c6e8f7a318ac001c9724876..3b99da84d4ba1d6a0ae65397970314f5d08475f9 100644 (file)
@@ -1,4 +1,4 @@
-// $G $D/$F.dir/p1.go && $G $D/$F.dir/p2.go
+// compiledir
 
 // Copyright 2009 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
index a0a43507dcb88552bb4c63cf1bbc1f841b371d19..e8967c25ddcf6f0ffaa8a126eda29d5a65d0b890 100644 (file)
@@ -1,4 +1,4 @@
-// $G $D/$F.dir/p1.go && $G $D/$F.dir/p2.go
+// compiledir
 
 // Copyright 2010 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
index e905e34d683f1e210db8a817c812bec2e16a4dc2..22df005b2a23708eec061a23c8816adc748b7683 100644 (file)
@@ -1,4 +1,4 @@
-// $G $D/$F.dir/one.go && $G $D/$F.dir/two.go
+// compiledir
 
 // Copyright 2011 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
index 50af6006fbe698c60458fbbcf1a8c53ff68acafd..48b79e01b894a128edb9c5c4a839674a5ead3156 100644 (file)
@@ -1,4 +1,4 @@
-// $G $D/$F.dir/one.go && $G $D/$F.dir/two.go
+// compiledir
 
 // Copyright 2011 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
index ac9e575bb593f7641bbe1e3c48195bd3ece2a0e5..481acda3284a8f2554c4b7b91932b0e9e25568bc 100644 (file)
@@ -1,4 +1,4 @@
-// $G $D/$F.dir/one.go && $G $D/$F.dir/two.go
+// compiledir
 
 // Copyright 2012 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
index 50af6006fbe698c60458fbbcf1a8c53ff68acafd..48b79e01b894a128edb9c5c4a839674a5ead3156 100644 (file)
@@ -1,4 +1,4 @@
-// $G $D/$F.dir/one.go && $G $D/$F.dir/two.go
+// compiledir
 
 // Copyright 2011 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
index 198863eab8250f148781d4c123c9c88054963ff6..e1d97e9eef771aa0d1fd7582ce6df36ab7a237b1 100644 (file)
@@ -216,6 +216,10 @@ func (t *test) goFileName() string {
        return filepath.Join(t.dir, t.gofile)
 }
 
+func (t *test) goDirName() string {
+       return filepath.Join(t.dir, strings.Replace(t.gofile, ".go", ".dir", -1))
+}
+
 // run runs a test.
 func (t *test) run() {
        defer close(t.donec)
@@ -251,7 +255,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", "runoutput":
+       case "compile", "compiledir", "build", "run", "errorcheck", "runoutput":
                t.action = action
        case "skip":
                t.action = "skip"
@@ -301,6 +305,23 @@ func (t *test) run() {
                        t.err = fmt.Errorf("%s\n%s", err, out)
                }
 
+       case "compiledir":
+               // Compile all files in the directory in lexicographic order.
+               longdir := filepath.Join(cwd, t.goDirName())
+               files, dirErr := ioutil.ReadDir(longdir)
+               if dirErr != nil {
+                       t.err = dirErr
+                       return
+               }
+               for _, gofile := range files {
+                       afile := strings.Replace(gofile.Name(), ".go", "."+letter, -1)
+                       out, err := runcmd("go", "tool", gc, "-e", "-o", afile, filepath.Join(longdir, gofile.Name()))
+                       if err != nil {
+                               t.err = fmt.Errorf("%s\n%s", err, out)
+                               break
+                       }
+               }
+
        case "build":
                out, err := runcmd("go", "build", "-o", "a.exe", long)
                if err != nil {
index 9e0911526ac9c5dd679b9f1c2b6535a745367552..84cda7b371e455159450657b00334ba87aff4e9b 100644 (file)
@@ -9,6 +9,13 @@ compile() {
        $G $D/$F.go
 }
 
+compiledir() {
+       for gofile in $D/$F.dir/*.go
+       do
+               $G ${gofile} || return 1
+       done
+}
+
 build() {
        $G $D/$F.go && $L $F.$A
 }