mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
f2e3a4ed8e
Reduce the time it takes to run test/pummel/test-hash-seed by switching from spawnSync() to spawn(). On my computer, this reduces the runtime from about 80 seconds to about 40 seconds. This test is not (yet) run regularly on CI, but when it was run recently, it timed out. PR-URL: https://github.com/nodejs/node/pull/25522 Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
32 lines
933 B
JavaScript
32 lines
933 B
JavaScript
'use strict';
|
|
|
|
// Check that spawn child doesn't create duplicated entries
|
|
require('../common');
|
|
const Countdown = require('../common/countdown');
|
|
const REPETITIONS = 2;
|
|
const assert = require('assert');
|
|
const fixtures = require('../common/fixtures');
|
|
const { spawn } = require('child_process');
|
|
const targetScript = fixtures.path('guess-hash-seed.js');
|
|
const seeds = [];
|
|
|
|
const requiredCallback = () => {
|
|
console.log(`Seeds: ${seeds}`);
|
|
assert.strictEqual(new Set(seeds).size, seeds.length);
|
|
assert.strictEqual(seeds.length, REPETITIONS);
|
|
};
|
|
|
|
const countdown = new Countdown(REPETITIONS, requiredCallback);
|
|
|
|
for (let i = 0; i < REPETITIONS; ++i) {
|
|
let result = '';
|
|
const subprocess = spawn(process.execPath, [targetScript]);
|
|
subprocess.stdout.setEncoding('utf8');
|
|
subprocess.stdout.on('data', (data) => { result += data; });
|
|
|
|
subprocess.on('exit', () => {
|
|
seeds.push(result.trim());
|
|
countdown.dec();
|
|
});
|
|
}
|