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

Parsing error with comment only feature files #179

Open
enkessler opened this issue Sep 30, 2023 · 6 comments
Open

Parsing error with comment only feature files #179

enkessler opened this issue Sep 30, 2023 · 6 comments

Comments

@enkessler
Copy link

👓 What did you see?

I encountered a parsing error when running a Cucumber suite that included a feature file containing only a comment line.

unexpected end of file, expected: #Language, #TagLine, #FeatureLine, #Comment, #Empty (Cucumber::Core::Gherkin::ParseError)

✅ What did you expect to see?

I expected the file to parse cleanly and have no impact on the Cucumber execution (no errors, no pickles, etc.)

📦 Which tool/library version are you using?

OS: Windows
Language: Ruby
Cucumber version: various, as needed for whatever version of cucumber-gherkin that I was using
Gherkin versions: 9-27. All versions of cucumber-gherkin are affected

🔬 How could we reproduce it?

Steps to reproduce the behavior:

  1. Have a feature file that only contains comments
    "my_great_idea.feature"
# Must write this idea down before I go to lunch and forget
  1. Attempt to run the feature
    cucumber my_great_idea.feature
  2. Get a parsing error
    unexpected end of file, expected: #Language, #TagLine, #FeatureLine, #Comment, #Empty (Cucumber::Core::Gherkin::ParseError)

📚 Any additional context?

Given that the parsing error explicitly lists #Comment tokens as a valid expectation at that point in the file, I am under the impression that the example feature is intended to be syntactically valid and that this is a bug in the parser.

This text was originally generated from a template, then edited by hand. You can modify the template here.

@luke-hill
Copy link
Contributor

luke-hill commented Oct 27, 2023

This sounds a legit issue. However I have just re-tested this on cucumber 9.0.2 and I cannot reproduce it.
I also re-tested it on cucumber 8.0, which was using gherkin 23.0.1 (Which is a bit old).

However I'm not certain we have done many / all fixes recently. My only thought is that we are now restricting gherkin quite aggressively in cucumber ruby because of some new bug fixes / refactors, maybe this has implicitly fixed this?

Can you re-test using cucumber ruby 9.0.2 please @enkessler

@enkessler
Copy link
Author

For cucumber 9.0.2 it works fine. After doing a bundle update It looks like it is only continuing to happen for older versions of Cucumber (e.g. 6.x, 2.x). So updating Cucumber as much as possible did fix the problem, although I am surprised that what presented as a parsing issue appears to instead be a test framework issue instead. A test might need to be added to cucumber-ruby.

In any case, I will continue to work around this issue by having non-empty feature files because I need to be able to use both newer and older versions of Cucumber.

@luke-hill
Copy link
Contributor

luke-hill commented Nov 27, 2023

So we have a new way of doing "things" in cucumber that is presented in the CCK. We are currently looking to do 2 things.

1 - Evaluate our CCK try add new items (I'll make a note to ensure we have a comment based CCK if we don't already). EDIT: There isn't a "fat" gherkin spec nor a "thin" CCK spec for this. I'll have a chat and we need to get a new issue raised for this. 100% agree this needs doing
2 - Port the CCK "inside" cucumber-ruby. Currently js sits inside cucumber-js, cucumber-jvm is a WIP (half n half), cucumber-ruby sits wholly outside.

If you want to manage / check progress or contribute feel free to

@mattwynne
Copy link
Member

I am surprised that what presented as a parsing issue appears to instead be a test framework issue instead.

Looking at the error message, It strikes me as more likely that this was indeed a parsing issue, in an older version of the Gherkin parser being used by the older version of Cucumber you were using.

If you have the capacity to investigate the details a bit more @enkessler and send a PR to improve the UX for these older versions of Cucumber, please go ahead. I don't see an actionable change here to the Gherkin library though so I think we need to close this issue.

@luke-hill
Copy link
Contributor

Hi @mattwynne - I was planning on keeping this open as a note to get the 2 things done. Once I've got those two things done I think we should close this as then we'll be able to monitor this better

@luke-hill luke-hill reopened this Nov 28, 2023
@Kingdutch
Copy link

Kingdutch commented Nov 29, 2023

I had something similar using the cucumber/gherkin package in PHP version 27.0.0

The following gave an error:

@tags here
Feature: Feature decription
  # This causes an error
  Benefit: Some benefit
  Role: To a user type
  Goal/desire: That wants to achieve something

  Scenario: Rest of the file omitted
     Given some set-up
     # This comment here is actually not an issue

The error is reported for the lines that have "Benefit", "Role", "Goal". If I remove the # This causes an error line then everything works as expected.

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

No branches or pull requests

4 participants