Skip to content

Commit

Permalink
inspector integration
Browse files Browse the repository at this point in the history
  • Loading branch information
cjihrig committed Aug 18, 2024
1 parent 7dfb106 commit 25ef2d7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/internal/main/test_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 9 additions & 4 deletions lib/internal/test_runner/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -654,7 +658,7 @@ function run(options = kEmptyObject) {
return subtest;
});
};
} else {
} else if (isolation === 'none') {
if (watch) {
filesWatcher = watchFiles(testFiles, opts);
runFiles = async () => {
Expand All @@ -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;
Expand All @@ -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;
Expand Down
16 changes: 10 additions & 6 deletions src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,16 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* 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) {
Expand All @@ -163,10 +171,6 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* 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) {
Expand Down

0 comments on commit 25ef2d7

Please sign in to comment.