Skip to content

Commit

Permalink
cancel context for each scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
draganm committed Dec 27, 2022
1 parent c35ea0b commit 8309320
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt
## Unreleased

### Changed
- Each scenario is run with a cancellable `context.Context` which is cancelled at the end of the scenario. ([514](https://github.com/cucumber/godog/pull/514) - [draganm](https://github.com/draganm))
- README example is updated with `context.Context` and `go test` usage. ([477](https://github.com/cucumber/godog/pull/477) - [vearutop](https://github.com/vearutop))
- Removed deprecation of `godog.BindFlags` ([498](https://github.com/cucumber/godog/pull/498) - [vearutop](https://github.com/vearutop))

Expand Down
6 changes: 6 additions & 0 deletions suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,12 @@ func (s *suite) runPickle(pickle *messages.Pickle) (err error) {
ctx = context.Background()
}

var cancel context.CancelFunc

ctx, cancel = context.WithCancel(ctx)

defer cancel()

if len(pickle.Steps) == 0 {
pr := models.PickleResult{PickleID: pickle.Id, StartedAt: utils.TimeNowFunc()}
s.storage.MustInsertPickleResult(pr)
Expand Down

0 comments on commit 8309320

Please sign in to comment.