Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions check.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func (method *methodType) matches(re *regexp.Regexp) bool {
}

type C struct {
sync.Mutex
method *methodType
kind funcKind
testName string
Expand Down
14 changes: 14 additions & 0 deletions helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (

// TestName returns the current test name in the form "SuiteName.TestName"
func (c *C) TestName() string {
c.Lock()
defer c.Unlock()
return c.testName
}

Expand All @@ -16,6 +18,8 @@ func (c *C) TestName() string {

// Failed returns whether the currently running test has already failed.
func (c *C) Failed() bool {
c.Lock()
defer c.Unlock()
return c.status == failedSt
}

Expand All @@ -25,6 +29,8 @@ func (c *C) Failed() bool {
// what went wrong. The higher level helper functions will fail the test
// and do the logging properly.
func (c *C) Fail() {
c.Lock()
defer c.Unlock()
c.status = failedSt
}

Expand All @@ -40,6 +46,8 @@ func (c *C) FailNow() {
// Succeed marks the currently running test as succeeded, undoing any
// previous failures.
func (c *C) Succeed() {
c.Lock()
defer c.Unlock()
c.status = succeededSt
}

Expand All @@ -57,6 +65,8 @@ func (c *C) SucceedNow() {
// fix the problem is found, without forgetting about the fact that a
// failure still exists.
func (c *C) ExpectFailure(reason string) {
c.Lock()
defer c.Unlock()
if reason == "" {
panic("Missing reason why the test is expected to fail")
}
Expand All @@ -68,6 +78,8 @@ func (c *C) ExpectFailure(reason string) {
// SetUpTest, the individual test being set up will be skipped, and if run
// from within SetUpSuite, the whole suite is skipped.
func (c *C) Skip(reason string) {
c.Lock()
defer c.Unlock()
if reason == "" {
panic("Missing reason why the test is being skipped")
}
Expand All @@ -81,6 +93,8 @@ func (c *C) Skip(reason string) {

// GetTestLog returns the current test error output.
func (c *C) GetTestLog() string {
c.Lock()
defer c.Unlock()
return c.logb.String()
}

Expand Down