0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-child-process-spawnsync-timeout.js
Rich Trott b6d2fc9b0f test: allow for slow hosts in spawnSync() test
test-child-process-spawnsync-timeout failed from time to time on
Raspberry Pi devices. Use common.platformTimeout() to allow a little
more time to run on resource-constrained hosts.

PR-URL: https://github.com/nodejs/node/pull/10998
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2017-01-27 12:03:06 -08:00

27 lines
682 B
JavaScript

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