forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest-hash-seed.js
More file actions
32 lines (26 loc) · 1.2 KB
/
test-hash-seed.js
File metadata and controls
32 lines (26 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'use strict';
// Check that spawn child doesn't create duplicated entries
const common = require('../common');
const kRepetitions = 2;
const assert = require('assert');
const fixtures = require('../common/fixtures');
const { promisify, debuglog } = require('util');
const debug = debuglog('test');
const { execFile } = require('child_process');
const execFilePromise = promisify(execFile);
const targetScript = fixtures.path('guess-hash-seed.js');
const requiredCallback = common.mustCall((results) => {
const seeds = results.map((val) => val.stdout.trim());
debug(`Seeds: ${seeds}`);
assert.strictEqual(new Set(seeds).size, seeds.length);
assert.strictEqual(seeds.length, kRepetitions);
});
const generateSeed = () => execFilePromise(process.execPath, [targetScript]);
const subprocesses = [...new Array(kRepetitions)].map(generateSeed);
Promise.all(subprocesses)
.then(requiredCallback);
// This test can take a long time to run. Some of our CI hosts are configured
// to consider the task stalled if there is no output for 3 minutes. TO
// prevent that from canceling this test and the entire test suite, output
// something every 60 seconds or so.
setInterval(() => { console.log('.'); }, 60000).unref();