aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/testing
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2013-08-14 23:21:32 -0700
committerBrad Fitzpatrick <bradfitz@golang.org>2013-08-14 23:21:32 -0700
commit35d8bb39bd7953dddead3d97db32af77d8941563 (patch)
tree99f0167a9875ac840d928f8ac5e70c8bccadb724 /src/pkg/testing
parenta41a5bb20799f75f914b991aae0e673166b0ad76 (diff)
downloadgo-35d8bb39bd7953dddead3d97db32af77d8941563.tar.xz
testing: add TB, an interface common to T and B
R=golang-dev, kevlar, rsc, adg, r CC=golang-dev https://golang.org/cl/12962043
Diffstat (limited to 'src/pkg/testing')
-rw-r--r--src/pkg/testing/testing.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/pkg/testing/testing.go b/src/pkg/testing/testing.go
index 852f4e7a62..4c81201a84 100644
--- a/src/pkg/testing/testing.go
+++ b/src/pkg/testing/testing.go
@@ -196,6 +196,31 @@ func decorate(s string) string {
return buf.String()
}
+// TB is the interface common to T and B.
+type TB interface {
+ Error(args ...interface{})
+ Errorf(format string, args ...interface{})
+ Fail()
+ FailNow()
+ Failed() bool
+ Fatal(args ...interface{})
+ Fatalf(format string, args ...interface{})
+ Log(args ...interface{})
+ Logf(format string, args ...interface{})
+ Skip(args ...interface{})
+ SkipNow()
+ Skipf(format string, args ...interface{})
+ Skipped() bool
+
+ // A private method to prevent users implementing the
+ // interface and so future additions to it will not
+ // violate Go 1 compatibility.
+ private()
+}
+
+var _ TB = (*T)(nil)
+var _ TB = (*B)(nil)
+
// T is a type passed to Test functions to manage test state and support formatted test logs.
// Logs are accumulated during execution and dumped to standard error when done.
type T struct {
@@ -204,6 +229,8 @@ type T struct {
startParallel chan bool // Parallel tests will wait on this.
}
+func (c *common) private() {}
+
// Fail marks the function as having failed but continues execution.
func (c *common) Fail() {
c.mu.Lock()