Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jun 6, 2019
1 parent 447cfac commit 30cb091
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,25 @@ test('use relative path with \'..\' chars', async t => {
});

if (process.platform !== 'win32') {
test('execa() rejects if running non-executable', async t => {
const cp = execa('non-executable');
await t.throwsAsync(cp);
});
// On Node 8, `child_process.spawn()` throws synchronously, but not on Node >=10
// TODO: remove Node 8 test case once we stop supporting Node 8
if (process.version.startsWith('v8')) {
test('execa() throws if running non-executable', t => {
t.throws(() => execa('non-executable'));
});

test('execa() rejects with correct error and doesn\'t throw if running non-executable with input', async t => {
await t.throwsAsync(execa('non-executable', {input: 'Hey!'}), /EACCES/);
});
test('execa() throws with correct error and doesn\'t throw if running non-executable with input', t => {
t.throws(() => execa('non-executable', {input: 'Hey!'}), /EACCES/);
});
} else {
test('execa() rejects if running non-executable', async t => {
await t.throwsAsync(execa('non-executable'));
});

test('execa() rejects with correct error and doesn\'t throw if running non-executable with input', async t => {
await t.throwsAsync(execa('non-executable', {input: 'Hey!'}), /EACCES/);
});
}
}

test('error.killed is true if process was killed directly', async t => {
Expand Down

0 comments on commit 30cb091

Please sign in to comment.