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 common.fixtures module in test-preload.js #15975

Closed
Closed
Changes from all commits
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
22 changes: 10 additions & 12 deletions test/parallel/test-preload.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict';

const common = require('../common');
const fixtures = require('../common/fixtures');
// Refs: https://github.com/nodejs/node/pull/2253
if (common.isSunOS)
common.skip('unreliable on SunOS');

const assert = require('assert');
const path = require('path');
const childProcess = require('child_process');

const nodeBinary = process.argv[0];
Expand All @@ -19,13 +19,11 @@ const preloadOption = (preloads) => {
return option;
};

const fixture = (name) => path.join(common.fixturesDir, name);

const fixtureA = fixture('printA.js');
const fixtureB = fixture('printB.js');
const fixtureC = fixture('printC.js');
const fixtureD = fixture('define-global.js');
const fixtureThrows = fixture('throws_error4.js');
const fixtureA = fixtures.path('printA.js');
const fixtureB = fixtures.path('printB.js');
const fixtureC = fixtures.path('printC.js');
const fixtureD = fixtures.path('define-global.js');
const fixtureThrows = fixtures.path('throws_error4.js');

// test preloading a single module works
childProcess.exec(`"${nodeBinary}" ${preloadOption([fixtureA])} "${fixtureB}"`,
Expand Down Expand Up @@ -124,19 +122,19 @@ interactive.stdin.write('a\n');
interactive.stdin.write('process.exit()\n');

childProcess.exec(
`"${nodeBinary}" --require "${fixture('cluster-preload.js')}" "${
fixture('cluster-preload-test.js')}"`,
`"${nodeBinary}" --require "${fixtures.path('cluster-preload.js')}" "${
fixtures.path('cluster-preload-test.js')}"`,
function(err, stdout, stderr) {
assert.ifError(err);
assert.ok(/worker terminated with code 43/.test(stdout));
}
);

// https://github.com/nodejs/node/issues/1691
process.chdir(common.fixturesDir);
process.chdir(fixtures.fixturesDir);
childProcess.exec(
`"${nodeBinary}" --expose_natives_as=v8natives --require ` +
`"${fixture('cluster-preload.js')}" cluster-preload-test.js`,
`"${fixtures.path('cluster-preload.js')}" cluster-preload-test.js`,
function(err, stdout, stderr) {
assert.ifError(err);
assert.ok(/worker terminated with code 43/.test(stdout));
Expand Down