Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion src/feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ fn expand_scenario(
// https://github.com/Canop/lazy-regex/issues/10
#[expect(clippy::unwrap_used, reason = "regex is valid")]
static TEMPLATE_REGEX: LazyLock<Regex> =
LazyLock::new(|| Regex::new(r"<([^>\s]+)>").unwrap());
LazyLock::new(|| Regex::new("<([^>]+)>").unwrap());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aepfli allowing spaces seems ok, but does it mean we should also allow \t, \r, \n and other "brothers"?

I think it's only meaningful to allow spaces strictly. And only between non-space characters. Otherwise, this regex allows < > placeholder, which is weird.


if scenario.examples.is_empty() {
return vec![Ok(scenario)];
Expand Down
6 changes: 3 additions & 3 deletions tests/features/output/background_scenario_outline.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Feature: Outline
Scenario Outline: foo
Given foo is <bar1>
When foo is <bar2>
Then foo is <bar3>
Then foo is <bar three>

Examples:
| bar1 | bar2 | bar3 |
| 1 | 2 | 3 |
| bar1 | bar2 | bar three |
| 1 | 2 | 3 |
24 changes: 12 additions & 12 deletions tests/features/output/background_scenario_outline.feature.debug.out

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Feature: Outline

Scenario Outline: foo
Given foo is <bar 1>
When foo is <bar two>
Then foo is <bar three>

Examples:
| bar 1 | bar two | bar three |
| 0 | 1 | 2 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Feature: Outline
Scenario Outline: foo
✔ Given foo is 0
✔ When foo is 1
✔ Then foo is 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Feature: Outline
 Scenario Outline: foo
Given foo is 0
 ✔ Given foo is 0
When foo is 1
 ✔ When foo is 1
Then foo is 2
 ✔ Then foo is 2
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ParsingFinished { features: 1, rules: 0, scenarios: 1, steps: 3, parser_errors: 0 }
Started
Feature(Feature { keyword: "Feature", name: "Outline", description: None, background: None, scenarios: [Scenario { keyword: "Scenario Outline", name: "foo", description: None, steps: [Step { keyword: "Given ", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 4 } }, Step { keyword: "When ", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 5 } }, Step { keyword: "Then ", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 6 } }], examples: [Examples { keyword: "Examples", name: None, description: None, table: Some(Table { rows: [["bar 1", "bar two", "bar three"], ["0", "1", "2"]], position: LineCol { line: 9 } }), tags: [], position: LineCol { line: 8 } }], tags: [], position: LineCol { line: 10 } }], rules: [], tags: [], position: LineCol { line: 1 }, }, Started)
Feature(Feature { keyword: "Feature", name: "Outline", description: None, background: None, scenarios: [Scenario { keyword: "Scenario Outline", name: "foo", description: None, steps: [Step { keyword: "Given ", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 4 } }, Step { keyword: "When ", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 5 } }, Step { keyword: "Then ", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 6 } }], examples: [Examples { keyword: "Examples", name: None, description: None, table: Some(Table { rows: [["bar 1", "bar two", "bar three"], ["0", "1", "2"]], position: LineCol { line: 9 } }), tags: [], position: LineCol { line: 8 } }], tags: [], position: LineCol { line: 10 } }], rules: [], tags: [], position: LineCol { line: 1 }, }, Scenario(Scenario { keyword: "Scenario Outline", name: "foo", description: None, steps: [Step { keyword: "Given ", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 4 } }, Step { keyword: "When ", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 5 } }, Step { keyword: "Then ", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 6 } }], examples: [Examples { keyword: "Examples", name: None, description: None, table: Some(Table { rows: [["bar 1", "bar two", "bar three"], ["0", "1", "2"]], position: LineCol { line: 9 } }), tags: [], position: LineCol { line: 8 } }], tags: [], position: LineCol { line: 10 } }, RetryableScenario { event: Started, retries: None }))
Feature(Feature { keyword: "Feature", name: "Outline", description: None, background: None, scenarios: [Scenario { keyword: "Scenario Outline", name: "foo", description: None, steps: [Step { keyword: "Given ", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 4 } }, Step { keyword: "When ", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 5 } }, Step { keyword: "Then ", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 6 } }], examples: [Examples { keyword: "Examples", name: None, description: None, table: Some(Table { rows: [["bar 1", "bar two", "bar three"], ["0", "1", "2"]], position: LineCol { line: 9 } }), tags: [], position: LineCol { line: 8 } }], tags: [], position: LineCol { line: 10 } }], rules: [], tags: [], position: LineCol { line: 1 }, }, Scenario(Scenario { keyword: "Scenario Outline", name: "foo", description: None, steps: [Step { keyword: "Given ", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 4 } }, Step { keyword: "When ", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 5 } }, Step { keyword: "Then ", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 6 } }], examples: [Examples { keyword: "Examples", name: None, description: None, table: Some(Table { rows: [["bar 1", "bar two", "bar three"], ["0", "1", "2"]], position: LineCol { line: 9 } }), tags: [], position: LineCol { line: 8 } }], tags: [], position: LineCol { line: 10 } }, RetryableScenario { event: Step(Step { keyword: "Given ", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 4 } }, Started), retries: None }))
Feature(Feature { keyword: "Feature", name: "Outline", description: None, background: None, scenarios: [Scenario { keyword: "Scenario Outline", name: "foo", description: None, steps: [Step { keyword: "Given ", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 4 } }, Step { keyword: "When ", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 5 } }, Step { keyword: "Then ", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 6 } }], examples: [Examples { keyword: "Examples", name: None, description: None, table: Some(Table { rows: [["bar 1", "bar two", "bar three"], ["0", "1", "2"]], position: LineCol { line: 9 } }), tags: [], position: LineCol { line: 8 } }], tags: [], position: LineCol { line: 10 } }], rules: [], tags: [], position: LineCol { line: 1 }, }, Scenario(Scenario { keyword: "Scenario Outline", name: "foo", description: None, steps: [Step { keyword: "Given ", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 4 } }, Step { keyword: "When ", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 5 } }, Step { keyword: "Then ", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 6 } }], examples: [Examples { keyword: "Examples", name: None, description: None, table: Some(Table { rows: [["bar 1", "bar two", "bar three"], ["0", "1", "2"]], position: LineCol { line: 9 } }), tags: [], position: LineCol { line: 8 } }], tags: [], position: LineCol { line: 10 } }, RetryableScenario { event: Step(Step { keyword: "Given ", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 4 } }, Passed(CaptureLocations(Captures { pid: Some(PatternID(0)), spans: {0: 0..8, 1: 7..8} }), Some(Location { line: 9, column: 1 }))), retries: None }))
Feature(Feature { keyword: "Feature", name: "Outline", description: None, background: None, scenarios: [Scenario { keyword: "Scenario Outline", name: "foo", description: None, steps: [Step { keyword: "Given ", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 4 } }, Step { keyword: "When ", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 5 } }, Step { keyword: "Then ", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 6 } }], examples: [Examples { keyword: "Examples", name: None, description: None, table: Some(Table { rows: [["bar 1", "bar two", "bar three"], ["0", "1", "2"]], position: LineCol { line: 9 } }), tags: [], position: LineCol { line: 8 } }], tags: [], position: LineCol { line: 10 } }], rules: [], tags: [], position: LineCol { line: 1 }, }, Scenario(Scenario { keyword: "Scenario Outline", name: "foo", description: None, steps: [Step { keyword: "Given ", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 4 } }, Step { keyword: "When ", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 5 } }, Step { keyword: "Then ", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 6 } }], examples: [Examples { keyword: "Examples", name: None, description: None, table: Some(Table { rows: [["bar 1", "bar two", "bar three"], ["0", "1", "2"]], position: LineCol { line: 9 } }), tags: [], position: LineCol { line: 8 } }], tags: [], position: LineCol { line: 10 } }, RetryableScenario { event: Step(Step { keyword: "When ", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 5 } }, Started), retries: None }))
Feature(Feature { keyword: "Feature", name: "Outline", description: None, background: None, scenarios: [Scenario { keyword: "Scenario Outline", name: "foo", description: None, steps: [Step { keyword: "Given ", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 4 } }, Step { keyword: "When ", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 5 } }, Step { keyword: "Then ", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 6 } }], examples: [Examples { keyword: "Examples", name: None, description: None, table: Some(Table { rows: [["bar 1", "bar two", "bar three"], ["0", "1", "2"]], position: LineCol { line: 9 } }), tags: [], position: LineCol { line: 8 } }], tags: [], position: LineCol { line: 10 } }], rules: [], tags: [], position: LineCol { line: 1 }, }, Scenario(Scenario { keyword: "Scenario Outline", name: "foo", description: None, steps: [Step { keyword: "Given ", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 4 } }, Step { keyword: "When ", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 5 } }, Step { keyword: "Then ", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 6 } }], examples: [Examples { keyword: "Examples", name: None, description: None, table: Some(Table { rows: [["bar 1", "bar two", "bar three"], ["0", "1", "2"]], position: LineCol { line: 9 } }), tags: [], position: LineCol { line: 8 } }], tags: [], position: LineCol { line: 10 } }, RetryableScenario { event: Step(Step { keyword: "When ", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 5 } }, Passed(CaptureLocations(Captures { pid: Some(PatternID(0)), spans: {0: 0..8, 1: 7..8} }), Some(Location { line: 10, column: 1 }))), retries: None }))
Feature(Feature { keyword: "Feature", name: "Outline", description: None, background: None, scenarios: [Scenario { keyword: "Scenario Outline", name: "foo", description: None, steps: [Step { keyword: "Given ", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 4 } }, Step { keyword: "When ", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 5 } }, Step { keyword: "Then ", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 6 } }], examples: [Examples { keyword: "Examples", name: None, description: None, table: Some(Table { rows: [["bar 1", "bar two", "bar three"], ["0", "1", "2"]], position: LineCol { line: 9 } }), tags: [], position: LineCol { line: 8 } }], tags: [], position: LineCol { line: 10 } }], rules: [], tags: [], position: LineCol { line: 1 }, }, Scenario(Scenario { keyword: "Scenario Outline", name: "foo", description: None, steps: [Step { keyword: "Given ", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 4 } }, Step { keyword: "When ", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 5 } }, Step { keyword: "Then ", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 6 } }], examples: [Examples { keyword: "Examples", name: None, description: None, table: Some(Table { rows: [["bar 1", "bar two", "bar three"], ["0", "1", "2"]], position: LineCol { line: 9 } }), tags: [], position: LineCol { line: 8 } }], tags: [], position: LineCol { line: 10 } }, RetryableScenario { event: Step(Step { keyword: "Then ", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 6 } }, Started), retries: None }))
Feature(Feature { keyword: "Feature", name: "Outline", description: None, background: None, scenarios: [Scenario { keyword: "Scenario Outline", name: "foo", description: None, steps: [Step { keyword: "Given ", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 4 } }, Step { keyword: "When ", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 5 } }, Step { keyword: "Then ", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 6 } }], examples: [Examples { keyword: "Examples", name: None, description: None, table: Some(Table { rows: [["bar 1", "bar two", "bar three"], ["0", "1", "2"]], position: LineCol { line: 9 } }), tags: [], position: LineCol { line: 8 } }], tags: [], position: LineCol { line: 10 } }], rules: [], tags: [], position: LineCol { line: 1 }, }, Scenario(Scenario { keyword: "Scenario Outline", name: "foo", description: None, steps: [Step { keyword: "Given ", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 4 } }, Step { keyword: "When ", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 5 } }, Step { keyword: "Then ", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 6 } }], examples: [Examples { keyword: "Examples", name: None, description: None, table: Some(Table { rows: [["bar 1", "bar two", "bar three"], ["0", "1", "2"]], position: LineCol { line: 9 } }), tags: [], position: LineCol { line: 8 } }], tags: [], position: LineCol { line: 10 } }, RetryableScenario { event: Step(Step { keyword: "Then ", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 6 } }, Passed(CaptureLocations(Captures { pid: Some(PatternID(0)), spans: {0: 0..8, 1: 7..8} }), Some(Location { line: 11, column: 1 }))), retries: None }))
Feature(Feature { keyword: "Feature", name: "Outline", description: None, background: None, scenarios: [Scenario { keyword: "Scenario Outline", name: "foo", description: None, steps: [Step { keyword: "Given ", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 4 } }, Step { keyword: "When ", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 5 } }, Step { keyword: "Then ", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 6 } }], examples: [Examples { keyword: "Examples", name: None, description: None, table: Some(Table { rows: [["bar 1", "bar two", "bar three"], ["0", "1", "2"]], position: LineCol { line: 9 } }), tags: [], position: LineCol { line: 8 } }], tags: [], position: LineCol { line: 10 } }], rules: [], tags: [], position: LineCol { line: 1 }, }, Scenario(Scenario { keyword: "Scenario Outline", name: "foo", description: None, steps: [Step { keyword: "Given ", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 4 } }, Step { keyword: "When ", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 5 } }, Step { keyword: "Then ", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 6 } }], examples: [Examples { keyword: "Examples", name: None, description: None, table: Some(Table { rows: [["bar 1", "bar two", "bar three"], ["0", "1", "2"]], position: LineCol { line: 9 } }), tags: [], position: LineCol { line: 8 } }], tags: [], position: LineCol { line: 10 } }, RetryableScenario { event: Finished, retries: None }))
Feature(Feature { keyword: "Feature", name: "Outline", description: None, background: None, scenarios: [Scenario { keyword: "Scenario Outline", name: "foo", description: None, steps: [Step { keyword: "Given ", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 4 } }, Step { keyword: "When ", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 5 } }, Step { keyword: "Then ", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 6 } }], examples: [Examples { keyword: "Examples", name: None, description: None, table: Some(Table { rows: [["bar 1", "bar two", "bar three"], ["0", "1", "2"]], position: LineCol { line: 9 } }), tags: [], position: LineCol { line: 8 } }], tags: [], position: LineCol { line: 10 } }], rules: [], tags: [], position: LineCol { line: 1 }, }, Finished)
Finished