Skip to content

Commit

Permalink
test: use common.fixtures module in test-preload
Browse files Browse the repository at this point in the history
PR-URL: #15975
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
lzcabrera authored and MylesBorins committed Oct 11, 2017
1 parent 530b62f commit 75ab6c0
Showing 1 changed file with 10 additions and 12 deletions.
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

0 comments on commit 75ab6c0

Please sign in to comment.