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 parser skipping files named .feature #201

Merged
merged 6 commits into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ All user visible changes to `cucumber` crate will be documented in this file. Th



## [0.11.3] · 2022-01-31
[0.11.3]: /../../tree/v0.11.3

[Diff](/../../compare/v0.11.2...v0.11.3) | [Milestone](/../../milestone/8)

### Fixed

- `parser::Basic` skipping files named `.feature`. ([#201])

[#201]: /../../issues/201




## [0.11.2] · 2022-01-19
[0.11.2]: /../../tree/v0.11.2

Expand Down
6 changes: 0 additions & 6 deletions src/parser/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ impl<I: AsRef<Path>> Parser<I> for Basic {
walker
.filter_map(Result::ok)
.sorted_by(|l, r| Ord::cmp(l.path(), r.path()))
.filter(|file| {
file.path()
.extension()
.map(|ext| ext == "feature")
.unwrap_or_default()
})
.map(|file| {
let env = self
.language
Expand Down
5 changes: 5 additions & 0 deletions tests/features/output/.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Feature: output
Scenario: output
Given foo is 0
When foo is 1
Then foo is 2
12 changes: 12 additions & 0 deletions tests/features/output/.feature.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Started
Feature(Feature { keyword: "Feature", name: "output", description: None, background: None, scenarios: [Scenario { keyword: "Scenario", name: "output", steps: [Step { keyword: "Given", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 3, col: 5 } }, Step { keyword: "When", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 4, col: 5 } }, Step { keyword: "Then", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 5, col: 5 } }], examples: [], tags: [], position: LineCol { line: 2, col: 3 } }], rules: [], tags: [], position: LineCol { line: 1, col: 1 }, }, Started)
Feature(Feature { keyword: "Feature", name: "output", description: None, background: None, scenarios: [Scenario { keyword: "Scenario", name: "output", steps: [Step { keyword: "Given", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 3, col: 5 } }, Step { keyword: "When", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 4, col: 5 } }, Step { keyword: "Then", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 5, col: 5 } }], examples: [], tags: [], position: LineCol { line: 2, col: 3 } }], rules: [], tags: [], position: LineCol { line: 1, col: 1 }, }, Scenario(Scenario { keyword: "Scenario", name: "output", steps: [Step { keyword: "Given", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 3, col: 5 } }, Step { keyword: "When", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 4, col: 5 } }, Step { keyword: "Then", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 5, col: 5 } }], examples: [], tags: [], position: LineCol { line: 2, col: 3 } }, Started))
Feature(Feature { keyword: "Feature", name: "output", description: None, background: None, scenarios: [Scenario { keyword: "Scenario", name: "output", steps: [Step { keyword: "Given", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 3, col: 5 } }, Step { keyword: "When", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 4, col: 5 } }, Step { keyword: "Then", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 5, col: 5 } }], examples: [], tags: [], position: LineCol { line: 2, col: 3 } }], rules: [], tags: [], position: LineCol { line: 1, col: 1 }, }, Scenario(Scenario { keyword: "Scenario", name: "output", steps: [Step { keyword: "Given", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 3, col: 5 } }, Step { keyword: "When", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 4, col: 5 } }, Step { keyword: "Then", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 5, col: 5 } }], examples: [], tags: [], position: LineCol { line: 2, col: 3 } }, Step(Step { keyword: "Given", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 3, col: 5 } }, Started)))
Feature(Feature { keyword: "Feature", name: "output", description: None, background: None, scenarios: [Scenario { keyword: "Scenario", name: "output", steps: [Step { keyword: "Given", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 3, col: 5 } }, Step { keyword: "When", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 4, col: 5 } }, Step { keyword: "Then", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 5, col: 5 } }], examples: [], tags: [], position: LineCol { line: 2, col: 3 } }], rules: [], tags: [], position: LineCol { line: 1, col: 1 }, }, Scenario(Scenario { keyword: "Scenario", name: "output", steps: [Step { keyword: "Given", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 3, col: 5 } }, Step { keyword: "When", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 4, col: 5 } }, Step { keyword: "Then", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 5, col: 5 } }], examples: [], tags: [], position: LineCol { line: 2, col: 3 } }, Step(Step { keyword: "Given", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 3, col: 5 } }, Passed(CaptureLocations(Locations([Some(0), Some(8), Some(7), Some(8)]))))))
Feature(Feature { keyword: "Feature", name: "output", description: None, background: None, scenarios: [Scenario { keyword: "Scenario", name: "output", steps: [Step { keyword: "Given", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 3, col: 5 } }, Step { keyword: "When", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 4, col: 5 } }, Step { keyword: "Then", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 5, col: 5 } }], examples: [], tags: [], position: LineCol { line: 2, col: 3 } }], rules: [], tags: [], position: LineCol { line: 1, col: 1 }, }, Scenario(Scenario { keyword: "Scenario", name: "output", steps: [Step { keyword: "Given", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 3, col: 5 } }, Step { keyword: "When", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 4, col: 5 } }, Step { keyword: "Then", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 5, col: 5 } }], examples: [], tags: [], position: LineCol { line: 2, col: 3 } }, Step(Step { keyword: "When", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 4, col: 5 } }, Started)))
Feature(Feature { keyword: "Feature", name: "output", description: None, background: None, scenarios: [Scenario { keyword: "Scenario", name: "output", steps: [Step { keyword: "Given", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 3, col: 5 } }, Step { keyword: "When", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 4, col: 5 } }, Step { keyword: "Then", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 5, col: 5 } }], examples: [], tags: [], position: LineCol { line: 2, col: 3 } }], rules: [], tags: [], position: LineCol { line: 1, col: 1 }, }, Scenario(Scenario { keyword: "Scenario", name: "output", steps: [Step { keyword: "Given", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 3, col: 5 } }, Step { keyword: "When", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 4, col: 5 } }, Step { keyword: "Then", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 5, col: 5 } }], examples: [], tags: [], position: LineCol { line: 2, col: 3 } }, Step(Step { keyword: "When", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 4, col: 5 } }, Passed(CaptureLocations(Locations([Some(0), Some(8), Some(7), Some(8)]))))))
Feature(Feature { keyword: "Feature", name: "output", description: None, background: None, scenarios: [Scenario { keyword: "Scenario", name: "output", steps: [Step { keyword: "Given", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 3, col: 5 } }, Step { keyword: "When", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 4, col: 5 } }, Step { keyword: "Then", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 5, col: 5 } }], examples: [], tags: [], position: LineCol { line: 2, col: 3 } }], rules: [], tags: [], position: LineCol { line: 1, col: 1 }, }, Scenario(Scenario { keyword: "Scenario", name: "output", steps: [Step { keyword: "Given", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 3, col: 5 } }, Step { keyword: "When", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 4, col: 5 } }, Step { keyword: "Then", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 5, col: 5 } }], examples: [], tags: [], position: LineCol { line: 2, col: 3 } }, Step(Step { keyword: "Then", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 5, col: 5 } }, Started)))
Feature(Feature { keyword: "Feature", name: "output", description: None, background: None, scenarios: [Scenario { keyword: "Scenario", name: "output", steps: [Step { keyword: "Given", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 3, col: 5 } }, Step { keyword: "When", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 4, col: 5 } }, Step { keyword: "Then", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 5, col: 5 } }], examples: [], tags: [], position: LineCol { line: 2, col: 3 } }], rules: [], tags: [], position: LineCol { line: 1, col: 1 }, }, Scenario(Scenario { keyword: "Scenario", name: "output", steps: [Step { keyword: "Given", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 3, col: 5 } }, Step { keyword: "When", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 4, col: 5 } }, Step { keyword: "Then", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 5, col: 5 } }], examples: [], tags: [], position: LineCol { line: 2, col: 3 } }, Step(Step { keyword: "Then", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 5, col: 5 } }, Passed(CaptureLocations(Locations([Some(0), Some(8), Some(7), Some(8)]))))))
Feature(Feature { keyword: "Feature", name: "output", description: None, background: None, scenarios: [Scenario { keyword: "Scenario", name: "output", steps: [Step { keyword: "Given", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 3, col: 5 } }, Step { keyword: "When", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 4, col: 5 } }, Step { keyword: "Then", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 5, col: 5 } }], examples: [], tags: [], position: LineCol { line: 2, col: 3 } }], rules: [], tags: [], position: LineCol { line: 1, col: 1 }, }, Scenario(Scenario { keyword: "Scenario", name: "output", steps: [Step { keyword: "Given", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 3, col: 5 } }, Step { keyword: "When", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 4, col: 5 } }, Step { keyword: "Then", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 5, col: 5 } }], examples: [], tags: [], position: LineCol { line: 2, col: 3 } }, Finished))
Feature(Feature { keyword: "Feature", name: "output", description: None, background: None, scenarios: [Scenario { keyword: "Scenario", name: "output", steps: [Step { keyword: "Given", ty: Given, value: "foo is 0", docstring: None, table: None, position: LineCol { line: 3, col: 5 } }, Step { keyword: "When", ty: When, value: "foo is 1", docstring: None, table: None, position: LineCol { line: 4, col: 5 } }, Step { keyword: "Then", ty: Then, value: "foo is 2", docstring: None, table: None, position: LineCol { line: 5, col: 5 } }], examples: [], tags: [], position: LineCol { line: 2, col: 3 } }], rules: [], tags: [], position: LineCol { line: 1, col: 1 }, }, Finished)
Finished
6 changes: 6 additions & 0 deletions tests/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ mod spec {
.map(|entry| entry.file_name().to_str().unwrap().to_owned())
.collect::<Vec<String>>();

assert_eq!(
files.len(),
fs::read_dir("tests/features/output").unwrap().count() / 2,
"Not all `.feature` files were collected",
);

for file in files {
// TODO: Use "{file}" syntax once MSRV bumps above 1.58.
let out = fs::read_to_string(format!(
Expand Down