-
Notifications
You must be signed in to change notification settings - Fork 95
change: Throw ParserException if file ends with tags #313
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
Conversation
For parity with cucumber/gherkin, do not accept feature files that end with `@tags` with no subsequent content. cucumber/gherkin is relatively permissive about incomplete files in some cases (for example, it is explicitly valid to have a file with a Feature: but no scenarios, or a Scenario: with no steps). I suspect this is intentional to avoid parser errors while iterating on a feature. However, the presence of `@tags` at the end of the file is unusual and suggests that the file is incomplete or damaged. cucumber/gherkin treats this as an exception and so should we.
| $parser->parse( | ||
| <<<'FEATURE' | ||
| Feature: | ||
| Scenario: | ||
| Given step | ||
| @skipped | ||
| FEATURE | ||
| ); | ||
| try { | ||
| $parser->parse( | ||
| <<<'FEATURE' | ||
| Feature: | ||
| Scenario: | ||
| Given step | ||
| @skipped | ||
| FEATURE, | ||
| ); | ||
| } catch (ParserException $e) { | ||
| // expected - features cannot end with tags | ||
| $this->assertSame('Unexpected end of file after tags on line 5', $e->getMessage()); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test relied on us parsing tags at the end of a file, but I don't think that was expected end-user behaviour. It was simply to prove that the parser state resets correctly on moving to the next file, and since we already know that tags are reset between features / scenarios / etc, the test had to create an artificial case where the tag was not attached to any node.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #313 +/- ##
============================================
+ Coverage 96.21% 96.23% +0.01%
- Complexity 596 598 +2
============================================
Files 35 35
Lines 1745 1751 +6
============================================
+ Hits 1679 1685 +6
Misses 66 66
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks @acoulton
For parity with cucumber/gherkin, do not accept feature files that end with
@tagswith no subsequent content.cucumber/gherkin is relatively permissive about incomplete files in some cases (for example, it is explicitly valid to have a file with a Feature: but no scenarios, or a Scenario: with no steps). I suspect this is intentional to avoid parser errors while iterating on a partially-complete feature file.
However, the presence of
@tagsat the end of the file is unusual and suggests that the file is incomplete or damaged. cucumber/gherkin treats this as an exception and so should we.