Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix @retry, @serial and @allow.skipped tags inheritance #237

Merged
merged 5 commits into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@ All user visible changes to `cucumber` crate will be documented in this file. Th



## [0.15.2] · 2022-10-??
[0.15.2]: /../../tree/v0.15.2
## [0.16.0] · 2022-10-??
[0.16.0]: /../../tree/v0.16.0

[Diff](/../../compare/v0.15.1...v0.15.2) | [Milestone](/../../milestone/17)
[Diff](/../../compare/v0.15.1...v0.16.0) | [Milestone](/../../milestone/17)

### BC Breaks

- Upgraded [`gherkin`] crate to 0.13 version. ([4cad49f])
tyranron marked this conversation as resolved.
Show resolved Hide resolved

### Fixed

- Parsing error on a `Feature` having comment and tag simultaneously. ([cucumber-rs/gherkin#37], [cucumber-rs/gherkin#35])
- `@retry`, `@serial` and `@allow.skipped` tags inheritance ([#237])

[4cad49f]: /../../commit/4cad49f8d8f5d0458dcb538aa044a5fff1e6fa10
[#237]: /../../pull/237
[cucumber-rs/gherkin#35]: https://github.com/cucumber-rs/gherkin/issues/35
[cucumber-rs/gherkin#37]: https://github.com/cucumber-rs/gherkin/pull/37

Expand Down
6 changes: 4 additions & 2 deletions book/src/writing/tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@ To filter out running [scenario]s we may use:

[Tags][tag] may be placed above the following [Gherkin] elements:
- [`Feature`][feature]
- [`Rule`][rule]
- [`Scenario`][scenario]
- [`Scenario Outline`]
- [`Examples`]

It's _not_ possible to place [tag]s above [`Background`](background.md) or [step]s (`Given`, `When`, `Then`, `And` and `But`).

[Tags][tag] are inherited by child elements:
- [`Feature`][feature] [tag]s will be inherited by [`Scenario`][scenario], [`Scenario Outline`], or [`Examples`].
- [`Feature`][feature] and [`Rule`][rule] [tag]s will be inherited by [`Scenario`][scenario], [`Scenario Outline`], or [`Examples`].
- [`Scenario Outline`] [tag]s will be inherited by [`Examples`].

```gherkin
Expand Down Expand Up @@ -221,7 +222,8 @@ Feature: Animal feature
[escaping]: https://github.com/cucumber/tag-expressions/tree/6f444830b23bd8e0c5a2617cd51b91bc2e05adde#escaping
[feature]: https://cucumber.io/docs/gherkin/reference#feature
[Gherkin]: https://cucumber.io/docs/gherkin/reference
[rule]: https://cucumber.io/docs/gherkin/reference#rule
[scenario]: https://cucumber.io/docs/gherkin/reference#example
[step]: https://cucumber.io/docs/gherkin/reference#steps
[tag]: https://cucumber.io/docs/cucumber/api#tags
[tag expressions]: https://cucumber.io/docs/cucumber/api#tag-expressions
[step]: https://cucumber.io/docs/gherkin/reference#steps
5 changes: 1 addition & 4 deletions src/cucumber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -731,10 +731,7 @@ where
tags.eval(
feat.tags
.iter()
.chain(
rule.into_iter()
.flat_map(|r| r.tags.iter()),
)
.chain(rule.iter().flat_map(|r| &r.tags))
.chain(scenario.tags.iter()),
)
},
Expand Down
22 changes: 13 additions & 9 deletions src/runner/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,11 @@ impl RetryOptions {
let apply_cli = |options: Option<_>| {
let matched = cli.retry_tag_filter.as_ref().map_or_else(
|| cli.retry.is_some() || cli.retry_after.is_some(),
|op| op.eval(&scenario.tags),
|op| {
op.eval(scenario.tags.iter().chain(
rule.iter().flat_map(|r| &r.tags).chain(&feature.tags),
))
},
);

(options.is_some() || matched).then(|| Self {
Expand Down Expand Up @@ -388,14 +392,14 @@ impl<World, F, B, A> fmt::Debug for Basic<World, F, B, A> {

impl<World> Default for Basic<World> {
fn default() -> Self {
let which_scenario: WhichScenarioFn = |_, _, scenario| {
let has_serial_tag =
scenario.tags.iter().any(|tag| tag == "serial");
if has_serial_tag {
ScenarioType::Serial
} else {
ScenarioType::Concurrent
}
let which_scenario: WhichScenarioFn = |feature, rule, scenario| {
scenario
.tags
.iter()
.chain(rule.iter().flat_map(|r| &r.tags))
.chain(&feature.tags)
.find(|tag| *tag == "serial")
.map_or(ScenarioType::Concurrent, |_| ScenarioType::Serial)
};

Self {
Expand Down
8 changes: 6 additions & 2 deletions src/writer/fail_on_skipped.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,12 @@ impl<Writer> From<Writer> for FailOnSkipped<Writer> {
fn from(writer: Writer) -> Self {
Self {
writer,
should_fail: |_, _, sc| {
!sc.tags.iter().any(|t| t == "allow.skipped")
should_fail: |feat, rule, sc| {
!sc.tags
.iter()
.chain(rule.iter().flat_map(|r| &r.tags))
.chain(&feat.tags)
.any(|t| t == "allow.skipped")
},
}
}
Expand Down
Loading