@@ -109,10 +109,11 @@ gulp.task('run-e2e-tests', function() {
109
109
// with the corresponding apps that they should run under. Then run
110
110
// each app/spec collection sequentially.
111
111
function findAndRunE2eTests ( filter ) {
112
+ var lang = argv . lang || 'ts' ;
112
113
var startTime = new Date ( ) . getTime ( ) ;
113
114
// create an output file with header.
114
115
var outputFile = path . join ( process . cwd ( ) , 'protractor-results.txt' ) ;
115
- var header = "Protractor example results for: " + ( new Date ( ) ) . toLocaleString ( ) + "\n\n" ;
116
+ var header = "Protractor example results for " + lang + " on " + ( new Date ( ) ) . toLocaleString ( ) + "\n\n" ;
116
117
if ( filter ) {
117
118
header += ' Filter: ' + filter . toString ( ) + '\n\n' ;
118
119
}
@@ -128,8 +129,14 @@ function findAndRunE2eTests(filter) {
128
129
fsExtra . copySync ( srcConfig , destConfig ) ;
129
130
// get all of the examples under each dir where a pcFilename is found
130
131
examplePaths = getExamplePaths ( specPath , true ) ;
132
+ // Filter by language
133
+ examplePaths = examplePaths . filter ( function ( fn ) {
134
+ gutil . log ( 'example path: ' + fn + '; matches lang? ' + ( fn . match ( '/' + lang + '$' ) != null ) ) ;
135
+ return fn . match ( '/' + lang + '$' ) != null ;
136
+ } ) ;
131
137
if ( filter ) {
132
138
examplePaths = examplePaths . filter ( function ( fn ) {
139
+ gutil . log ( 'example path: ' + fn + '; matches? ' + filter + ' ' + ( fn . match ( filter ) != null ) ) ;
133
140
return fn . match ( filter ) != null ;
134
141
} )
135
142
}
@@ -142,7 +149,8 @@ function findAndRunE2eTests(filter) {
142
149
var status = { passed : [ ] , failed : [ ] } ;
143
150
return exeConfigs . reduce ( function ( promise , combo ) {
144
151
return promise . then ( function ( ) {
145
- return runE2eTests ( combo . examplePath , combo . protractorConfigFilename , outputFile ) . then ( function ( ok ) {
152
+ var runTests = lang == 'dart' ? runE2eTestsForDart : runE2eTests ;
153
+ return runTests ( combo . examplePath , combo . protractorConfigFilename , outputFile ) . then ( function ( ok ) {
146
154
var arr = ok ? status . passed : status . failed ;
147
155
arr . push ( combo . examplePath ) ;
148
156
} )
@@ -184,19 +192,54 @@ function runE2eTests(appDir, protractorConfigFilename, outputFile ) {
184
192
} ) ;
185
193
}
186
194
195
+ function runE2eTestsForDart ( appDir , protractorConfigFilename , outputFile ) {
196
+ var deployDir = path . resolve ( path . join ( appDir , 'build/web' ) ) ;
197
+ gutil . log ( 'AppDir for Dart e2e: ' + appDir ) ;
198
+ gutil . log ( 'Deploying from: ' + deployDir ) ;
199
+
200
+ var appRunSpawnInfo = spawnExt ( 'npm' , [ 'run' , 'http-server:e2e' , deployDir , '-s' ] , { cwd : EXAMPLES_PATH } ) ;
201
+ if ( ! appRunSpawnInfo . proc . pid ) {
202
+ gutil . log ( 'http-server failed to launch over ' + deployDir ) ;
203
+ return false ;
204
+ }
205
+ var pubUpgradeSpawnInfo = spawnExt ( 'pub' , [ 'upgrade' ] , { cwd : appDir } ) ;
206
+
207
+ return pubUpgradeSpawnInfo . promise . then ( function ( data ) {
208
+ return spawnExt ( 'pub' , [ 'build' ] , { cwd : appDir } ) . promise ;
209
+ } ) . then ( function ( data ) {
210
+ // start protractor
211
+ var pcFilename = path . resolve ( protractorConfigFilename ) ; // need to resolve because we are going to be running from a different dir
212
+ var exePath = path . join ( process . cwd ( ) , "./node_modules/.bin/" ) ;
213
+ var spawnInfo = spawnExt ( 'protractor' ,
214
+ [ pcFilename , '--params.appDir=' + appDir , '--params.outputFile=' + outputFile ] , { cwd : exePath } ) ;
215
+ return spawnInfo . promise ;
216
+ } ) . then ( function ( data ) {
217
+ // kill the app now that protractor has completed.
218
+ // Ugh... proc.kill does not work properly on windows with child processes.
219
+ // appRun.proc.kill();
220
+ treeKill ( appRunSpawnInfo . proc . pid ) ;
221
+ return ! data ;
222
+ } ) . fail ( function ( err ) {
223
+ // Ugh... proc.kill does not work properly on windows with child processes.
224
+ // appRun.proc.kill();
225
+ treeKill ( appRunSpawnInfo . proc . pid ) ;
226
+ return false ;
227
+ } ) ;
228
+ }
229
+
187
230
function reportStatus ( status ) {
188
231
gutil . log ( 'Suites passed:' ) ;
189
232
status . passed . forEach ( function ( val ) {
190
233
gutil . log ( ' ' + val ) ;
191
234
} ) ;
192
235
193
- gutil . log ( 'Suites failed:' ) ;
194
- status . failed . forEach ( function ( val ) {
195
- gutil . log ( ' ' + val ) ;
196
- } ) ;
197
-
198
236
if ( status . failed . length == 0 ) {
199
237
gutil . log ( 'All tests passed' ) ;
238
+ } else {
239
+ gutil . log ( 'Suites failed:' ) ;
240
+ status . failed . forEach ( function ( val ) {
241
+ gutil . log ( ' ' + val ) ;
242
+ } ) ;
200
243
}
201
244
gutil . log ( 'Elapsed time: ' + status . elapsedTime + ' seconds' ) ;
202
245
}
@@ -206,12 +249,12 @@ function spawnExt(command, args, options) {
206
249
var deferred = Q . defer ( ) ;
207
250
var descr = command + " " + args . join ( ' ' ) ;
208
251
var proc ;
209
- gutil . log ( 'running: ' + descr ) ;
210
252
try {
211
253
proc = xSpawn . spawn ( command , args , options ) ;
212
254
} catch ( e ) {
213
255
gutil . log ( e ) ;
214
256
deferred . reject ( e ) ;
257
+ gutil . log ( 'failed to run: ' + descr ) ;
215
258
return { proc : null , promise : deferred . promise } ;
216
259
}
217
260
proc . stdout . on ( 'data' , function ( data ) {
@@ -229,6 +272,7 @@ function spawnExt(command, args, options) {
229
272
gutil . log ( data . toString ( ) ) ;
230
273
deferred . reject ( data ) ;
231
274
} ) ;
275
+ gutil . log ( 'running: ' + descr ) ;
232
276
return { proc : proc , promise : deferred . promise } ;
233
277
}
234
278
0 commit comments