| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -679,9 +679,6 @@ bool Agent::Start(const std::string& path, | |||
| 679 | 679 | const DebugOptions& options, | |
| 680 | 680 | std::shared_ptr<ExclusiveAccess<HostPort>> host_port, | |
| 681 | 681 | bool is_main) { | |
| 682 | - if (!options.allow_attaching_debugger) { | ||
| 683 | - return false; | ||
| 684 | - } | ||
| 685 | 682 | path_ = path; | |
| 686 | 683 | debug_options_ = options; | |
| 687 | 684 | CHECK_NOT_NULL(host_port); | |
@@ -725,7 +722,8 @@ bool Agent::Start(const std::string& path, | |||
| 725 | 722 | if (parent_handle_) { | |
| 726 | 723 | wait_for_connect = parent_handle_->WaitForConnect(); | |
| 727 | 724 | parent_handle_->WorkerStarted(client_->getThreadHandle(), wait_for_connect); | |
| 728 | - } else if (!options.inspector_enabled || !StartIoThread()) { | ||
| 725 | + } else if (!options.inspector_enabled || !options.allow_attaching_debugger || | ||
| 726 | + !StartIoThread()) { | ||
| 729 | 727 | return false; | |
| 730 | 728 | } | |
| 731 | 729 | ||
@@ -920,6 +918,9 @@ void Agent::RequestIoThreadStart() { | |||
| 920 | 918 | // We need to attempt to interrupt V8 flow (in case Node is running | |
| 921 | 919 | // continuous JS code) and to wake up libuv thread (in case Node is waiting | |
| 922 | 920 | // for IO events) | |
| 921 | + if (!options().allow_attaching_debugger) { | ||
| 922 | + return; | ||
| 923 | + } | ||
| 923 | 924 | CHECK(start_io_thread_async_initialized); | |
| 924 | 925 | uv_async_send(&start_io_thread_async); | |
| 925 | 926 | parent_env_->RequestInterrupt([this](Environment*) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,8 @@ import * as common from '../common/index.mjs'; | |||
| 2 | 2 | import * as tmpdir from '../common/tmpdir.js'; | |
| 3 | 3 | import * as fixtures from '../common/fixtures.mjs'; | |
| 4 | 4 | import assert from 'node:assert'; | |
| 5 | + import path from 'node:path'; | ||
| 6 | + import fs from 'node:fs/promises'; | ||
| 5 | 7 | import { NodeInstance } from '../common/inspector-helper.js'; | |
| 6 | 8 | ||
| 7 | 9 | ||
@@ -52,3 +54,31 @@ tmpdir.refresh(); | |||
| 52 | 54 | assert.strictEqual(code, 1); | |
| 53 | 55 | assert.strictEqual(signal, null); | |
| 54 | 56 | } | |
| 57 | + | ||
| 58 | + | ||
| 59 | + // Outputs coverage when event loop is drained, with no async logic. | ||
| 60 | + { | ||
| 61 | + const coverageDirectory = path.join(tmpdir.path, 'coverage'); | ||
| 62 | + async function getCoveredFiles() { | ||
| 63 | + const coverageFiles = await fs.readdir(coverageDirectory); | ||
| 64 | + const files = new Set(); | ||
| 65 | + for (const coverageFile of coverageFiles) { | ||
| 66 | + const coverage = JSON.parse(await fs.readFile(path.join(coverageDirectory, coverageFile))); | ||
| 67 | + for (const { url } of coverage.result) { | ||
| 68 | + if (!url.startsWith('node:')) files.add(url); | ||
| 69 | + } | ||
| 70 | + } | ||
| 71 | + return files; | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + const { stderr, code, signal } = await common | ||
| 75 | + .spawnPromisified(process.execPath, | ||
| 76 | + ['--test', fixtures.path('v8-coverage/basic.js')], | ||
| 77 | + { env: { ...process.env, NODE_V8_COVERAGE: coverageDirectory } }); | ||
| 78 | + | ||
| 79 | + assert.strictEqual(stderr, ''); | ||
| 80 | + assert.strictEqual(code, 0); | ||
| 81 | + assert.strictEqual(signal, null); | ||
| 82 | + const files = await getCoveredFiles(coverageDirectory); | ||
| 83 | + assert.ok(files.has(fixtures.fileURL('v8-coverage/basic.js').href)); | ||
| 84 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments