Skip to content

PickleLineFilter doesn't work with absolute paths #1900

@jan-molak

Description

@jan-molak

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions