This repository was archived by the owner on Jul 29, 2024. It is now read-only.
File tree 2 files changed +23
-5
lines changed
2 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -98,17 +98,23 @@ ConfigParser.resolveFilePatterns =
98
98
for ( var i = 0 ; i < patterns . length ; ++ i ) {
99
99
// Cucumber allows running a spec given a line number. See
100
100
// https://github.com/angular/protractor/issues/2413
101
- var fileName = patterns [ i ] . split ( ':' ) [ 0 ] ,
102
- lineNumber = patterns [ i ] . split ( ':' ) [ 1 ] ,
103
- matches = glob . sync ( fileName , { cwd : cwd } ) ;
101
+ var lineNumber = '' ;
102
+ var parsedPath = path . parse ( patterns [ i ] ) ;
103
+ parsedPath . base = parsedPath . base . replace ( / : \d + / , function ( match ) {
104
+ lineNumber = match ;
105
+ return '' ;
106
+ } ) ;
107
+
108
+ var filePath = path . format ( parsedPath ) ;
109
+ var matches = glob . sync ( filePath , { cwd : cwd } ) ;
104
110
105
111
if ( ! matches . length && ! opt_omitWarnings ) {
106
112
log . warn ( 'pattern ' + patterns [ i ] + ' did not match any files.' ) ;
107
113
}
108
114
for ( var j = 0 ; j < matches . length ; ++ j ) {
109
115
var resolvedPath = path . resolve ( cwd , matches [ j ] ) ;
110
- if ( lineNumber ) {
111
- resolvedPath += ':' + lineNumber ;
116
+ if ( lineNumber ) {
117
+ resolvedPath += lineNumber ;
112
118
}
113
119
resolvedFiles . push ( resolvedPath ) ;
114
120
}
Original file line number Diff line number Diff line change @@ -62,5 +62,17 @@ describe('the config parser', function() {
62
62
expect ( specs [ 0 ] . indexOf ( path . normalize ( 'unit/data/fakespecA.js' ) ) ) . not . toEqual ( - 1 ) ;
63
63
expect ( specs [ 1 ] . indexOf ( path . normalize ( 'unit/data/fakespecB.js' ) ) ) . not . toEqual ( - 1 ) ;
64
64
} ) ;
65
+
66
+ it ( 'should allow for line numbers in file paths' , function ( ) {
67
+ spyOn ( process , 'cwd' ) . and . returnValue ( __dirname + '/' ) ;
68
+ var toAdd = {
69
+ specs : [ 'data/fakespecA.js:32' , 'data/fakespecB.js' ]
70
+ } ;
71
+ var config = new ConfigParser ( ) . addConfig ( toAdd ) . getConfig ( ) ;
72
+ var specs = ConfigParser . resolveFilePatterns ( config . specs ) ;
73
+ expect ( specs . length ) . toEqual ( 2 ) ;
74
+ expect ( specs [ 0 ] . indexOf ( path . normalize ( 'unit/data/fakespecA.js:32' ) ) ) . not . toEqual ( - 1 ) ;
75
+ expect ( specs [ 1 ] ) . toMatch ( / u n i t \/ d a t a \/ f a k e s p e c B .j s $ / ) ;
76
+ } ) ;
65
77
} ) ;
66
78
} ) ;
You can’t perform that action at this time.
0 commit comments