From 0dcbfef9be6e6fe34a2424b86e78b3fe01a56523 Mon Sep 17 00:00:00 2001 From: Dragan Milic Date: Tue, 4 Apr 2023 01:28:03 +0200 Subject: [PATCH] cancel context for each scenario (#514) * 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 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 Co-authored-by: Viacheslav Poturaev --- CHANGELOG.md | 1 + suite.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 869c119..c99edcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/suite.go b/suite.go index dc63013..b2261ab 100644 --- a/suite.go +++ b/suite.go @@ -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)