summaryrefslogtreecommitdiff
path: root/test/run.go
diff options
context:
space:
mode:
authorR?my Oudompheng <oudomphe@phare.normalesup.org>2012-07-30 21:12:05 +0200
committerR?my Oudompheng <oudomphe@phare.normalesup.org>2012-07-30 21:12:05 +0200
commit09211501f75dd30633efcb6144d34eba926c587f (patch)
tree656903342542721752a88c18b5aa05541f345e94 /test/run.go
parenta1814d9900ea4ab53d06d3acc7b20ba12f7a9dd6 (diff)
downloadgo-09211501f75dd30633efcb6144d34eba926c587f.tar.gz
test: add a compiledir pattern in run.go
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 http://codereview.appspot.com/6440048
Diffstat (limited to 'test/run.go')
-rw-r--r--test/run.go23
1 files changed, 22 insertions, 1 deletions
diff --git a/test/run.go b/test/run.go
index 198863eab..e1d97e9ee 100644
--- a/test/run.go
+++ b/test/run.go
@@ -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 {