• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3// Check that spawn child doesn't create duplicated entries
4const common = require('../common');
5
6if (common.isPi) {
7  common.skip('Too slow for Raspberry Pi devices');
8}
9
10const kRepetitions = 2;
11const assert = require('assert');
12const fixtures = require('../common/fixtures');
13const { promisify, debuglog } = require('util');
14const debug = debuglog('test');
15
16const { execFile } = require('child_process');
17const execFilePromise = promisify(execFile);
18const targetScript = fixtures.path('guess-hash-seed.js');
19
20const requiredCallback = common.mustCall((results) => {
21  const seeds = results.map((val) => val.stdout.trim());
22  debug(`Seeds: ${seeds}`);
23  assert.strictEqual(new Set(seeds).size, seeds.length);
24  assert.strictEqual(seeds.length, kRepetitions);
25});
26
27const generateSeed = () => execFilePromise(process.execPath, [targetScript]);
28const subprocesses = [...new Array(kRepetitions)].map(generateSeed);
29
30Promise.all(subprocesses)
31  .then(requiredCallback);
32