@@ -197,6 +197,7 @@ function installWorkspaceDependencies(downstreamInstallDirs) {
197
197
util . _exec ( 'yarn' ) ;
198
198
}
199
199
200
+ let runningTestsFor ;
200
201
function runDownstreamTests ( key , upstreamPackages , downstreamTreeNode , successLog ) {
201
202
if ( DOWNSTREAM_PKGS . length && DOWNSTREAM_PKGS . indexOf ( key ) === - 1 ) {
202
203
console . log ( ` ===> ${ key } not in DOWNSTREAM_PKGS, skipping... <===` ) ;
@@ -208,6 +209,7 @@ function runDownstreamTests(key, upstreamPackages, downstreamTreeNode, successLo
208
209
const name = downstreamTreeNode . installDir ;
209
210
210
211
foldEnd = foldStart ( `Running downstream tests: '${ name } '` )
212
+ runningTestsFor = name ;
211
213
212
214
console . log ( ` ===> '${ name } ': prepping tests <===` ) ;
213
215
process . chdir ( downstreamTreeNode . installDir ) ;
@@ -224,6 +226,7 @@ function runDownstreamTests(key, upstreamPackages, downstreamTreeNode, successLo
224
226
runTests ( ) ;
225
227
226
228
successLog . push ( key ) ;
229
+ runningTestsFor = undefined ;
227
230
228
231
console . log ( ` ===> '${ name } ': Reverting working copy <===` ) ;
229
232
revertLocalChanges ( downstreamTreeNode . installSource ) ;
@@ -267,13 +270,31 @@ if (yargs.argv.workspace) {
267
270
console . log ( ` ===> Moving working directory to temp dir ${ TEMP_DIR } <===` ) ;
268
271
shelljs . mv ( DOWNSTREAM_CACHE , TEMP_DIR ) ;
269
272
273
+ function getAllProjectKeys ( tree , keyPrefix ) {
274
+ const children = Object . keys ( tree . children || { } ) ;
275
+ const grandChildren = children . map ( child => getAllProjectKeys ( tree . children [ child ] , child ) ) ;
276
+ return children . concat ( ...grandChildren ) . map ( key => keyPrefix ? `${ keyPrefix } .${ key } ` : key ) ;
277
+ }
278
+
270
279
const successLog = [ ] ;
280
+ const allProjectKeys = getAllProjectKeys ( tree ) ;
271
281
nodeCleanup ( ( ) => {
272
282
shelljs . mv ( TEMP_DOWNSTREAM_CACHE , PKG_DIR ) ;
273
283
console . log ( ` ===> Successfully ran downstream tests for: ${ successLog . join ( ', ' ) } <===` ) ;
284
+ if ( runningTestsFor ) {
285
+ console . log ( ` ===> Failed to run downstream tests for: ${ runningTestsFor } <===` ) ;
286
+ }
287
+ const skipped = _ . difference ( allProjectKeys , successLog . concat ( runningTestsFor ) ) ;
288
+ if ( skipped . length ) {
289
+ console . log ( ` ===> Did not try to run downstream tests for: ${ skipped . join ( ', ' ) } <===` ) ;
290
+ }
291
+ } ) ;
292
+
293
+ console . log ( ` ===> Running the following downstream tests <===` ) ;
294
+ allProjectKeys . forEach ( key => {
295
+ console . log ( ` ===> ${ _ . padEnd ( key , 38 ) } <===` ) ;
274
296
} ) ;
275
297
276
- console . log ( ` ===> Running downstream tests <===` ) ;
277
298
Object . keys ( tree . children ) . forEach ( key => {
278
299
runDownstreamTests ( key , [ pkgjson . name ] , tree . children [ key ] , successLog ) ;
279
300
} ) ;
0 commit comments