Skip to content

Commit ff52556

Browse files
committed
CR
1 parent 4fd6635 commit ff52556

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

lib/internal/main/test_runner.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ let debug = require('internal/util/debuglog').debuglog('test_runner', (fn) => {
2222
debug = fn;
2323
});
2424

25-
prepareMainThreadExecution(false);
25+
prepareMainThreadExecution(false, true, false);
2626
markBootstrapComplete();
2727

2828
let concurrency = getOptionValue('--test-concurrency') || true;

lib/internal/process/pre_execution.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ const {
5050
},
5151
} = require('internal/v8/startup_snapshot');
5252

53-
function prepareMainThreadExecution(expandArgv1 = false, initializeModules = true) {
53+
function prepareMainThreadExecution(expandArgv1 = false, initializeModules = true, preloadModules = initializeModules) {
5454
return prepareExecution({
5555
expandArgv1,
5656
initializeModules,
57+
preloadModules,
5758
isMainThread: true,
5859
});
5960
}
@@ -62,6 +63,7 @@ function prepareWorkerThreadExecution() {
6263
prepareExecution({
6364
expandArgv1: false,
6465
initializeModules: false, // Will need to initialize it after policy setup
66+
preloadModules: false,
6567
isMainThread: false,
6668
});
6769
}
@@ -95,7 +97,7 @@ function prepareShadowRealmExecution() {
9597
}
9698

9799
function prepareExecution(options) {
98-
const { expandArgv1, initializeModules, isMainThread } = options;
100+
const { expandArgv1, initializeModules, isMainThread, preloadModules } = options;
99101

100102
refreshRuntimeOptions();
101103
reconnectZeroFillToggle();
@@ -157,7 +159,7 @@ function prepareExecution(options) {
157159
}
158160

159161
if (initializeModules) {
160-
setupUserModules();
162+
setupUserModules(false, preloadModules);
161163
}
162164

163165
return mainEntry;
@@ -188,7 +190,7 @@ function setupSymbolDisposePolyfill() {
188190
}
189191
}
190192

191-
function setupUserModules(forceDefaultLoader = false) {
193+
function setupUserModules(forceDefaultLoader = false, preloadModules = true) {
192194
initializeCJSLoader();
193195
initializeESMLoader(forceDefaultLoader);
194196
const {
@@ -203,7 +205,7 @@ function setupUserModules(forceDefaultLoader = false) {
203205
// Do not enable preload modules if custom loaders are disabled.
204206
// For example, loader workers are responsible for doing this themselves.
205207
// And preload modules are not supported in ShadowRealm as well.
206-
if (!forceDefaultLoader) {
208+
if (!forceDefaultLoader && preloadModules) {
207209
loadPreloadModules();
208210
}
209211
// Need to be done after --require setup.
@@ -735,8 +737,7 @@ function runEmbedderPreload() {
735737
function loadPreloadModules() {
736738
// For user code, we preload modules if `-r` is passed
737739
const preloadModules = getOptionValue('--require');
738-
const isOrcastrationProcess = getOptionValue('--test');
739-
if (preloadModules && preloadModules.length > 0 && !isOrcastrationProcess) {
740+
if (preloadModules && preloadModules.length > 0) {
740741
const {
741742
Module: {
742743
_preloadModules,

test/parallel/test-runner-cli.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,8 @@ const testFixtures = fixtures.path('test-runner');
337337

338338
{
339339
// --require should only be applied to individual test processes, not the orchestrator
340-
const args = ['--test', '--require', join(testFixtures, 'print_pid.js'), join(testFixtures, 'index.js')];
340+
const args = ['--test', '--require', join(testFixtures, 'print_pid.js'),
341+
join(testFixtures, 'index.js'), join(testFixtures, 'default-behavior', 'index.test.js')];
341342
const child = spawnSync(process.execPath, args, { cwd: testFixtures });
342343

343344
assert.strictEqual(child.status, 1);
@@ -349,7 +350,8 @@ const testFixtures = fixtures.path('test-runner');
349350

350351
{
351352
// --import should only be applied to individual test processes, not the orchestrator
352-
const args = ['--test', '--require', join(testFixtures, 'print_pid.js'), join(testFixtures, 'index.js')];
353+
const args = ['--test', '--import', fixtures.fileURL('test-runner/print_pid.js'),
354+
join(testFixtures, 'index.js'), join(testFixtures, 'default-behavior', 'index.test.js')];
353355
const child = spawnSync(process.execPath, args, { cwd: testFixtures });
354356

355357
assert.strictEqual(child.status, 1);

0 commit comments

Comments
 (0)