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

Tag parsing #215

Merged
merged 4 commits into from
Jul 12, 2021
Merged

Tag parsing #215

merged 4 commits into from
Jul 12, 2021

Conversation

ciaranmcnulty
Copy link
Contributor

Closes #210 and #213

Not too happy with the implementation yet

For the tag whitespace we could optionally show a warning rather than an exception for backwards compatibility

{
foreach ($tags as $tag) {
if (preg_match('/\s/', $tag)) {
throw new ParserException(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This could be E_USER_DEPRECATED if we think whitespace tags are a valid current usage rather than an error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you think about this @stof?

Copy link
Member

Choose a reason for hiding this comment

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

do tag expressions in TagFilter support tags with whitespace in them or no ? If such tags are not usable in TagFilter, then I would go for a ParserException

@stof
Copy link
Member

stof commented Feb 8, 2021

I would vote for adding such API to consume the line only partially instead of the hack about #

@ciaranmcnulty
Copy link
Contributor Author

@stof Yeah I will add something like consumeLineUntil($char) or similar

@stof
Copy link
Member

stof commented Feb 8, 2021

@ciaranmcnulty I suggest confirming upstream whether comments are meant to be allowed at the end of any line. If the answer is yes, it might be a matter of changing consumeLine instead.

@ciaranmcnulty
Copy link
Contributor Author

It looks like they're only allowed at the end of tags lines, added in cucumber/common#880

@ciaranmcnulty ciaranmcnulty requested a review from stof February 9, 2021 11:15
src/Behat/Gherkin/Lexer.php Outdated Show resolved Hide resolved
@ciaranmcnulty
Copy link
Contributor Author

ciaranmcnulty commented Feb 9, 2021

TagFilter is quite happy to be constructed with, and filter by tags with whitespace so there's a chance there are people depending on this functionality.

trigger_error with a deprecation warning?

@stof
Copy link
Member

stof commented Feb 9, 2021

@ciaranmcnulty then a deprecation is indeed better (and probably also in TagFilter if the filter uses a tag with whitespace)

@ciaranmcnulty
Copy link
Contributor Author

I think #220 is necessary to test the deprecations properly

@ciaranmcnulty
Copy link
Contributor Author

@stof would appreciate feedback on how the deprecation is implemented

@ciaranmcnulty ciaranmcnulty merged commit 3f94bb5 into Behat:master Jul 12, 2021
@funkyproject
Copy link

Hello ,

That trigger a deprecation notice when we use a filter likes "@tag1 && @tag2".
Even if the tags haven't spaces.

@stof
Copy link
Member

stof commented Oct 15, 2021

When using that where ?

@funkyproject
Copy link

@funkyproject
Copy link

It's about src/Behat/Gherkin/Filter/TagFilter.php on construct.
Maybe the trigger error can be moved into isTagsMatchCondition.

@stof
Copy link
Member

stof commented Oct 15, 2021

I agree. The deprecation warning should allow for spaces around the operators.

However, I would not do that in isTagsMatchCondition. We don't want to trigger the deprecation on each scenario

andriokha added a commit to andriokha/drupalextension that referenced this pull request Nov 14, 2021
Since Gherkin 4.9.0 tags with whitespace are deprecated: use a comma as
an explicit OR operator.

See
- Behat/Gherkin#213
- Behat/Gherkin#215
- https://behat.org/en/latest/user_guide/context/hooks.html#tagged-hooks

Closes jhedstrom#600
Berdir pushed a commit to Berdir/drupalextension that referenced this pull request Apr 24, 2022
Since Gherkin 4.9.0 tags with whitespace are deprecated: use a comma as
an explicit OR operator.

See
- Behat/Gherkin#213
- Behat/Gherkin#215
- https://behat.org/en/latest/user_guide/context/hooks.html#tagged-hooks

Closes jhedstrom#600
xurizaemon pushed a commit to xurizaemon/drupalextension that referenced this pull request Nov 28, 2022
Since Gherkin 4.9.0 tags with whitespace are deprecated: use a comma as
an explicit OR operator.

See
- Behat/Gherkin#213
- Behat/Gherkin#215
- https://behat.org/en/latest/user_guide/context/hooks.html#tagged-hooks

Closes jhedstrom#600
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Comments after tags are captured
3 participants