-
-
Notifications
You must be signed in to change notification settings - Fork 694
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
gherkin: Fix parsing of commented tags #880
Conversation
To create new cross-platform acceptance tests, this is the easiest way at the moment:
Since you started with Java, we could do all of this from |
Cheers! I'll check it out tomorrow. |
@@ -3,29 +3,29 @@ | |||
"astNodeIds": [ | |||
"4" | |||
], | |||
"id": "24", | |||
"id": "34", |
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.
@aslakhellesoy, @vincent-psarga I don't understand why these ids changed. These scenarios didn't change position. Is there an implicit ordering going on?
gherkin/dotnet/testdata/bad/whitespace_in_tags.feature.errors.ndjson
Outdated
Show resolved
Hide resolved
@luke-hill sorry. Took me like 45 minutes to do the ruby. Getting better at! |
In the past 6 months, `cucumber/cucumber`-repo has seen a variet of changes all of which have been fixed with this commit: * background to have `id` * rule to have `id` * examples to have `id` * ensure to only strip leading and trailing spaces in table cells. Keep newline intact * ensure escaped delimiter within doc_string is not recorded as escaped * doc_string has field change: contentType -> mediaType * ignore comments on tags See: cucumber/common#891 cucumber/common#880 cucumber/common#889 cucumber/common#800 At the time of this commit, master for `cucumber/cucumber` was at: a7c593f479e7ae739b49108f79bba4853352d99c
@mpkorstanje @aslakhellesoy @sebrose I run into this change wen I tried to align the .NET Gherkin parser to the others, but I don't understand it. Regarding my knowledge Gherkin was a language that only supported full line comments (so This PR changes this behavior, but only partially. It allows partial line comments, but only in tag lines. (At least based on the test files ( This seems to be inconsistent for me. Is this really what we wanted? |
It's limited to tags only. Handled in the same code that splits the tags into individual items.
Yes. It's the defacto behavior of various Gherkin highlighters and parsers. IDEA, Eclipse and the syntax highlighter on Github all have this behavior: Feature: example
@Tag #comment
Scenario: example #not a comment This is confusing users (#721) and I feel that avoiding this confusion is more important then being consistent. |
Summary
Tag parsing in gherkin suffers from four problems
@
.@
, tag expression do not support white space.To illustrate:
In Java this example is tagged with the strings
@Example
,Tag
,and
,#Comment
. In other languages this would be tagged with just@Example tag and #Comment
.When trying to select this scenario using the tag expression
@Example
only the Java scenario would be executed. Trying to use@Example tag and #Comment
as a tag expression results in a parse error. This means that tags are single words.So by first removing the comments from the tag line by splitting on
\s#
and then splitting uncommented tags on@
we can parse tags in line with IDE expectations. Invalidating tags containing white space takes care of non-selectable tags.Motivation and Context
Fixes: #721
Types of changes
Checklist: