Commit de8549df authored by Russ Cox's avatar Russ Cox

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://golang.org/cl/40040044
parent 9bea6f3b
...@@ -27,6 +27,7 @@ import ( ...@@ -27,6 +27,7 @@ import (
"sort" "sort"
"strconv" "strconv"
"strings" "strings"
"time"
"unicode" "unicode"
) )
...@@ -114,28 +115,39 @@ func main() { ...@@ -114,28 +115,39 @@ func main() {
failed := false failed := false
resCount := map[string]int{} resCount := map[string]int{}
for _, test := range tests { for _, test := range tests {
<-test.donec <-test.donec
_, isSkip := test.err.(skipError) status := "ok "
errStr := "pass" 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 { if test.err != nil {
status = "FAIL"
errStr = test.err.Error() errStr = test.err.Error()
if !isSkip {
failed = true
}
} }
if isSkip && !skipOkay[path.Join(test.dir, test.gofile)] { if status == "FAIL" {
errStr = "unexpected skip for " + path.Join(test.dir, test.gofile) + ": " + errStr
isSkip = false
failed = true failed = true
} }
resCount[errStr]++ resCount[status]++
if isSkip && !*verbose && !*showSkips { 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 continue
} }
if !*verbose && test.err == nil { if !*verbose {
continue 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 { if *summary {
...@@ -207,7 +219,8 @@ func check(err error) { ...@@ -207,7 +219,8 @@ func check(err error) {
type test struct { type test struct {
dir, gofile string dir, gofile string
donec chan bool // closed when done donec chan bool // closed when done
dt time.Duration
src string src string
action string // "compile", "build", etc. action string // "compile", "build", etc.
...@@ -379,7 +392,11 @@ func init() { checkShouldTest() } ...@@ -379,7 +392,11 @@ func init() { checkShouldTest() }
// run runs a test. // run runs a test.
func (t *test) run() { 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()) srcBytes, err := ioutil.ReadFile(t.goFileName())
if err != nil { if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment