|
@@ -21,6 +21,7 @@ import (
|
|
"strconv"
|
|
"strconv"
|
|
"strings"
|
|
"strings"
|
|
"sync"
|
|
"sync"
|
|
|
|
+ "sync/atomic"
|
|
"time"
|
|
"time"
|
|
)
|
|
)
|
|
|
|
|
|
@@ -43,7 +44,7 @@ const (
|
|
missedSt
|
|
missedSt
|
|
)
|
|
)
|
|
|
|
|
|
-type funcStatus int
|
|
|
|
|
|
+type funcStatus uint32
|
|
|
|
|
|
// A method value can't reach its own Method structure.
|
|
// A method value can't reach its own Method structure.
|
|
type methodType struct {
|
|
type methodType struct {
|
|
@@ -81,7 +82,7 @@ type C struct {
|
|
method *methodType
|
|
method *methodType
|
|
kind funcKind
|
|
kind funcKind
|
|
testName string
|
|
testName string
|
|
- status funcStatus
|
|
|
|
|
|
+ _status funcStatus
|
|
logb *logger
|
|
logb *logger
|
|
logw io.Writer
|
|
logw io.Writer
|
|
done chan *C
|
|
done chan *C
|
|
@@ -93,6 +94,14 @@ type C struct {
|
|
timer
|
|
timer
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func (c *C) status() funcStatus {
|
|
|
|
+ return funcStatus(atomic.LoadUint32((*uint32)(&c._status)))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (c *C) setStatus(s funcStatus) {
|
|
|
|
+ atomic.StoreUint32((*uint32)(&c._status), uint32(s))
|
|
|
|
+}
|
|
|
|
+
|
|
func (c *C) stopNow() {
|
|
func (c *C) stopNow() {
|
|
runtime.Goexit()
|
|
runtime.Goexit()
|
|
}
|
|
}
|
|
@@ -326,7 +335,7 @@ func (c *C) logPanic(skip int, value interface{}) {
|
|
if name == "Value.call" && strings.HasSuffix(path, valueGo) {
|
|
if name == "Value.call" && strings.HasSuffix(path, valueGo) {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- if name == "call16" && strings.Contains(path, asmGo) {
|
|
|
|
|
|
+ if (name == "call16" || name == "call32") && strings.Contains(path, asmGo) {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
c.logf("%s:%d\n in %s", nicePath(file), line, name)
|
|
c.logf("%s:%d\n in %s", nicePath(file), line, name)
|
|
@@ -455,7 +464,7 @@ func (tracker *resultTracker) _loopRoutine() {
|
|
tracker._waiting += 1
|
|
tracker._waiting += 1
|
|
case c = <-tracker._doneChan:
|
|
case c = <-tracker._doneChan:
|
|
tracker._waiting -= 1
|
|
tracker._waiting -= 1
|
|
- switch c.status {
|
|
|
|
|
|
+ switch c.status() {
|
|
case succeededSt:
|
|
case succeededSt:
|
|
if c.kind == testKd {
|
|
if c.kind == testKd {
|
|
if c.mustFail {
|
|
if c.mustFail {
|
|
@@ -601,15 +610,15 @@ func (runner *suiteRunner) run() *Result {
|
|
runner.tracker.start()
|
|
runner.tracker.start()
|
|
if runner.checkFixtureArgs() {
|
|
if runner.checkFixtureArgs() {
|
|
c := runner.runFixture(runner.setUpSuite, "", nil)
|
|
c := runner.runFixture(runner.setUpSuite, "", nil)
|
|
- if c == nil || c.status == succeededSt {
|
|
|
|
|
|
+ if c == nil || c.status() == succeededSt {
|
|
for i := 0; i != len(runner.tests); i++ {
|
|
for i := 0; i != len(runner.tests); i++ {
|
|
c := runner.runTest(runner.tests[i])
|
|
c := runner.runTest(runner.tests[i])
|
|
- if c.status == fixturePanickedSt {
|
|
|
|
|
|
+ if c.status() == fixturePanickedSt {
|
|
runner.skipTests(missedSt, runner.tests[i+1:])
|
|
runner.skipTests(missedSt, runner.tests[i+1:])
|
|
break
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- } else if c != nil && c.status == skippedSt {
|
|
|
|
|
|
+ } else if c != nil && c.status() == skippedSt {
|
|
runner.skipTests(skippedSt, runner.tests)
|
|
runner.skipTests(skippedSt, runner.tests)
|
|
} else {
|
|
} else {
|
|
runner.skipTests(missedSt, runner.tests)
|
|
runner.skipTests(missedSt, runner.tests)
|
|
@@ -674,22 +683,22 @@ func (runner *suiteRunner) callDone(c *C) {
|
|
switch v := value.(type) {
|
|
switch v := value.(type) {
|
|
case *fixturePanic:
|
|
case *fixturePanic:
|
|
if v.status == skippedSt {
|
|
if v.status == skippedSt {
|
|
- c.status = skippedSt
|
|
|
|
|
|
+ c.setStatus(skippedSt)
|
|
} else {
|
|
} else {
|
|
c.logSoftPanic("Fixture has panicked (see related PANIC)")
|
|
c.logSoftPanic("Fixture has panicked (see related PANIC)")
|
|
- c.status = fixturePanickedSt
|
|
|
|
|
|
+ c.setStatus(fixturePanickedSt)
|
|
}
|
|
}
|
|
default:
|
|
default:
|
|
c.logPanic(1, value)
|
|
c.logPanic(1, value)
|
|
- c.status = panickedSt
|
|
|
|
|
|
+ c.setStatus(panickedSt)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if c.mustFail {
|
|
if c.mustFail {
|
|
- switch c.status {
|
|
|
|
|
|
+ switch c.status() {
|
|
case failedSt:
|
|
case failedSt:
|
|
- c.status = succeededSt
|
|
|
|
|
|
+ c.setStatus(succeededSt)
|
|
case succeededSt:
|
|
case succeededSt:
|
|
- c.status = failedSt
|
|
|
|
|
|
+ c.setStatus(failedSt)
|
|
c.logString("Error: Test succeeded, but was expected to fail")
|
|
c.logString("Error: Test succeeded, but was expected to fail")
|
|
c.logString("Reason: " + c.reason)
|
|
c.logString("Reason: " + c.reason)
|
|
}
|
|
}
|
|
@@ -724,11 +733,11 @@ func (runner *suiteRunner) runFixtureWithPanic(method *methodType, testName stri
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
c := runner.runFixture(method, testName, logb)
|
|
c := runner.runFixture(method, testName, logb)
|
|
- if c != nil && c.status != succeededSt {
|
|
|
|
|
|
+ if c != nil && c.status() != succeededSt {
|
|
if skipped != nil {
|
|
if skipped != nil {
|
|
- *skipped = c.status == skippedSt
|
|
|
|
|
|
+ *skipped = c.status() == skippedSt
|
|
}
|
|
}
|
|
- panic(&fixturePanic{c.status, method})
|
|
|
|
|
|
+ panic(&fixturePanic{c.status(), method})
|
|
}
|
|
}
|
|
return c
|
|
return c
|
|
}
|
|
}
|
|
@@ -753,7 +762,7 @@ func (runner *suiteRunner) forkTest(method *methodType) *C {
|
|
if mt.NumIn() != 1 || mt.In(0) != reflect.TypeOf(c) {
|
|
if mt.NumIn() != 1 || mt.In(0) != reflect.TypeOf(c) {
|
|
// Rather than a plain panic, provide a more helpful message when
|
|
// Rather than a plain panic, provide a more helpful message when
|
|
// the argument type is incorrect.
|
|
// the argument type is incorrect.
|
|
- c.status = panickedSt
|
|
|
|
|
|
+ c.setStatus(panickedSt)
|
|
c.logArgPanic(c.method, "*check.C")
|
|
c.logArgPanic(c.method, "*check.C")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -773,7 +782,7 @@ func (runner *suiteRunner) forkTest(method *methodType) *C {
|
|
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 {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
perOpN := int(1e9)
|
|
perOpN := int(1e9)
|
|
@@ -808,7 +817,7 @@ func (runner *suiteRunner) runTest(method *methodType) *C {
|
|
func (runner *suiteRunner) skipTests(status funcStatus, methods []*methodType) {
|
|
func (runner *suiteRunner) skipTests(status funcStatus, methods []*methodType) {
|
|
for _, method := range methods {
|
|
for _, method := range methods {
|
|
runner.runFunc(method, testKd, "", nil, func(c *C) {
|
|
runner.runFunc(method, testKd, "", nil, func(c *C) {
|
|
- c.status = status
|
|
|
|
|
|
+ c.setStatus(status)
|
|
})
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -825,7 +834,7 @@ func (runner *suiteRunner) checkFixtureArgs() bool {
|
|
succeeded = false
|
|
succeeded = false
|
|
runner.runFunc(method, fixtureKd, "", nil, func(c *C) {
|
|
runner.runFunc(method, fixtureKd, "", nil, func(c *C) {
|
|
c.logArgPanic(method, "*check.C")
|
|
c.logArgPanic(method, "*check.C")
|
|
- c.status = panickedSt
|
|
|
|
|
|
+ c.setStatus(panickedSt)
|
|
})
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -839,7 +848,7 @@ func (runner *suiteRunner) reportCallStarted(c *C) {
|
|
|
|
|
|
func (runner *suiteRunner) reportCallDone(c *C) {
|
|
func (runner *suiteRunner) reportCallDone(c *C) {
|
|
runner.tracker.callDone(c)
|
|
runner.tracker.callDone(c)
|
|
- switch c.status {
|
|
|
|
|
|
+ switch c.status() {
|
|
case succeededSt:
|
|
case succeededSt:
|
|
if c.mustFail {
|
|
if c.mustFail {
|
|
runner.output.WriteCallSuccess("FAIL EXPECTED", c)
|
|
runner.output.WriteCallSuccess("FAIL EXPECTED", c)
|
|
@@ -917,7 +926,7 @@ func (ow *outputWriter) WriteCallSuccess(label string, c *C) {
|
|
if c.reason != "" {
|
|
if c.reason != "" {
|
|
suffix = " (" + c.reason + ")"
|
|
suffix = " (" + c.reason + ")"
|
|
}
|
|
}
|
|
- if c.status == succeededSt {
|
|
|
|
|
|
+ if c.status() == succeededSt {
|
|
suffix += "\t" + c.timerString()
|
|
suffix += "\t" + c.timerString()
|
|
}
|
|
}
|
|
suffix += "\n"
|
|
suffix += "\n"
|