Skip to content

Commit

Permalink
feat(test:downstream): Support folding of output in travis ci
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherthielen committed Jan 9, 2019
1 parent df92ad7 commit 66bd430
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions test_downstream_projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const fs = require('fs');
const path = require('path');
const tmp = require('tmp');
const shelljs = require('shelljs');
const IS_TRAVIS = !!process.env.TRAVIS;

const yargs = require('yargs')
.option('workspace', {
Expand All @@ -12,6 +13,12 @@ const yargs = require('yargs')

const nodeCleanup = require('node-cleanup');
const publishYalcPackage = require('./publish_yalc_package');
const foldStart = (message) => {
IS_TRAVIS && console.log('travis_fold:start:' + message);
console.log(message);
return () => IS_TRAVIS && console.log('travis_fold:end:' + message);
};
let foldEnd = () => null;

const util = require('./util');
util.packageDir();
Expand Down Expand Up @@ -164,6 +171,8 @@ function runDownstreamTests(key, upstreamPackages, downstreamTreeNode, successLo

const name = downstreamTreeNode.installDir;

foldEnd = foldStart(` ===> Running downstream tests: '${name}' <===`)

console.log(` ===> '${name}': prepping tests <===`);
process.chdir(downstreamTreeNode.installDir);

Expand All @@ -183,13 +192,16 @@ function runDownstreamTests(key, upstreamPackages, downstreamTreeNode, successLo
console.log(` ===> '${name}': Reverting working copy <===`);
revertLocalChanges(downstreamTreeNode.installSource);

foldEnd();

const downstreamChildren = Object.keys(downstreamTreeNode.children || {});
if (downstreamChildren.length) {
const thisPkg = JSON.parse(fs.readFileSync('package.json')).name;
const upstreams = upstreamPackages.concat(thisPkg);

foldEnd = foldStart(` ===> Local Yalc Publish: ${process.cwd()} <===`);
localPublish(process.cwd());
foldEnd();

downstreamChildren.forEach(child => {
runDownstreamTests(child, upstreams, downstreamTreeNode.children[child], successLog);
Expand All @@ -200,17 +212,20 @@ function runDownstreamTests(key, upstreamPackages, downstreamTreeNode, successLo
console.log(` ===> Creating .downstream_cache working directory <===`);
makeDownstreamCache();

console.log(` ===> Publishing ${pkgjson.name} to yalc registry <===`);
foldEnd = foldStart(` ===> Publishing ${pkgjson.name} to yalc registry <===`);
localPublish();
foldEnd();

console.log(` ===> Fetching downstream projects <===`);
foldEnd = foldStart(` ===> Fetching downstream projects <===`);
const tree = { children: {} };
fetchDownstreamProjects(projects, "", tree.children);
foldEnd();

if (yargs.argv.workspace) {
console.log(` ===> Installing downstream dependencies <===`);
foldEnd = foldStart(` ===> Installing downstream dependencies <===`);
const downstreamDirs = getDownstreamInstallDirs(tree);
installWorkspaceDependencies(downstreamDirs);
foldEnd();
}

console.log(` ===> Moving working directory to temp dir ${TEMP_DIR} <===`);
Expand Down

0 comments on commit 66bd430

Please sign in to comment.