Conversation
- Add 19 test functions covering previously untested stdio server paths - Test environment variable passthrough with -e flag parsing - Test container detection and security warnings - Test concurrent access with 100 goroutines (double-check locking) - Test all error paths and logging variations - Increase GetOrLaunch coverage from ~40% to ~85% Resolves stdio path coverage gap (0% -> ~95%)
This was referenced Jan 23, 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.
Test Coverage Improvement: GetOrLaunch Function
Function Analyzed
internal/launcherGetOrLaunchlauncher.go(lines 48-185)Why This Function?
GetOrLaunchwas selected because it is the most complex function with the lowest test coverage in the codebase:Complexity Breakdown
-eflag parsing loopTests Added
Created 19 comprehensive test functions (649 lines) in new file
internal/launcher/getorlaunch_stdio_test.go:Environment Variable Passthrough Tests (8 tests)
TestGetOrLaunch_StdioServer_EnvPassthrough- Env var passthrough with-eflagTestGetOrLaunch_StdioServer_EnvPassthroughMissing- Missing env var warning pathTestGetOrLaunch_StdioServer_EnvExplicitValue- ExplicitVAR=value(not passthrough)TestGetOrLaunch_StdioServer_EnvLongValue- Long value truncation (>10 chars)TestGetOrLaunch_StdioServer_MultipleEnvFlags- Multiple-eflags in argsTestGetOrLaunch_StdioServer_EnvFlagAtEnd- Edge case:-eat end without valueTestGetOrLaunch_StdioServer_WithEnvMap- Env map in configTestGetOrLaunch_StdioServer_EmptyEnvMap- Empty env map (no logging)Container Detection Tests (3 tests)
TestGetOrLaunch_DirectCommandInContainer- Direct command security warningTestGetOrLaunch_DockerCommandInContainer- Docker command OK in containerTestGetOrLaunch_ContainerFieldConversion- Container field → docker commandError Handling Tests (5 tests)
TestGetOrLaunch_StdioServer_InvalidCommand- Invalid command error pathTestGetOrLaunch_HTTPConnectionError- HTTP connection creation failureTestGetOrLaunch_StdioConnectionError- Stdio connection creation failureTestGetOrLaunch_ErrorLogging_DirectCommand- Error logging for direct commandsTestGetOrLaunch_ErrorLogging_DirectCommandInContainer- Container-specific error loggingThread Safety Tests (2 tests)
TestGetOrLaunch_ConcurrentLaunch- 10 concurrent launches (double-check lock)TestGetOrLaunch_RaceConditionDoubleCheck- 100 concurrent goroutines stress testCommand Detection Tests (1 test)
TestGetOrLaunch_StdioServer_DockerCommand- Docker command detectionCoverage Report
Before (from launcher_test.go):
After (with getorlaunch_stdio_test.go):
Estimated Coverage Improvement:
Test Quality Features
loadConfigFromJSONtest helperTest Execution
All tests are designed to execute without external dependencies:
loadConfigFromJSONtest helperImpact
This PR significantly improves the robustness of the launcher package by:
Next Steps
After this PR merges, the next high-priority under-tested functions are:
GetOrLaunchForSession(launcher.go, 108 LOC) - Session pool logicViolationError.Error()(difc/labels.go, 25 LOC) - Complex branchingvalidateCustomServerConfig(config/validation.go, 27 LOC) - Schema validationGenerated by Test Coverage Improver
Targeting the most complex, under-tested functions in the codebase