re-vendor go-check
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
parent
80c49d1e52
commit
51771a3094
|
@ -47,7 +47,7 @@ clone git github.com/Microsoft/hcsshim v0.3.6
|
||||||
clone git github.com/Microsoft/go-winio v0.3.4
|
clone git github.com/Microsoft/go-winio v0.3.4
|
||||||
clone git github.com/Sirupsen/logrus v0.10.0 # logrus is a common dependency among multiple deps
|
clone git github.com/Sirupsen/logrus v0.10.0 # logrus is a common dependency among multiple deps
|
||||||
clone git github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a
|
clone git github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a
|
||||||
clone git github.com/go-check/check 03a4d9dcf2f92eae8e90ed42aa2656f63fdd0b14 https://github.com/cpuguy83/check.git
|
clone git github.com/go-check/check 4ed411733c5785b40214c70bce814c3a3a689609 https://github.com/cpuguy83/check.git
|
||||||
clone git github.com/gorilla/context v1.1
|
clone git github.com/gorilla/context v1.1
|
||||||
clone git github.com/gorilla/mux v1.1
|
clone git github.com/gorilla/mux v1.1
|
||||||
clone git github.com/kr/pty 5cf931ef8f
|
clone git github.com/kr/pty 5cf931ef8f
|
||||||
|
|
|
@ -514,6 +514,7 @@ type suiteRunner struct {
|
||||||
suite interface{}
|
suite interface{}
|
||||||
setUpSuite, tearDownSuite *methodType
|
setUpSuite, tearDownSuite *methodType
|
||||||
setUpTest, tearDownTest *methodType
|
setUpTest, tearDownTest *methodType
|
||||||
|
onTimeout *methodType
|
||||||
tests []*methodType
|
tests []*methodType
|
||||||
tracker *resultTracker
|
tracker *resultTracker
|
||||||
tempDir *tempDir
|
tempDir *tempDir
|
||||||
|
@ -591,6 +592,8 @@ func newSuiteRunner(suite interface{}, runConf *RunConf) *suiteRunner {
|
||||||
runner.setUpTest = method
|
runner.setUpTest = method
|
||||||
case "TearDownTest":
|
case "TearDownTest":
|
||||||
runner.tearDownTest = method
|
runner.tearDownTest = method
|
||||||
|
case "OnTimeout":
|
||||||
|
runner.onTimeout = method
|
||||||
default:
|
default:
|
||||||
prefix := "Test"
|
prefix := "Test"
|
||||||
if conf.Benchmark {
|
if conf.Benchmark {
|
||||||
|
@ -671,6 +674,23 @@ func (runner *suiteRunner) forkCall(method *methodType, kind funcKind, testName
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type timeoutErr struct {
|
||||||
|
method *methodType
|
||||||
|
t time.Duration
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e timeoutErr) Error() string {
|
||||||
|
return fmt.Sprintf("%s test timed out after %v", e.method.String(), e.t)
|
||||||
|
}
|
||||||
|
|
||||||
|
func isTimeout(e error) bool {
|
||||||
|
if e == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
_, ok := e.(timeoutErr)
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
// Same as forkCall(), but wait for call to finish before returning.
|
// Same as forkCall(), but wait for call to finish before returning.
|
||||||
func (runner *suiteRunner) runFunc(method *methodType, kind funcKind, testName string, logb *logger, dispatcher func(c *C)) *C {
|
func (runner *suiteRunner) runFunc(method *methodType, kind funcKind, testName string, logb *logger, dispatcher func(c *C)) *C {
|
||||||
var timeout <-chan time.Time
|
var timeout <-chan time.Time
|
||||||
|
@ -681,7 +701,19 @@ func (runner *suiteRunner) runFunc(method *methodType, kind funcKind, testName s
|
||||||
select {
|
select {
|
||||||
case <-c.done:
|
case <-c.done:
|
||||||
case <-timeout:
|
case <-timeout:
|
||||||
panic(fmt.Sprintf("%s test timed out after %v", method.String(), runner.checkTimeout))
|
if runner.onTimeout != nil {
|
||||||
|
// run the OnTimeout callback, allowing the suite to collect any sort of debug information it can
|
||||||
|
// `runFixture` is syncronous, so run this in a separate goroutine with a timeout
|
||||||
|
cChan := make(chan *C)
|
||||||
|
go func() {
|
||||||
|
cChan <- runner.runFixture(runner.onTimeout, c.testName, c.logb)
|
||||||
|
}()
|
||||||
|
select {
|
||||||
|
case <-cChan:
|
||||||
|
case <-time.After(runner.checkTimeout):
|
||||||
|
}
|
||||||
|
}
|
||||||
|
panic(timeoutErr{method, runner.checkTimeout})
|
||||||
}
|
}
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
@ -777,12 +809,14 @@ func (runner *suiteRunner) forkTest(method *methodType) *C {
|
||||||
c.logArgPanic(c.method, "*check.C")
|
c.logArgPanic(c.method, "*check.C")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(c.method.Info.Name, "Test") {
|
if strings.HasPrefix(c.method.Info.Name, "Test") {
|
||||||
c.ResetTimer()
|
c.ResetTimer()
|
||||||
c.StartTimer()
|
c.StartTimer()
|
||||||
c.method.Call([]reflect.Value{reflect.ValueOf(c)})
|
c.method.Call([]reflect.Value{reflect.ValueOf(c)})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.HasPrefix(c.method.Info.Name, "Benchmark") {
|
if !strings.HasPrefix(c.method.Info.Name, "Benchmark") {
|
||||||
panic("unexpected method prefix: " + c.method.Info.Name)
|
panic("unexpected method prefix: " + c.method.Info.Name)
|
||||||
}
|
}
|
||||||
|
@ -791,6 +825,7 @@ func (runner *suiteRunner) forkTest(method *methodType) *C {
|
||||||
c.N = benchN
|
c.N = benchN
|
||||||
c.ResetTimer()
|
c.ResetTimer()
|
||||||
c.StartTimer()
|
c.StartTimer()
|
||||||
|
|
||||||
c.method.Call([]reflect.Value{reflect.ValueOf(c)})
|
c.method.Call([]reflect.Value{reflect.ValueOf(c)})
|
||||||
c.StopTimer()
|
c.StopTimer()
|
||||||
if c.status() != succeededSt || c.duration >= c.benchTime || benchN >= 1e9 {
|
if c.status() != succeededSt || c.duration >= c.benchTime || benchN >= 1e9 {
|
||||||
|
@ -825,7 +860,19 @@ func (runner *suiteRunner) runTest(method *methodType) *C {
|
||||||
select {
|
select {
|
||||||
case <-c.done:
|
case <-c.done:
|
||||||
case <-timeout:
|
case <-timeout:
|
||||||
panic(fmt.Sprintf("%s test timed out after %v", method.String(), runner.checkTimeout))
|
if runner.onTimeout != nil {
|
||||||
|
// run the OnTimeout callback, allowing the suite to collect any sort of debug information it can
|
||||||
|
// `runFixture` is syncronous, so run this in a separate goroutine with a timeout
|
||||||
|
cChan := make(chan *C)
|
||||||
|
go func() {
|
||||||
|
cChan <- runner.runFixture(runner.onTimeout, c.testName, c.logb)
|
||||||
|
}()
|
||||||
|
select {
|
||||||
|
case <-cChan:
|
||||||
|
case <-time.After(runner.checkTimeout):
|
||||||
|
}
|
||||||
|
}
|
||||||
|
panic(timeoutErr{method, runner.checkTimeout})
|
||||||
}
|
}
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
@ -846,7 +893,7 @@ func (runner *suiteRunner) skipTests(status funcStatus, methods []*methodType) {
|
||||||
func (runner *suiteRunner) checkFixtureArgs() bool {
|
func (runner *suiteRunner) checkFixtureArgs() bool {
|
||||||
succeeded := true
|
succeeded := true
|
||||||
argType := reflect.TypeOf(&C{})
|
argType := reflect.TypeOf(&C{})
|
||||||
for _, method := range []*methodType{runner.setUpSuite, runner.tearDownSuite, runner.setUpTest, runner.tearDownTest} {
|
for _, method := range []*methodType{runner.setUpSuite, runner.tearDownSuite, runner.setUpTest, runner.tearDownTest, runner.onTimeout} {
|
||||||
if method != nil {
|
if method != nil {
|
||||||
mt := method.Type()
|
mt := method.Type()
|
||||||
if mt.NumIn() != 1 || mt.In(0) != argType {
|
if mt.NumIn() != 1 || mt.In(0) != argType {
|
||||||
|
|
Loading…
Reference in New Issue