Skip to content

Commit e9847e8

Browse files
feat(test_downstrem_projects): Print out a summary of success/failed/skipped downstream tests at the end
1 parent 89d50e0 commit e9847e8

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

test_downstream_projects.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ function installWorkspaceDependencies(downstreamInstallDirs) {
197197
util._exec('yarn');
198198
}
199199

200+
let runningTestsFor;
200201
function runDownstreamTests(key, upstreamPackages, downstreamTreeNode, successLog) {
201202
if (DOWNSTREAM_PKGS.length && DOWNSTREAM_PKGS.indexOf(key) === -1) {
202203
console.log(` ===> ${key} not in DOWNSTREAM_PKGS, skipping... <===`);
@@ -208,6 +209,7 @@ function runDownstreamTests(key, upstreamPackages, downstreamTreeNode, successLo
208209
const name = downstreamTreeNode.installDir;
209210

210211
foldEnd = foldStart(`Running downstream tests: '${name}'`)
212+
runningTestsFor = name;
211213

212214
console.log(` ===> '${name}': prepping tests <===`);
213215
process.chdir(downstreamTreeNode.installDir);
@@ -224,6 +226,7 @@ function runDownstreamTests(key, upstreamPackages, downstreamTreeNode, successLo
224226
runTests();
225227

226228
successLog.push(key);
229+
runningTestsFor = undefined;
227230

228231
console.log(` ===> '${name}': Reverting working copy <===`);
229232
revertLocalChanges(downstreamTreeNode.installSource);
@@ -267,13 +270,31 @@ if (yargs.argv.workspace) {
267270
console.log(` ===> Moving working directory to temp dir ${TEMP_DIR} <===`);
268271
shelljs.mv(DOWNSTREAM_CACHE, TEMP_DIR);
269272

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+
270279
const successLog = [];
280+
const allProjectKeys = getAllProjectKeys(tree);
271281
nodeCleanup(() => {
272282
shelljs.mv(TEMP_DOWNSTREAM_CACHE, PKG_DIR);
273283
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)} <===`);
274296
});
275297

276-
console.log(` ===> Running downstream tests <===`);
277298
Object.keys(tree.children).forEach(key => {
278299
runDownstreamTests(key, [pkgjson.name], tree.children[key], successLog);
279300
});

0 commit comments

Comments
 (0)