0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-25 08:19:38 +01:00
nodejs/test/parallel/test-child-process-spawnsync-timeout.js
Fedor Indutny ccc91aea35 test: loosen timeout in spawnsync-test for FreeBSD
PR-URL: https://github.com/iojs/io.js/pull/332
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-13 20:36:44 +03:00

26 lines
626 B
JavaScript

var common = require('../common');
var assert = require('assert');
var spawnSync = require('child_process').spawnSync;
var TIMER = 200;
var SLEEP = 5000;
switch (process.argv[2]) {
case 'child':
setTimeout(function() {
console.log('child fired');
process.exit(1);
}, SLEEP);
break;
default:
var start = Date.now();
var ret = spawnSync(process.execPath, [__filename, 'child'], {timeout: TIMER});
assert.strictEqual(ret.error.errno, 'ETIMEDOUT');
console.log(ret);
var end = Date.now() - start;
assert(end < SLEEP);
assert(ret.status > 128 || ret.signal);
break;
}