[#121] Add sandbox tests for core doctor checks#261
Merged
Conversation
- Add `environment` property to DoctorRunner and 10 check structs (CommandCheck, MCPServerCheck, PluginCheck, HookCheck, GitignoreCheck, ProjectIndexCheck, PackGitignoreCheck, ExternalCommandExistsCheck, ExternalHookEventExistsCheck, ExternalSettingsKeyEqualsCheck), replacing all hardcoded `Environment()` calls - Add `projectRootOverride` to DoctorRunner to bypass ProjectDetector.findProjectRoot() in tests - Flow environment through DerivedDoctorChecks and standaloneDoctorChecks
- Thread environment from DoctorCommand to DoctorRunner - Pass environment to PackGitignoreCheck in artifactChecks() - Remove redundant environment parameter from private standaloneDoctorChecks()
- Add 23 tests across 5 suites verifying doctor checks work correctly with injected Environment(home: tmpDir) - Cover MCPServerCheck, PluginCheck, HookCheck, ProjectIndexCheck, and DerivedDoctorChecks with full sandbox isolation - Verify check/fix behavior for pass, fail, warn, skip, and fix paths
- Add `commit.gpgsign=false` to test repo config in PackFetcherTests and PackUpdaterTests to prevent 1Password SSH agent interference - Fix ambiguous #require assertion in CoreDoctorCheckSandboxTests
- Replace duplicated makeSandboxHome with existing makeGlobalTmpDir - Add PluginCheck invalid JSON test for parity with MCPServerCheck - Add ExternalHookEventExistsCheck sandbox tests (4 tests: pass, fail, skip optional, missing settings) - Add ExternalSettingsKeyEqualsCheck sandbox tests (4 tests: pass, warn mismatch, warn absent, missing settings)
This was referenced Mar 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add sandbox tests for all core doctor check structs that were made injectable in #256. Each test creates a temp directory, constructs
Environment(home: tmpDir), and verifies check behavior against controlled file fixtures — no real~/paths are touched. Also fixes pre-existing test failures caused by 1Password SSH agent interfering withgit commitin test fixture repos.Replaces closed PR #257. Part 2 of the #121 series (builds on merged #256).
Changes
CoreDoctorCheckSandboxTests.swiftwith 23 tests across 5 suites:MCPServerCheckSandboxTests(5 tests): global/project-scoped servers, missing server, missing file, invalid JSONPluginCheckSandboxTests(3 tests): enabled/not-enabled plugin, missing settingsHookCheckSandboxTests(6 tests): present+executable, missing, optional skip, not-executable, fix makes executable, fix when missingProjectIndexCheckSandboxTests(5 tests): all paths valid, stale paths, empty index, fix prunes stale, global sentinelDerivedDoctorCheckSandboxTests(4 tests): copyPackFile global URL, copyPackFile with project root + fallback, mcpServer uses env, allDoctorChecks forwards envcommit.gpgsign=falseto test repo config inPackFetcherTestsandPackUpdaterTeststo prevent 1Password SSH agent failuresTest plan
swift testpasses locally (758 tests, 0 failures)swiftformat --lint .andswiftlintpass without violationsmcs sync,mcs doctor)