shell: add option for maxLines
This commit is contained in:
@@ -27,6 +27,24 @@ describe('shell', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('maxLines', function () {
|
||||
it('maxLines=0 means unlimited', async function () {
|
||||
await shell.bash('for i in {1..10}; do echo $i; sleep 1; done', { encoding: 'utf8', maxLines: 0});
|
||||
});
|
||||
|
||||
it('maxLines=2 kills the process (stdout)', async function () {
|
||||
const [error] = await safe(shell.bash('for i in {1..10}; do echo $i; sleep 1; done', { encoding: 'utf8', maxLines: 2}));
|
||||
expect(error).to.be.ok();
|
||||
expect(error.stdoutLineCount).to.be(2);
|
||||
});
|
||||
|
||||
it('maxLines=2 kills the process (stderr)', async function () {
|
||||
const [error] = await safe(shell.bash('for i in {1..10}; do echo $i >&2; sleep 1; done', { encoding: 'utf8', maxLines: 2}));
|
||||
expect(error).to.be.ok();
|
||||
expect(error.stderrLineCount).to.be(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('sudo', function () {
|
||||
it('cannot sudo invalid program', function (done) {
|
||||
shell.sudo([ 'randomprogram' ], {}, function (error) {
|
||||
|
||||
Reference in New Issue
Block a user