Skip to content

test: migrate adapter tests off process.platform/version mutation (#186)#189

Merged
debugmcpdev merged 1 commit into
mainfrom
test/186-platform-injection
Jul 14, 2026
Merged

test: migrate adapter tests off process.platform/version mutation (#186)#189
debugmcpdev merged 1 commit into
mainfrom
test/186-platform-injection

Conversation

@debugmcpdev

Copy link
Copy Markdown
Collaborator

Summary

Fixes #186 — removes all 68 Object.defineProperty(process, 'platform'|'version') / vi.spyOn(process, 'platform') mutation sites across 8 adapter-package test files by extending the seam pattern #183 (PR #185) established. No production behavior changes: every new parameter defaults to the real process.platform / process.arch / process.version.

Production seams added

Package Seam
shared AdapterPolicy.getAdapterSpawnConfig interface gains optional trailing platform/arch params (mirrors the existing resolveExecutablePath precedent); RustAdapterPolicy implements them. Source-compatible: the 7 other policy implementations and both call sites in dap-proxy-worker.ts need no changes.
adapter-rust RustDebugAdapter constructor-injects platform (mirrors GenericAdapterManager); all 10 method-body reads use this.platform. getRustBinaryPath / findDlltoolExecutable gain trailing platform params.
adapter-python findPythonExecutable gains a trailing platform param, threaded into CommandFinder.find(cmd, platform?); WhichCommandFinder branches on the param (ComSpec fallback, Path→PATH copy, Store-alias filter).
adapter-dotnet listDotnetProcesses, getProcessExecutablePath, getProcessExecutableDir, getProcessArchitecture gain trailing platform params (the latter two thread through).
adapter-ruby getRubySearchPaths, getRdbgSearchPaths, findRubyExecutable, findRdbgExecutable gain trailing platform params (completes the file buildRdbgInvocation started in #183).
adapter-javascript JavascriptAdapterFactory.validate gains a trailing nodeVersion param (override-compatible with IAdapterFactory.validate()).

Tests now pass 'win32'/'linux'/'darwin' (or 'v12.22.0') explicitly; all save/restore machinery is deleted (−184 net lines). The rust toolchain tests construct per-test adapters with an explicit platform instead of mutating the beforeEach one. A side benefit: the win32-x64 codelldb assertion in adapter-policy-rust.test.ts now passes an explicit 'x64' arch, making it hermetic on arm64 hosts.

Acceptance (from the issue)

  • rg -n "defineProperty\(process|spyOn\(process,\s*'platform'|spyOn\(process,\s*'version'" over the whole repo returns nothing (baseline: 68 hits in 8 files)
  • No production behavior change when parameters are omitted

Verification

  • All 11 affected test files: 218/218 pass
  • Full unit sweep under LEAK_GUARD_STRICT=1: 154 files / 2488 tests pass
  • pnpm run build (full workspace typecheck) clean; lint clean
  • Pre-push hook: unit + integration green

Refs #183, #159.

🤖 Generated with Claude Code

Extends the #183 seam pattern to the adapter packages so no test
redefines process.platform or process.version on the shared
fork-worker process object (68 mutation sites across 8 test files).

Production seams added, all defaulting to the real value so behavior
is unchanged when omitted:

- shared: AdapterPolicy.getAdapterSpawnConfig gains optional
  platform/arch params; RustAdapterPolicy implements them
- adapter-rust: RustDebugAdapter constructor-injects platform
  (GenericAdapterManager precedent); getRustBinaryPath and
  findDlltoolExecutable gain trailing platform params
- adapter-python: findPythonExecutable and CommandFinder.find gain
  trailing platform params; WhichCommandFinder branches on the param
- adapter-dotnet: listDotnetProcesses, getProcessExecutablePath,
  getProcessExecutableDir, getProcessArchitecture gain trailing
  platform params
- adapter-ruby: getRubySearchPaths, getRdbgSearchPaths,
  findRubyExecutable, findRdbgExecutable gain trailing platform params
- adapter-javascript: JavascriptAdapterFactory.validate gains a
  trailing nodeVersion param

Tests now pass 'win32'/'linux'/'darwin' (or a version string)
explicitly; all defineProperty/spyOn save-restore machinery deleted.

Fixes #186

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.46154% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/adapter-dotnet/src/utils/dotnet-utils.ts 66.66% 3 Missing ⚠️
packages/adapter-rust/src/utils/rust-utils.ts 66.66% 2 Missing ⚠️
packages/adapter-python/src/utils/python-utils.ts 88.88% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@debugmcpdev debugmcpdev merged commit 02009e4 into main Jul 14, 2026
13 of 16 checks passed
@debugmcpdev debugmcpdev deleted the test/186-platform-injection branch July 14, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate adapter-package tests off process.platform/version mutation (follow-up to #183)

2 participants