mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
re-vendor go-check
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
parent
80c49d1e52
commit
51771a3094
2 changed files with 51 additions and 4 deletions
|
@ -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/Sirupsen/logrus v0.10.0 # logrus is a common dependency among multiple deps
|
||||
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/mux v1.1
|
||||
clone git github.com/kr/pty 5cf931ef8f
|
||||
|
|
53
vendor/src/github.com/go-check/check/check.go
vendored
53
vendor/src/github.com/go-check/check/check.go
vendored
|
@ -514,6 +514,7 @@ type suiteRunner struct {
|
|||
suite interface{}
|
||||
setUpSuite, tearDownSuite *methodType
|
||||
setUpTest, tearDownTest *methodType
|
||||
onTimeout *methodType
|
||||
tests []*methodType
|
||||
tracker *resultTracker
|
||||
tempDir *tempDir
|
||||
|
@ -591,6 +592,8 @@ func newSuiteRunner(suite interface{}, runConf *RunConf) *suiteRunner {
|
|||
runner.setUpTest = method
|
||||
case "TearDownTest":
|
||||
runner.tearDownTest = method
|
||||
case "OnTimeout":
|
||||
runner.onTimeout = method
|
||||
default:
|
||||
prefix := "Test"
|
||||
if conf.Benchmark {
|
||||
|
@ -671,6 +674,23 @@ func (runner *suiteRunner) forkCall(method *methodType, kind funcKind, testName
|
|||
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.
|
||||
func (runner *suiteRunner) runFunc(method *methodType, kind funcKind, testName string, logb *logger, dispatcher func(c *C)) *C {
|
||||
var timeout <-chan time.Time
|
||||
|
@ -681,7 +701,19 @@ func (runner *suiteRunner) runFunc(method *methodType, kind funcKind, testName s
|
|||
select {
|
||||
case <-c.done:
|
||||
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
|
||||
}
|
||||
|
@ -777,12 +809,14 @@ func (runner *suiteRunner) forkTest(method *methodType) *C {
|
|||
c.logArgPanic(c.method, "*check.C")
|
||||
return
|
||||
}
|
||||
|
||||
if strings.HasPrefix(c.method.Info.Name, "Test") {
|
||||
c.ResetTimer()
|
||||
c.StartTimer()
|
||||
c.method.Call([]reflect.Value{reflect.ValueOf(c)})
|
||||
return
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(c.method.Info.Name, "Benchmark") {
|
||||
panic("unexpected method prefix: " + c.method.Info.Name)
|
||||
}
|
||||
|
@ -791,6 +825,7 @@ func (runner *suiteRunner) forkTest(method *methodType) *C {
|
|||
c.N = benchN
|
||||
c.ResetTimer()
|
||||
c.StartTimer()
|
||||
|
||||
c.method.Call([]reflect.Value{reflect.ValueOf(c)})
|
||||
c.StopTimer()
|
||||
if c.status() != succeededSt || c.duration >= c.benchTime || benchN >= 1e9 {
|
||||
|
@ -825,7 +860,19 @@ func (runner *suiteRunner) runTest(method *methodType) *C {
|
|||
select {
|
||||
case <-c.done:
|
||||
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
|
||||
}
|
||||
|
@ -846,7 +893,7 @@ func (runner *suiteRunner) skipTests(status funcStatus, methods []*methodType) {
|
|||
func (runner *suiteRunner) checkFixtureArgs() bool {
|
||||
succeeded := true
|
||||
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 {
|
||||
mt := method.Type()
|
||||
if mt.NumIn() != 1 || mt.In(0) != argType {
|
||||
|
|
Loading…
Reference in a new issue