shell: no need to promise scoping

This commit is contained in:
Girish Ramakrishnan
2024-02-21 19:40:27 +01:00
parent cfd5c0f82b
commit a6f078330f
20 changed files with 105 additions and 107 deletions
+8 -8
View File
@@ -13,16 +13,16 @@ const BoxError = require('../boxerror.js'),
describe('shell', function () {
describe('execArgs', function () {
it('can run valid program', async function () {
await shell.promises.execArgs('test', 'ls', [ '-l' ], {});
await shell.execArgs('test', 'ls', [ '-l' ], {});
});
it('fails on invalid program', async function () {
const [error] = await safe(shell.promises.execArgs('test', 'randomprogram', [ ], {}));
const [error] = await safe(shell.execArgs('test', 'randomprogram', [ ], {}));
expect(error.reason).to.be(BoxError.SHELL_ERROR);
});
it('fails on failing program', async function () {
const [error] = await safe(shell.promises.execArgs('test', '/usr/bin/false', [ ], {}));
const [error] = await safe(shell.execArgs('test', '/usr/bin/false', [ ], {}));
expect(error.reason).to.be(BoxError.SHELL_ERROR);
});
});
@@ -51,27 +51,27 @@ describe('shell', function () {
describe('exec', function () {
it('exec throws for invalid program', async function () {
const [error] = await safe(shell.promises.exec('test', 'cannotexist', {}));
const [error] = await safe(shell.exec('test', 'cannotexist', {}));
expect(error.reason).to.be(BoxError.SHELL_ERROR);
});
it('exec throws for failed program', async function () {
const [error] = await safe(shell.promises.exec('test', 'false', {}));
const [error] = await safe(shell.exec('test', 'false', {}));
expect(error.reason).to.be(BoxError.SHELL_ERROR);
});
it('exec times out properly', async function () {
const [error] = await safe(shell.promises.exec('sleeping', 'sleep 20', { timeout: 1000 }));
const [error] = await safe(shell.exec('sleeping', 'sleep 20', { timeout: 1000 }));
expect(error.reason).to.be(BoxError.SHELL_ERROR);
});
it('cannot exec a shell program by default', async function () {
const [error] = await safe(shell.promises.exec('test', 'ls -l | wc -c', {}));
const [error] = await safe(shell.exec('test', 'ls -l | wc -c', {}));
expect(error.reason).to.be(BoxError.SHELL_ERROR);
});
it('cannot exec a shell program b', async function () {
await shell.promises.exec('test', 'ls -l | wc -c', { shell: '/bin/bash' });
await shell.exec('test', 'ls -l | wc -c', { shell: '/bin/bash' });
});
});
});