mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
testing: finish implementation of subtests
API not exposed yet. Change-Id: Iaba0adc0fa1ae8075e6b56796f99ee8db9177a78 Reviewed-on: https://go-review.googlesource.com/18896 Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
1857bfca13
commit
2330ae8cf8
2 changed files with 249 additions and 0 deletions
|
|
@ -273,6 +273,29 @@ func (c *common) flushToParent(format string, args ...interface{}) {
|
|||
c.output = c.output[:0]
|
||||
}
|
||||
|
||||
type indenter struct {
|
||||
c *common
|
||||
}
|
||||
|
||||
func (w indenter) Write(b []byte) (n int, err error) {
|
||||
n = len(b)
|
||||
for len(b) > 0 {
|
||||
end := bytes.IndexByte(b, '\n')
|
||||
if end == -1 {
|
||||
end = len(b)
|
||||
} else {
|
||||
end++
|
||||
}
|
||||
// An indent of 4 spaces will neatly align the dashes with the status
|
||||
// indicator of the parent.
|
||||
const indent = " "
|
||||
w.c.output = append(w.c.output, indent...)
|
||||
w.c.output = append(w.c.output, b[:end]...)
|
||||
b = b[end:]
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// fmtDuration returns a string representing d in the form "87.00s".
|
||||
func fmtDuration(d time.Duration) string {
|
||||
return fmt.Sprintf("%.2fs", d.Seconds())
|
||||
|
|
@ -542,6 +565,7 @@ func (t *T) run(name string, f func(t *T)) bool {
|
|||
},
|
||||
context: t.context,
|
||||
}
|
||||
t.w = indenter{&t.common}
|
||||
|
||||
if *chatty {
|
||||
fmt.Printf("=== RUN %s\n", t.name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue