diff --git a/lib/internal/main/test_runner.js b/lib/internal/main/test_runner.js index cc853da7388821..b1f69b07771ac6 100644 --- a/lib/internal/main/test_runner.js +++ b/lib/internal/main/test_runner.js @@ -21,7 +21,7 @@ markBootstrapComplete(); const options = parseCommandLine(); -if (isUsingInspector()) { +if (isUsingInspector() && options.isolation === 'process') { process.emitWarning('Using the inspector with --test forces running at a concurrency of 1. ' + 'Use the inspectPort option to run with concurrency'); options.concurrency = 1; diff --git a/lib/internal/test_runner/runner.js b/lib/internal/test_runner/runner.js index dd167b8af0ad15..446ee8accfdba1 100644 --- a/lib/internal/test_runner/runner.js +++ b/lib/internal/test_runner/runner.js @@ -58,7 +58,11 @@ const { const { getInspectPort, isUsingInspector, isInspectorMessage } = require('internal/util/inspector'); const { isRegExp } = require('internal/util/types'); const { pathToFileURL } = require('internal/url'); -const { getCWDURL, kEmptyObject } = require('internal/util'); +const { + createDeferredPromise, + getCWDURL, + kEmptyObject, +} = require('internal/util'); const { kEmitMessage } = require('internal/test_runner/tests_stream'); const { createTestTree, @@ -654,7 +658,7 @@ function run(options = kEmptyObject) { return subtest; }); }; - } else { + } else if (isolation === 'none') { if (watch) { filesWatcher = watchFiles(testFiles, opts); runFiles = async () => { @@ -666,7 +670,7 @@ function run(options = kEmptyObject) { }; } else { runFiles = async () => { - const { promise, resolve: finishBootstrap } = Promise.withResolvers(); + const { promise, resolve: finishBootstrap } = createDeferredPromise(); await root.runInAsyncScope(async () => { const parentURL = getCWDURL().href; @@ -678,13 +682,14 @@ function run(options = kEmptyObject) { for (let i = 0; i < testFiles.length; ++i) { const testFile = testFiles[i]; const fileURL = pathToFileURL(testFile); + const parent = i === 0 ? undefined : parentURL; let threw = false; let importError; root.entryFile = resolve(testFile); debug('loading test file:', fileURL.href); try { - await cascadedLoader.import(fileURL, parentURL, { __proto__: null }); + await cascadedLoader.import(fileURL, parent, { __proto__: null }); } catch (err) { threw = true; importError = err; diff --git a/src/node_options.cc b/src/node_options.cc index 893407adcdff6c..f88495d0bbbe94 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -143,8 +143,16 @@ void EnvironmentOptions::CheckOptions(std::vector* errors, } if (test_runner) { - if (test_isolation != "process" && test_isolation != "none") { - errors->push_back("invalid value for --experimental-test-isolation"); + if (test_isolation == "none") { + debug_options_.allow_attaching_debugger = true; + } else { + if (test_isolation != "process") { + errors->push_back("invalid value for --experimental-test-isolation"); + } + +#ifndef ALLOW_ATTACHING_DEBUGGER_IN_TEST_RUNNER + debug_options_.allow_attaching_debugger = false; +#endif } if (syntax_check_only) { @@ -163,10 +171,6 @@ void EnvironmentOptions::CheckOptions(std::vector* errors, errors->push_back( "--watch-path cannot be used in combination with --test"); } - -#ifndef ALLOW_ATTACHING_DEBUGGER_IN_TEST_RUNNER - debug_options_.allow_attaching_debugger = false; -#endif } if (watch_mode) {