summaryrefslogtreecommitdiff
path: root/test/run.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2013-12-10 14:02:42 -0500
committerRuss Cox <rsc@golang.org>2013-12-10 14:02:42 -0500
commit86306699d04073742d0720bfeb39fb635131c063 (patch)
tree8b68118cac70bfe3ab74fa3f9d0913195bfbab46 /test/run.go
parenta62ff3e2cc090ed5de48a95e66f088c281c08916 (diff)
downloadgo-86306699d04073742d0720bfeb39fb635131c063.tar.gz
test/run: make -v output look like go test output
Among other things, it makes it easier to scan to see what is slow. R=golang-dev, bradfitz CC=golang-dev https://codereview.appspot.com/40040044
Diffstat (limited to 'test/run.go')
-rw-r--r--test/run.go47
1 files changed, 32 insertions, 15 deletions
diff --git a/test/run.go b/test/run.go
index f1f1ec034..5c94de640 100644
--- a/test/run.go
+++ b/test/run.go
@@ -27,6 +27,7 @@ import (
"sort"
"strconv"
"strings"
+ "time"
"unicode"
)
@@ -114,28 +115,39 @@ func main() {
failed := false
resCount := map[string]int{}
for _, test := range tests {
- <-test.donec
- _, isSkip := test.err.(skipError)
- errStr := "pass"
+ <-test.donec
+ status := "ok "
+ errStr := ""
+ if _, isSkip := test.err.(skipError); isSkip {
+ status = "skip"
+ test.err = nil
+ if !skipOkay[path.Join(test.dir, test.gofile)] {
+ errStr = "unexpected skip for " + path.Join(test.dir, test.gofile) + ": " + errStr
+ status = "FAIL"
+ }
+ }
if test.err != nil {
+ status = "FAIL"
errStr = test.err.Error()
- if !isSkip {
- failed = true
- }
}
- if isSkip && !skipOkay[path.Join(test.dir, test.gofile)] {
- errStr = "unexpected skip for " + path.Join(test.dir, test.gofile) + ": " + errStr
- isSkip = false
+ if status == "FAIL" {
failed = true
}
- resCount[errStr]++
- if isSkip && !*verbose && !*showSkips {
+ resCount[status]++
+ if status == "skip" && !*verbose && !*showSkips {
+ continue
+ }
+ dt := fmt.Sprintf("%.3fs", test.dt.Seconds())
+ if status == "FAIL" {
+ fmt.Printf("# go run run.go -- %s\n%s\nFAIL\t%s\t%s\n",
+ path.Join(test.dir, test.gofile),
+ errStr, test.goFileName(), dt)
continue
}
- if !*verbose && test.err == nil {
+ if !*verbose {
continue
}
- fmt.Printf("# go run run.go -- %s\n%-20s %-20s: %s\n", path.Join(test.dir, test.gofile), test.action, test.goFileName(), errStr)
+ fmt.Printf("%s\t%s\t%s\n", status, test.goFileName(), dt)
}
if *summary {
@@ -207,7 +219,8 @@ func check(err error) {
type test struct {
dir, gofile string
donec chan bool // closed when done
-
+ dt time.Duration
+
src string
action string // "compile", "build", etc.
@@ -379,7 +392,11 @@ func init() { checkShouldTest() }
// run runs a test.
func (t *test) run() {
- defer close(t.donec)
+ start := time.Now()
+ defer func() {
+ t.dt = time.Since(start)
+ close(t.donec)
+ }()
srcBytes, err := ioutil.ReadFile(t.goFileName())
if err != nil {