Skip to content
Myr

Improve some tests (#655)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ehmicky · committed by GitHub · parent d78348d · Browse files · 2 files+18 added−27 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+18 added−27 removed

  • tests:+18 added−27 removed

2 files+18 added−27 removed

modified:test/kill.js+15 added-27 removed
29 unmodified lines
30 subprocess.kill('SIGTERM', {forceKillAfterTimeout: false});3132 t.true(isRunning(subprocess.pid));33 subprocess.kill('SIGKILL');34 });3436 test('`forceKillAfterTimeout: number` should kill after a timeout', async t => {37 const subprocess = execa('no-killable.js', {stdio: ['ipc']});38 await pEvent(subprocess, 'message');3940 subprocess.kill('SIGTERM', {forceKillAfterTimeout: 50});4135 const {signal} = await t.throwsAsync(subprocess);36 t.is(signal, 'SIGKILL');37 });3846 test('`forceKillAfterTimeout: true` should kill after a timeout', async t => {39 const testForceKill = async (t, killArguments) => {40 const subprocess = execa('no-killable.js', {stdio: ['ipc']});41 await pEvent(subprocess, 'message');4250 subprocess.kill('SIGTERM', {forceKillAfterTimeout: true});43 subprocess.kill(...killArguments);4445 const {signal} = await t.throwsAsync(subprocess);46 t.is(signal, 'SIGKILL');54 });47 };4856 test('kill() with no arguments should kill after a timeout', async t => {57 const subprocess = execa('no-killable.js', {stdio: ['ipc']});58 await pEvent(subprocess, 'message');49 test('`forceKillAfterTimeout: number` should kill after a timeout', testForceKill, ['SIGTERM', {forceKillAfterTimeout: 50}]);50 test('`forceKillAfterTimeout: true` should kill after a timeout', testForceKill, ['SIGTERM', {forceKillAfterTimeout: true}]);51 test('kill("SIGTERM") should kill after a timeout', testForceKill, ['SIGTERM']);52 test('kill() with no arguments should kill after a timeout', testForceKill, []);5360 subprocess.kill();6162 const {signal} = await t.throwsAsync(subprocess);63 t.is(signal, 'SIGKILL');64 });6566 test('`forceKillAfterTimeout` should not be NaN', t => {54 const testInvalidForceKill = async (t, forceKillAfterTimeout) => {55 const childProcess = execa('noop.js');56 t.throws(() => {68 execa('noop.js').kill('SIGTERM', {forceKillAfterTimeout: Number.NaN});57 childProcess.kill('SIGTERM', {forceKillAfterTimeout});58 }, {instanceOf: TypeError, message: /non-negative integer/});59 const {signal} = await t.throwsAsync(childProcess);60 t.is(signal, 'SIGTERM');70 });61 };6272 test('`forceKillAfterTimeout` should not be negative', t => {73 t.throws(() => {74 execa('noop.js').kill('SIGTERM', {forceKillAfterTimeout: -1});75 }, {instanceOf: TypeError, message: /non-negative integer/});76 });63 test('`forceKillAfterTimeout` should not be NaN', testInvalidForceKill, Number.NaN);64 test('`forceKillAfterTimeout` should not be negative', testInvalidForceKill, -1);65}6667test('execa() returns a promise with kill()', t => {68 const {kill} = execa('noop.js', ['foo']);
234 unmodified lines
modified:test/node.js+3 added