test: use common.fixtures module in test-preload
PR-URL: https://github.com/nodejs/node/pull/15975 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
parent
91724cb2a1
commit
0d38e6d01f
@ -1,12 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
// Refs: https://github.com/nodejs/node/pull/2253
|
// Refs: https://github.com/nodejs/node/pull/2253
|
||||||
if (common.isSunOS)
|
if (common.isSunOS)
|
||||||
common.skip('unreliable on SunOS');
|
common.skip('unreliable on SunOS');
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const path = require('path');
|
|
||||||
const childProcess = require('child_process');
|
const childProcess = require('child_process');
|
||||||
|
|
||||||
const nodeBinary = process.argv[0];
|
const nodeBinary = process.argv[0];
|
||||||
@ -19,13 +19,11 @@ const preloadOption = (preloads) => {
|
|||||||
return option;
|
return option;
|
||||||
};
|
};
|
||||||
|
|
||||||
const fixture = (name) => path.join(common.fixturesDir, name);
|
const fixtureA = fixtures.path('printA.js');
|
||||||
|
const fixtureB = fixtures.path('printB.js');
|
||||||
const fixtureA = fixture('printA.js');
|
const fixtureC = fixtures.path('printC.js');
|
||||||
const fixtureB = fixture('printB.js');
|
const fixtureD = fixtures.path('define-global.js');
|
||||||
const fixtureC = fixture('printC.js');
|
const fixtureThrows = fixtures.path('throws_error4.js');
|
||||||
const fixtureD = fixture('define-global.js');
|
|
||||||
const fixtureThrows = fixture('throws_error4.js');
|
|
||||||
|
|
||||||
// test preloading a single module works
|
// test preloading a single module works
|
||||||
childProcess.exec(`"${nodeBinary}" ${preloadOption([fixtureA])} "${fixtureB}"`,
|
childProcess.exec(`"${nodeBinary}" ${preloadOption([fixtureA])} "${fixtureB}"`,
|
||||||
@ -124,8 +122,8 @@ interactive.stdin.write('a\n');
|
|||||||
interactive.stdin.write('process.exit()\n');
|
interactive.stdin.write('process.exit()\n');
|
||||||
|
|
||||||
childProcess.exec(
|
childProcess.exec(
|
||||||
`"${nodeBinary}" --require "${fixture('cluster-preload.js')}" "${
|
`"${nodeBinary}" --require "${fixtures.path('cluster-preload.js')}" "${
|
||||||
fixture('cluster-preload-test.js')}"`,
|
fixtures.path('cluster-preload-test.js')}"`,
|
||||||
function(err, stdout, stderr) {
|
function(err, stdout, stderr) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
assert.ok(/worker terminated with code 43/.test(stdout));
|
assert.ok(/worker terminated with code 43/.test(stdout));
|
||||||
@ -133,10 +131,10 @@ childProcess.exec(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// https://github.com/nodejs/node/issues/1691
|
// https://github.com/nodejs/node/issues/1691
|
||||||
process.chdir(common.fixturesDir);
|
process.chdir(fixtures.fixturesDir);
|
||||||
childProcess.exec(
|
childProcess.exec(
|
||||||
`"${nodeBinary}" --expose_natives_as=v8natives --require ` +
|
`"${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) {
|
function(err, stdout, stderr) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
assert.ok(/worker terminated with code 43/.test(stdout));
|
assert.ok(/worker terminated with code 43/.test(stdout));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user