summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2019-01-15 10:31:12 -0800
committerRich Trott <rtrott@gmail.com>2019-01-17 16:14:45 -0800
commitf2e3a4ed8edf4675e3ec409a8430f6547660960a (patch)
tree866feaad7c1ed692fe12e3e8c46efcb954acaeab /test
parenteed096ea2e953dc143f0e425086a649a9a668f56 (diff)
downloadandroid-node-v8-f2e3a4ed8edf4675e3ec409a8430f6547660960a.tar.gz
android-node-v8-f2e3a4ed8edf4675e3ec409a8430f6547660960a.tar.bz2
android-node-v8-f2e3a4ed8edf4675e3ec409a8430f6547660960a.zip
test: prepare test-hash-seed for CI
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>
Diffstat (limited to 'test')
-rw-r--r--test/pummel/test-hash-seed.js27
1 files changed, 19 insertions, 8 deletions
diff --git a/test/pummel/test-hash-seed.js b/test/pummel/test-hash-seed.js
index fd59bbe5e0..2b7f13593a 100644
--- a/test/pummel/test-hash-seed.js
+++ b/test/pummel/test-hash-seed.js
@@ -2,19 +2,30 @@
// 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 { spawnSync } = require('child_process');
+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) {
- const seed = spawnSync(process.execPath, [targetScript], {
- encoding: 'utf8'
- }).stdout.trim();
- seeds.push(seed);
-}
+ let result = '';
+ const subprocess = spawn(process.execPath, [targetScript]);
+ subprocess.stdout.setEncoding('utf8');
+ subprocess.stdout.on('data', (data) => { result += data; });
-console.log(`Seeds: ${seeds}`);
-assert.strictEqual(new Set(seeds).size, seeds.length);
+ subprocess.on('exit', () => {
+ seeds.push(result.trim());
+ countdown.dec();
+ });
+}