@@ -109,10 +109,12 @@ 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|js)' ) . toLowerCase ( ) ;
113
+ if ( lang === 'all' ) { lang = '(ts|js|dart)' ; }
112
114
var startTime = new Date ( ) . getTime ( ) ;
113
115
// create an output file with header.
114
116
var outputFile = path . join ( process . cwd ( ) , 'protractor-results.txt' ) ;
115
- var header = "Protractor example results for: " + ( new Date ( ) ) . toLocaleString ( ) + "\n\n" ;
117
+ var header = "Protractor example results for " + lang + " on " + ( new Date ( ) ) . toLocaleString ( ) + "\n\n" ;
116
118
if ( filter ) {
117
119
header += ' Filter: ' + filter . toString ( ) + '\n\n' ;
118
120
}
@@ -128,6 +130,10 @@ function findAndRunE2eTests(filter) {
128
130
fsExtra . copySync ( srcConfig , destConfig ) ;
129
131
// get all of the examples under each dir where a pcFilename is found
130
132
examplePaths = getExamplePaths ( specPath , true ) ;
133
+ // Filter by language
134
+ examplePaths = examplePaths . filter ( function ( fn ) {
135
+ return fn . match ( '/' + lang + '$' ) != null ;
136
+ } ) ;
131
137
if ( filter ) {
132
138
examplePaths = examplePaths . filter ( function ( fn ) {
133
139
return fn . match ( filter ) != null ;
@@ -142,7 +148,9 @@ function findAndRunE2eTests(filter) {
142
148
var status = { passed : [ ] , failed : [ ] } ;
143
149
return exeConfigs . reduce ( function ( promise , combo ) {
144
150
return promise . then ( function ( ) {
145
- return runE2eTests ( combo . examplePath , combo . protractorConfigFilename , outputFile ) . then ( function ( ok ) {
151
+ var isDart = combo . examplePath . indexOf ( '/dart' ) > - 1 ;
152
+ var runTests = isDart ? runE2eDartTests : runE2eTsTests ;
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
} )
@@ -158,12 +166,16 @@ function findAndRunE2eTests(filter) {
158
166
// start the example in appDir; then run protractor with the specified
159
167
// fileName; then shut down the example. All protractor output is appended
160
168
// to the outputFile.
161
- function runE2eTests ( appDir , protractorConfigFilename , outputFile ) {
169
+ function runE2eTsTests ( appDir , protractorConfigFilename , outputFile ) {
162
170
// start the app
163
171
var appRunSpawnInfo = spawnExt ( 'npm' , [ 'run' , 'http-server:e2e' , '--' , '-s' ] , { cwd : appDir } ) ;
164
172
var tscRunSpawnInfo = spawnExt ( 'npm' , [ 'run' , 'tsc' ] , { cwd : appDir } ) ;
165
173
166
- return tscRunSpawnInfo . promise . then ( function ( data ) {
174
+ return runProtractor ( tscRunSpawnInfo . promise , appDir , appRunSpawnInfo , protractorConfigFilename , outputFile ) ;
175
+ }
176
+
177
+ function runProtractor ( prepPromise , appDir , appRunSpawnInfo , protractorConfigFilename , outputFile ) {
178
+ return prepPromise . then ( function ( data ) {
167
179
// start protractor
168
180
var pcFilename = path . resolve ( protractorConfigFilename ) ; // need to resolve because we are going to be running from a different dir
169
181
var exePath = path . join ( process . cwd ( ) , "./node_modules/.bin/" ) ;
@@ -184,19 +196,39 @@ function runE2eTests(appDir, protractorConfigFilename, outputFile ) {
184
196
} ) ;
185
197
}
186
198
199
+ // start the server in appDir/build/web; then run protractor with the specified
200
+ // fileName; then shut down the example. All protractor output is appended
201
+ // to the outputFile.
202
+ function runE2eDartTests ( appDir , protractorConfigFilename , outputFile ) {
203
+ var deployDir = path . resolve ( path . join ( appDir , 'build/web' ) ) ;
204
+ gutil . log ( 'AppDir for Dart e2e: ' + appDir ) ;
205
+ gutil . log ( 'Deploying from: ' + deployDir ) ;
206
+
207
+ var appRunSpawnInfo = spawnExt ( 'npm' , [ 'run' , 'http-server:e2e' , '--' , deployDir , '-s' ] , { cwd : EXAMPLES_PATH } ) ;
208
+ if ( ! appRunSpawnInfo . proc . pid ) {
209
+ gutil . log ( 'http-server failed to launch over ' + deployDir ) ;
210
+ return false ;
211
+ }
212
+ var pubUpgradeSpawnInfo = spawnExt ( 'pub' , [ 'upgrade' ] , { cwd : appDir } ) ;
213
+ var prepPromise = pubUpgradeSpawnInfo . promise . then ( function ( data ) {
214
+ return spawnExt ( 'pub' , [ 'build' ] , { cwd : appDir } ) . promise ;
215
+ } ) ;
216
+ return runProtractor ( prepPromise , appDir , appRunSpawnInfo , protractorConfigFilename , outputFile ) ;
217
+ }
218
+
187
219
function reportStatus ( status ) {
188
220
gutil . log ( 'Suites passed:' ) ;
189
221
status . passed . forEach ( function ( val ) {
190
222
gutil . log ( ' ' + val ) ;
191
223
} ) ;
192
224
193
- gutil . log ( 'Suites failed:' ) ;
194
- status . failed . forEach ( function ( val ) {
195
- gutil . log ( ' ' + val ) ;
196
- } ) ;
197
-
198
225
if ( status . failed . length == 0 ) {
199
226
gutil . log ( 'All tests passed' ) ;
227
+ } else {
228
+ gutil . log ( 'Suites failed:' ) ;
229
+ status . failed . forEach ( function ( val ) {
230
+ gutil . log ( ' ' + val ) ;
231
+ } ) ;
200
232
}
201
233
gutil . log ( 'Elapsed time: ' + status . elapsedTime + ' seconds' ) ;
202
234
}
0 commit comments