Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit 67474e0

Browse files
darrinholstcnishina
authored andcommitted
chore(configParser): allow non-glob file pattern (#2754)
Cucumber allows line numbers to be passed in the filename in the form of `features/some.feature:42`. Glob expanding that results in an empty array and nothing being passed to the framework runner. This change checks for glob magic characters and only tries expanding it if found. Otherwise it just passes the filename verbatim. This was previously handled in [#2445] by stripping the line number first, but this is a more generic (non-cucumber) way to do it. Glob needed to be upgraded for this which resulted in a weird [npm 3 bug] (npm/npm#10637). Removing the rimraf package resolved this. It was only used to generate documentation which itself was removed a while ago.
1 parent f1bdca0 commit 67474e0

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/configParser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export class ConfigParser {
117117

118118
if (patterns) {
119119
for (let fileName of patterns) {
120-
let matches = glob.sync(fileName, {cwd});
120+
let matches = glob.hasMagic(fileName) ? glob.sync(fileName, {cwd}) : [fileName];
121121
if (!matches.length && !opt_omitWarnings) {
122122
logger.warn('pattern ' + fileName + ' did not match any files.');
123123
}

spec/unit/configParser_test.js

+10
Original file line numberDiff line numberDiff line change
@@ -129,5 +129,15 @@ describe('the config parser', function() {
129129
expect(specs[0].indexOf(path.normalize('unit/data/fakespecA.js'))).not.toEqual(-1);
130130
expect(specs[1].indexOf(path.normalize('unit/data/fakespecB.js'))).not.toEqual(-1);
131131
});
132+
133+
it('should not try to expand non-glob patterns', function() {
134+
var toAdd = {
135+
specs: 'data/fakespecA.js:5'
136+
};
137+
var config = new ConfigParser().addConfig(toAdd).getConfig();
138+
var specs = ConfigParser.resolveFilePatterns(config.specs);
139+
expect(specs.length).toEqual(1);
140+
expect(specs[0].indexOf(path.normalize('data/fakespecA.js:5'))).not.toEqual(-1);
141+
});
132142
});
133143
});

0 commit comments

Comments
 (0)