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

PickleLineFilter doesn't work with absolute paths #1900

Closed
jan-molak opened this issue Jan 26, 2022 · 4 comments · Fixed by #2063
Closed

PickleLineFilter doesn't work with absolute paths #1900

jan-molak opened this issue Jan 26, 2022 · 4 comments · Fixed by #2063

Comments

@jan-molak
Copy link
Member

jan-molak commented Jan 26, 2022

Describe the bug

Cucumber ignores line filter when the feature file is described using an absolute path:

So this works:

cucumber-js ./features/example.feature:3

But this doesn't work and all scenarios from example.feature are executed, not just the one on line 3:

cucumber-js /Users/jan/cucumber-demo/features/example.feature:3

Original issue reported at protractor-cucumber-framework/protractor-cucumber-framework#238

Possibly related:

To Reproduce

Please have a look at the repository where I'm demonstrating the issue.

I think the issue comes down to this:

  • given featurePaths are absolute, so [ '/Users/jan/cucumber-demo/features/example.feature:3' ]
  • they're provided to PickleLineFilter, which creates featureUriToLinesMapping as follows:
{
  "/Users/jan/cucumber-demo/features/example.feature": [
    3
  ]
}
const uri = path.normalize(pickle.uri)                  // relative path
const linesToMatch = this.featureUriToLinesMapping[uri] // a map of absolute paths -> line numbers
  • and all scenarios from a given feature file are included

Proposed solution

I think that since PickleLineFilter has access to cwd (which it seems to be ignoring at the moment) it might be useful to ensure that both the featureUriToLinesMapping and matchesAnyLine rely on absolute paths.

Expected behaviour
Line number filters should work for both relative and absolute paths.

Desktop (please complete the following information):

  • OS: MacOS
  • Version: Checked on Cucumber 5, 6 and 7
@mpkorstanje
Copy link
Contributor

Mmh. I would expect Cucumber to identify pickles by the the argument provided and not turn absolute urls into relative ones.

Is there a reason feature paths in the current working would have to be made relative?

@jan-molak
Copy link
Member Author

jan-molak commented Jan 27, 2022

It's hard to tell, perhaps because Cucumber prefers pickle.uri to be relative? I'm just guessing here, though. Maybe @davidjgoss?

@davidjgoss
Copy link
Contributor

Yeah the URIs on the Gherkin messages are relative to cwd since #1672. This happens whether or not you pass a relative or absolute URL in your initial args - the process of resolving the glob args always yeilds an array of absolute paths anyway.

I think providing absolute paths is an under-tested use case for us to date. I'm not sure how best to address this offhand but will take a look. And yeah I expect #1783 is at least somewhat related.

jan-molak added a commit to serenity-js/serenity-js that referenced this issue Feb 3, 2022
… number they're on

Serenity/JS now ensures that any paths to feature files given to Cucumber are relative from
Cucumber's current working directory. This helps to work around cucumber/cucumber-js#1900

Re protractor-cucumber-framework/protractor-cucumber-framework#238
@davidjgoss
Copy link
Contributor

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

Successfully merging a pull request may close this issue.

3 participants