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

pickle_filter: use absolute paths #962

Merged
merged 3 commits into from
Oct 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/pickle_filter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _ from 'lodash'
import path from 'path'
import { TagExpressionParser } from 'cucumber-tag-expressions'

const FEATURE_LINENUM_REGEXP = /^(.*?)((?::[\d]+)+)?$/
Expand All @@ -20,7 +21,7 @@ export default class PickleFilter {
featurePaths.forEach(featurePath => {
const match = FEATURE_LINENUM_REGEXP.exec(featurePath)
if (match) {
const uri = match[1]
const uri = path.resolve(match[1])
const linesExpression = match[2]
if (linesExpression) {
if (!mapping[uri]) {
Expand All @@ -47,7 +48,7 @@ export default class PickleFilter {
}

matchesAnyLine({ pickle, uri }) {
const lines = this.featureUriToLinesMapping[uri]
const lines = this.featureUriToLinesMapping[path.resolve(uri)]
if (lines) {
return _.size(_.intersection(lines, _.map(pickle.locations, 'line'))) > 0
} else {
Expand Down
28 changes: 26 additions & 2 deletions src/pickle_filter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,32 @@ describe('PickleFilter', function() {
})
})
})

describe('scenario line using current directory path representation', function() {
beforeEach(function() {
this.input.uri = './features/b.feature'
})

describe('scenario line matches', function() {
beforeEach(function() {
this.input.pickle.locations = [{ line: 1 }]
})

it('returns true', function() {
expect(this.pickleFilter.matches(this.input)).to.be.true
})
})

describe('scenario line does not match', function() {
beforeEach(function() {
this.input.pickle.locations = [{ line: 3 }]
})

it('returns false', function() {
expect(this.pickleFilter.matches(this.input)).to.be.false
})
})
})
})

describe('name filters', function() {
Expand Down Expand Up @@ -321,7 +347,6 @@ describe('PickleFilter', function() {
tagExpressions: ['tagA']
})
this.input.pickle.locations = [{ line: 1 }]
this.input.uri = this.scenarioPath
})

it('returns false', function() {
Expand All @@ -337,7 +362,6 @@ describe('PickleFilter', function() {
tagExpression: '@tagA'
})
this.input.pickle.locations = [{ line: 1 }]
this.input.uri = this.scenarioPath
})

it('returns false', function() {
Expand Down