From 2d03daa802bf35f4999eea64634ef923c6393eb9 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 25 Aug 2014 16:43:34 -0700 Subject: [PATCH] Remove test.TB and use testing.TB, now that we depend on Go 1.3 Change-Id: Ie7c2e021a95705d2fe8379bdbb43c24fd0714836 --- pkg/search/query_test.go | 10 +++++----- pkg/test/test.go | 22 ++-------------------- pkg/test/test_test.go | 2 +- 3 files changed, 8 insertions(+), 26 deletions(-) diff --git a/pkg/search/query_test.go b/pkg/search/query_test.go index f27437549..f146ee670 100644 --- a/pkg/search/query_test.go +++ b/pkg/search/query_test.go @@ -49,13 +49,13 @@ func (i indexType) String() string { } type queryTest struct { - t test.TB + t testing.TB id *indextest.IndexDeps Handler func() *Handler } -func querySetup(t test.TB) (*indextest.IndexDeps, *Handler) { +func querySetup(t testing.TB) (*indextest.IndexDeps, *Handler) { idx := index.NewMemoryIndex() // string key-value pairs in memory, as if they were on disk id := indextest.NewIndexDeps(idx) id.Fataler = t @@ -63,11 +63,11 @@ func querySetup(t test.TB) (*indextest.IndexDeps, *Handler) { return id, h } -func testQuery(t test.TB, fn func(*queryTest)) { +func testQuery(t testing.TB, fn func(*queryTest)) { testQueryTypes(t, allIndexTypes, fn) } -func testQueryTypes(t test.TB, types []indexType, fn func(*queryTest)) { +func testQueryTypes(t testing.TB, types []indexType, fn func(*queryTest)) { defer test.TLog(t)() for _, it := range types { if *queryType == "" || *queryType == it.String() { @@ -77,7 +77,7 @@ func testQueryTypes(t test.TB, types []indexType, fn func(*queryTest)) { } } -func testQueryType(t test.TB, fn func(*queryTest), itype indexType) { +func testQueryType(t testing.TB, fn func(*queryTest), itype indexType) { defer index.SetVerboseCorpusLogging(true) index.SetVerboseCorpusLogging(false) diff --git a/pkg/test/test.go b/pkg/test/test.go index b4175b265..91fa53a8c 100644 --- a/pkg/test/test.go +++ b/pkg/test/test.go @@ -34,27 +34,9 @@ func BrokenTest(t *testing.T) { } } -// TB is a copy of Go 1.2's testing.TB. -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 -} - // TLog changes the log package's output to log to t and returns a function // to reset it back to stderr. -func TLog(t TB) func() { - // TODO(bradfitz): once we rely on Go 1.2, change this to take a testing.TB. +func TLog(t testing.TB) func() { log.SetOutput(&twriter{t: t}) return func() { log.SetOutput(os.Stderr) @@ -66,7 +48,7 @@ func TLog(t TB) func() { // method calls and Write calls: // "Each logging operation makes a single call to the Writer's Write method" type twriter struct { - t TB + t testing.TB buf bytes.Buffer } diff --git a/pkg/test/test_test.go b/pkg/test/test_test.go index 5bd91df6d..a83c01ca2 100644 --- a/pkg/test/test_test.go +++ b/pkg/test/test_test.go @@ -28,7 +28,7 @@ import ( var _ index.Interface = (*FakeIndex)(nil) type tbLogger struct { - TB + testing.TB log []string }