mirror of
https://github.com/golang/go
synced 2024-11-22 00:54:43 -07:00
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 https://golang.org/cl/6440048
This commit is contained in:
parent
09f1f5d76d
commit
adc9337262
@ -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.
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
|
@ -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.
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
|
@ -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.
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
|
@ -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.
|
// Copyright 2010 The Go Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
|
@ -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.
|
// Copyright 2011 The Go Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
|
@ -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.
|
// Copyright 2011 The Go Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
|
@ -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.
|
// Copyright 2012 The Go Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
|
@ -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.
|
// Copyright 2011 The Go Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
|
23
test/run.go
23
test/run.go
@ -216,6 +216,10 @@ func (t *test) goFileName() string {
|
|||||||
return filepath.Join(t.dir, t.gofile)
|
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.
|
// run runs a test.
|
||||||
func (t *test) run() {
|
func (t *test) run() {
|
||||||
defer close(t.donec)
|
defer close(t.donec)
|
||||||
@ -251,7 +255,7 @@ func (t *test) run() {
|
|||||||
case "cmpout":
|
case "cmpout":
|
||||||
action = "run" // the run case already looks for <dir>/<test>.out files
|
action = "run" // the run case already looks for <dir>/<test>.out files
|
||||||
fallthrough
|
fallthrough
|
||||||
case "compile", "build", "run", "errorcheck", "runoutput":
|
case "compile", "compiledir", "build", "run", "errorcheck", "runoutput":
|
||||||
t.action = action
|
t.action = action
|
||||||
case "skip":
|
case "skip":
|
||||||
t.action = "skip"
|
t.action = "skip"
|
||||||
@ -301,6 +305,23 @@ func (t *test) run() {
|
|||||||
t.err = fmt.Errorf("%s\n%s", err, out)
|
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":
|
case "build":
|
||||||
out, err := runcmd("go", "build", "-o", "a.exe", long)
|
out, err := runcmd("go", "build", "-o", "a.exe", long)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -9,6 +9,13 @@ compile() {
|
|||||||
$G $D/$F.go
|
$G $D/$F.go
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compiledir() {
|
||||||
|
for gofile in $D/$F.dir/*.go
|
||||||
|
do
|
||||||
|
$G ${gofile} || return 1
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
$G $D/$F.go && $L $F.$A
|
$G $D/$F.go && $L $F.$A
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user