aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing.go')
-rw-r--r--src/testing/testing.go43
1 files changed, 10 insertions, 33 deletions
diff --git a/src/testing/testing.go b/src/testing/testing.go
index f08c5c6b8e..c972b2737f 100644
--- a/src/testing/testing.go
+++ b/src/testing/testing.go
@@ -204,7 +204,6 @@ package testing
import (
"bytes"
- "context"
"errors"
"flag"
"fmt"
@@ -262,14 +261,12 @@ type common struct {
mu sync.RWMutex // guards output, failed, and done.
output []byte // Output generated by test or benchmark.
w io.Writer // For flushToParent.
- ctx context.Context
- cancel context.CancelFunc
- chatty bool // A copy of the chatty flag.
- ran bool // Test or benchmark (or one of its subtests) was executed.
- failed bool // Test or benchmark has failed.
- skipped bool // Test of benchmark has been skipped.
- finished bool // Test function has completed.
- done bool // Test is finished and all subtests have completed.
+ chatty bool // A copy of the chatty flag.
+ ran bool // Test or benchmark (or one of its subtests) was executed.
+ failed bool // Test or benchmark has failed.
+ skipped bool // Test of benchmark has been skipped.
+ finished bool // Test function has completed.
+ done bool // Test is finished and all subtests have completed.
hasSub bool
raceErrors int // number of races detected during test
@@ -283,13 +280,6 @@ type common struct {
sub []*T // Queue of subtests to be run in parallel.
}
-func (c *common) parentContext() context.Context {
- if c == nil || c.parent == nil || c.parent.ctx == nil {
- return context.Background()
- }
- return c.parent.ctx
-}
-
// Short reports whether the -test.short flag is set.
func Short() bool {
return *short
@@ -386,7 +376,6 @@ func fmtDuration(d time.Duration) string {
// TB is the interface common to T and B.
type TB interface {
- Context() context.Context
Error(args ...interface{})
Errorf(format string, args ...interface{})
Fail()
@@ -434,15 +423,6 @@ func (c *common) Name() string {
return c.name
}
-// Context returns the context for the current test or benchmark.
-// The context is cancelled when the test or benchmark finishes.
-// A goroutine started during a test or benchmark can wait for the
-// context's Done channel to become readable as a signal that the
-// test or benchmark is over, so that the goroutine can exit.
-func (c *common) Context() context.Context {
- return c.ctx
-}
-
func (c *common) setRan() {
if c.parent != nil {
c.parent.setRan()
@@ -619,9 +599,6 @@ type InternalTest struct {
}
func tRunner(t *T, fn func(t *T)) {
- t.ctx, t.cancel = context.WithCancel(t.parentContext())
- defer t.cancel()
-
// When this goroutine is done, either because fn(t)
// returned normally or because a test failure triggered
// a call to runtime.Goexit, record the duration and send
@@ -918,11 +895,11 @@ func (m *M) before() {
if *cpuProfile != "" {
f, err := os.Create(toOutputDir(*cpuProfile))
if err != nil {
- fmt.Fprintf(os.Stderr, "testing: %s", err)
+ fmt.Fprintf(os.Stderr, "testing: %s\n", err)
return
}
if err := m.deps.StartCPUProfile(f); err != nil {
- fmt.Fprintf(os.Stderr, "testing: can't start cpu profile: %s", err)
+ fmt.Fprintf(os.Stderr, "testing: can't start cpu profile: %s\n", err)
f.Close()
return
}
@@ -931,11 +908,11 @@ func (m *M) before() {
if *traceFile != "" {
f, err := os.Create(toOutputDir(*traceFile))
if err != nil {
- fmt.Fprintf(os.Stderr, "testing: %s", err)
+ fmt.Fprintf(os.Stderr, "testing: %s\n", err)
return
}
if err := trace.Start(f); err != nil {
- fmt.Fprintf(os.Stderr, "testing: can't start tracing: %s", err)
+ fmt.Fprintf(os.Stderr, "testing: can't start tracing: %s\n", err)
f.Close()
return
}