Skip to content

Commit

Permalink
chore: test improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
AVVS committed Jan 24, 2022
1 parent 88fed9c commit 138ebf0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion __tests__/install.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ describe('test installing the package', () => {

beforeAll(async () => {
await clean();
await execFile('yarn', ['config', 'set', 'cache-folder', '/tmp/yarn-cache']);
await execFile('yarn', ['config', 'set', 'preferred-cache-folder', '/tmp/yarn-cache']);
await execFile('yarn', ['config', 'set', 'prefer-offline', 'true']);
const { stdout } = await execFile('yarn', ['pack', '--filename', kFilename]);
console.info(stdout);
});
Expand Down
14 changes: 9 additions & 5 deletions bin/cmds/test_cmds/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ const pipeline = promisify(_pipeline);
const debug = require('debug')('test');

const execAsync = (cmd, args, opts) => execa(cmd, args, opts);
const echoAndExec = (cmd, args = [], opts = {}) => {
echo(cmd, args.join(' '));
return execAsync(cmd, args, opts);
const echoAndExec = (cmd, args = [], { buffer = false, all = true, ...rest } = {}) => {
echo(cmd, ...args);
const exe = execAsync(cmd, args, { buffer, all, ...rest });
if (!buffer && all) {
exe.all.pipe(process.stdout);
}
return exe;
};

function removeCommonPrefix(from, compareWith) {
Expand Down Expand Up @@ -53,7 +57,7 @@ exports.handler = async (argv) => {
const { compose, composeArgs } = argv;

if (argv.pull) {
if (await echoAndExec(compose, [...composeArgs, 'pull']).exitCode !== 0) {
if ((await echoAndExec(compose, [...composeArgs, 'pull'])).exitCode !== 0) {
echo('failed pull docker containers. Exit 128');
exit(128);
}
Expand All @@ -65,7 +69,7 @@ exports.handler = async (argv) => {
exit(128);
}

const containerData = await echoAndExec(compose, [...composeArgs, 'ps', '-q', 'tester']);
const containerData = await echoAndExec(compose, [...composeArgs, 'ps', '-q', 'tester'], { buffer: true });
if (containerData.exitCode !== 0) {
echo('failed to get container id. Exit 128');
exit(128);
Expand Down

0 comments on commit 138ebf0

Please sign in to comment.