@@ -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,6 +129,10 @@ 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
+ return fn . match ( '/' + lang + '$' ) != null ;
135
+ } ) ;
131
136
if ( filter ) {
132
137
examplePaths = examplePaths . filter ( function ( fn ) {
133
138
return fn . match ( filter ) != null ;
@@ -142,7 +147,8 @@ function findAndRunE2eTests(filter) {
142
147
var status = { passed : [ ] , failed : [ ] } ;
143
148
return exeConfigs . reduce ( function ( promise , combo ) {
144
149
return promise . then ( function ( ) {
145
- return runE2eTests ( combo . examplePath , combo . protractorConfigFilename , outputFile ) . then ( function ( ok ) {
150
+ var runTests = lang == 'dart' ? runE2eDartTests : runE2eTsTests ;
151
+ return runTests ( combo . examplePath , combo . protractorConfigFilename , outputFile ) . then ( function ( ok ) {
146
152
var arr = ok ? status . passed : status . failed ;
147
153
arr . push ( combo . examplePath ) ;
148
154
} )
@@ -158,12 +164,16 @@ function findAndRunE2eTests(filter) {
158
164
// start the example in appDir; then run protractor with the specified
159
165
// fileName; then shut down the example. All protractor output is appended
160
166
// to the outputFile.
161
- function runE2eTests ( appDir , protractorConfigFilename , outputFile ) {
167
+ function runE2eTsTests ( appDir , protractorConfigFilename , outputFile ) {
162
168
// start the app
163
169
var appRunSpawnInfo = spawnExt ( 'npm' , [ 'run' , 'http-server:e2e' , '--' , '-s' ] , { cwd : appDir } ) ;
164
170
var tscRunSpawnInfo = spawnExt ( 'npm' , [ 'run' , 'tsc' ] , { cwd : appDir } ) ;
165
171
166
- return tscRunSpawnInfo . promise . then ( function ( data ) {
172
+ return runProtractor ( tscRunSpawnInfo . promise , appDir , appRunSpawnInfo , protractorConfigFilename , outputFile ) ;
173
+ }
174
+
175
+ function runProtractor ( prepPromise , appDir , appRunSpawnInfo , protractorConfigFilename , outputFile ) {
176
+ return prepPromise . then ( function ( data ) {
167
177
// start protractor
168
178
var pcFilename = path . resolve ( protractorConfigFilename ) ; // need to resolve because we are going to be running from a different dir
169
179
var exePath = path . join ( process . cwd ( ) , "./node_modules/.bin/" ) ;
@@ -184,19 +194,39 @@ function runE2eTests(appDir, protractorConfigFilename, outputFile ) {
184
194
} ) ;
185
195
}
186
196
197
+ // start the server in appDir/build/web; then run protractor with the specified
198
+ // fileName; then shut down the example. All protractor output is appended
199
+ // to the outputFile.
200
+ function runE2eDartTests ( appDir , protractorConfigFilename , outputFile ) {
201
+ var deployDir = path . resolve ( path . join ( appDir , 'build/web' ) ) ;
202
+ gutil . log ( 'AppDir for Dart e2e: ' + appDir ) ;
203
+ gutil . log ( 'Deploying from: ' + deployDir ) ;
204
+
205
+ var appRunSpawnInfo = spawnExt ( 'npm' , [ 'run' , 'http-server:e2e' , '--' , deployDir , '-s' ] , { cwd : EXAMPLES_PATH } ) ;
206
+ if ( ! appRunSpawnInfo . proc . pid ) {
207
+ gutil . log ( 'http-server failed to launch over ' + deployDir ) ;
208
+ return false ;
209
+ }
210
+ var pubUpgradeSpawnInfo = spawnExt ( 'pub' , [ 'upgrade' ] , { cwd : appDir } ) ;
211
+ var prepPromise = pubUpgradeSpawnInfo . promise . then ( function ( data ) {
212
+ return spawnExt ( 'pub' , [ 'build' ] , { cwd : appDir } ) . promise ;
213
+ } ) ;
214
+ return runProtractor ( prepPromise , appDir , appRunSpawnInfo , protractorConfigFilename , outputFile ) ;
215
+ }
216
+
187
217
function reportStatus ( status ) {
188
218
gutil . log ( 'Suites passed:' ) ;
189
219
status . passed . forEach ( function ( val ) {
190
220
gutil . log ( ' ' + val ) ;
191
221
} ) ;
192
222
193
- gutil . log ( 'Suites failed:' ) ;
194
- status . failed . forEach ( function ( val ) {
195
- gutil . log ( ' ' + val ) ;
196
- } ) ;
197
-
198
223
if ( status . failed . length == 0 ) {
199
224
gutil . log ( 'All tests passed' ) ;
225
+ } else {
226
+ gutil . log ( 'Suites failed:' ) ;
227
+ status . failed . forEach ( function ( val ) {
228
+ gutil . log ( ' ' + val ) ;
229
+ } ) ;
200
230
}
201
231
gutil . log ( 'Elapsed time: ' + status . elapsedTime + ' seconds' ) ;
202
232
}
0 commit comments