Skip to content

Commit

Permalink
Test with -race in CI
Browse files Browse the repository at this point in the history
Attempt to detect race conditions in CI. Make a test timeout longer to
account for slower speed with the `-race` flag.

Signed-off-by: Michael Smith <[email protected]>
  • Loading branch information
MikaelSmith committed Feb 3, 2020
1 parent 3d9dad3 commit 382a4f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ env:
jobs:
include:
- name: Test Go stable
script: go test -race ./...
- name: Acceptance tests
before_script:
- |
Expand Down
8 changes: 4 additions & 4 deletions plugin/execCommandImpl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (

type ExecCommandImplTestSuite struct {
suite.Suite
ctx context.Context
cancelFunc context.CancelFunc
ctx context.Context
cancelFunc context.CancelFunc
}

func (suite *ExecCommandImplTestSuite) SetupTest() {
Expand Down Expand Up @@ -89,7 +89,8 @@ func (suite *ExecCommandImplTestSuite) TestNewExecCommand_CancelledContext_Close
func (suite *ExecCommandImplTestSuite) TestSetStopFunc_CancelledContext_StopsCommand() {
execCmd := suite.NewExecCommand()
stoppedCh := make(chan bool, 1)
time.AfterFunc(1 * time.Second, func() {
// Allow lots of time for slow testing with `-race`.
time.AfterFunc(10*time.Second, func() {
close(stoppedCh)
})
execCmd.SetStopFunc(func() {
Expand Down Expand Up @@ -179,4 +180,3 @@ func (suite *ExecCommandImplTestSuite) TestExitCode_ReturnsExitCodeErrIfSet() {
func TestExecCommandImpl(t *testing.T) {
suite.Run(t, new(ExecCommandImplTestSuite))
}

0 comments on commit 382a4f6

Please sign in to comment.