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 (
"sort"
"strconv"
"strings"
"time"
"unicode"
)
......@@ -115,27 +116,38 @@ func main() {
resCount := map[string]int{}
for _, test := range tests {
<-test.donec
_, isSkip := test.err.(skipError)
errStr := "pass"
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,6 +219,7 @@ 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 {
......
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