Skip to content

Commit

Permalink
cancel context for each scenario (#514)
Browse files Browse the repository at this point in the history
* fix(deps): update module github.com/cucumber/gherkin/go/v26 to v26.1.0 (#549)

* Update CI for go1.20 (#552)

* fix(deps): update module github.com/cucumber/gherkin/go/v26 to v26.1.0

* Tidy modules

---------

Co-authored-by: Viacheslav Poturaev <vearutop@gmail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* cancel context for each scenario

* Update suite.go

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Viacheslav Poturaev <vearutop@gmail.com>
Co-authored-by: Viacheslav Poturaev <nanopeni@gmail.com>
  • Loading branch information
4 people committed Apr 3, 2023
1 parent 472ea27 commit 0dcbfef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt

## [v0.12.6]
### 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))
- Pretty Print when using rules. ([480](https://github.com/cucumber/godog/pull/480) - [dumpsterfireproject](https://github.com/dumpsterfireproject))
Expand Down
4 changes: 4 additions & 0 deletions suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,10 @@ func (s *suite) runPickle(pickle *messages.Pickle) (err error) {
ctx = context.Background()
}

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 0dcbfef

Please sign in to comment.