Skip to content

Commit

Permalink
Fix options.detached test (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky authored and sindresorhus committed May 7, 2019
1 parent d43460d commit 88585d2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
13 changes: 4 additions & 9 deletions fixtures/detach
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
#!/usr/bin/env node
const fs = require('fs');
const execa = require('..');

const fd = fs.openSync(process.argv[2], 'w');
'use strict';

const cp = execa('noop', ['foo'], {
detached: true,
stdio: ['ignore', fd]
});
cp.unref();
const execa = require('..');

const subprocess = execa('node', ['./fixtures/forever'], {detached: true});
console.log(subprocess.pid);
process.exit();
2 changes: 1 addition & 1 deletion fixtures/forever
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node
'use strict';

setTimeout(() => {}, 20000);
setTimeout(() => {}, 1e8);
11 changes: 5 additions & 6 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,13 +581,12 @@ test('do not buffer when streaming', async t => {
});

test('detach child process', async t => {
const file = tempfile('.txt');

await execa('detach', [file]);

await delay(5000);
const {stdout} = await execa('detach');
const pid = Number(stdout);
t.true(Number.isInteger(pid));
t.true(isRunning(pid));

t.is(fs.readFileSync(file, 'utf8'), 'foo\n');
process.kill(pid, 'SIGKILL');
});

// See #128
Expand Down

0 comments on commit 88585d2

Please sign in to comment.