Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: use the common/fixtures module to load the fixtures #16823

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions test/pummel/test-hash-seed.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
'use strict';

// Check that spawn child don't create duplicated entries
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't --> doesn't

require('common');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not seem to work without relative paths, can you change it to require('../common')?

const REPETITIONS = 2;

const assert = require('assert');
const common = require('../common');
const cp = require('child_process');
const path = require('path');
const targetScript = path.resolve(common.fixturesDir, 'guess-hash-seed.js');
const fixtures = require('common/fixtures');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change this to const fixtures = require('../common/fixtures')?

const { spawnSync } = require('child_process');
const targetScript = fixtures.path('guess-hash-seed.js');
const seeds = [];

for (let i = 0; i < REPETITIONS; ++i) {
const seed = cp.spawnSync(process.execPath, [targetScript],
{ encoding: 'utf8' }).stdout.trim();
const seed = spawnSync(process.execPath, [targetScript], {
encoding: 'utf8'
}).stdout.trim();
seeds.push(seed);
}

console.log(`Seeds: ${seeds}`);
const hasDuplicates = (new Set(seeds)).size !== seeds.length;
const hasDuplicates = new Set(seeds).size !== seeds.length;
assert.strictEqual(hasDuplicates, false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could just be changed to assert.strictEqual(new Set(seeds).size, seeds.length); and drop the hasDuplicates