diff options
| author | Adam Mathes <adam@adammathes.com> | 2026-02-13 21:34:48 -0800 |
|---|---|---|
| committer | Adam Mathes <adam@adammathes.com> | 2026-02-13 21:34:48 -0800 |
| commit | 76cb9c2a39d477a64824a985ade40507e3bbade1 (patch) | |
| tree | 41e997aa9c6f538d3a136af61dae9424db2005a9 /vanilla/node_modules/vitest/dist/chunks/inspector.CvyFGlXm.js | |
| parent | 819a39a21ac992b1393244a4c283bbb125208c69 (diff) | |
| download | neko-76cb9c2a39d477a64824a985ade40507e3bbade1.tar.gz neko-76cb9c2a39d477a64824a985ade40507e3bbade1.tar.bz2 neko-76cb9c2a39d477a64824a985ade40507e3bbade1.zip | |
feat(vanilla): add testing infrastructure and tests (NK-wjnczv)
Diffstat (limited to 'vanilla/node_modules/vitest/dist/chunks/inspector.CvyFGlXm.js')
| -rw-r--r-- | vanilla/node_modules/vitest/dist/chunks/inspector.CvyFGlXm.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/vanilla/node_modules/vitest/dist/chunks/inspector.CvyFGlXm.js b/vanilla/node_modules/vitest/dist/chunks/inspector.CvyFGlXm.js new file mode 100644 index 0000000..99fb843 --- /dev/null +++ b/vanilla/node_modules/vitest/dist/chunks/inspector.CvyFGlXm.js @@ -0,0 +1,53 @@ +import { createRequire } from 'node:module'; +import { pathToFileURL } from 'node:url'; + +const __require = createRequire(import.meta.url); +let inspector; +let session; +/** +* Enables debugging inside `worker_threads` and `child_process`. +* Should be called as early as possible when worker/process has been set up. +*/ +function setupInspect(ctx) { + const config = ctx.config; + const isEnabled = config.inspector.enabled; + if (isEnabled) { + inspector = __require("node:inspector"); + if (!(inspector.url() !== void 0)) { + inspector.open(config.inspector.port, config.inspector.host, config.inspector.waitForDebugger); + if (config.inspectBrk) { + const firstTestFile = typeof ctx.files[0] === "string" ? ctx.files[0] : ctx.files[0].filepath; + // Stop at first test file + if (firstTestFile) { + session = new inspector.Session(); + session.connect(); + session.post("Debugger.enable"); + session.post("Debugger.setBreakpointByUrl", { + lineNumber: 0, + url: pathToFileURL(firstTestFile) + }); + } + } + } + } + const keepOpen = shouldKeepOpen(config); + return function cleanup() { + if (isEnabled && !keepOpen && inspector) { + inspector.close(); + session?.disconnect(); + } + }; +} +function closeInspector(config) { + const keepOpen = shouldKeepOpen(config); + if (inspector && !keepOpen) { + inspector.close(); + session?.disconnect(); + } +} +function shouldKeepOpen(config) { + // In watch mode the inspector can persist re-runs if isolation is disabled and a single worker is used + return config.watch && config.isolate === false && config.maxWorkers === 1; +} + +export { closeInspector as c, setupInspect as s }; |
