Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jun 10, 2019
1 parent 2ec2a70 commit 4b6f394
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions test.js
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 4b6f394

Please sign in to comment.