test(shell): cover emulated shell branches - #1058
Open
devsy-app[bot] wants to merge 4 commits into
Open
Conversation
Add tests for three uncovered RunEmulatedShell code paths: malformed command parse error, the /dev/null OpenHandler intercept, and the nil env fallback to os.Environ. pkg/shell had minimal coverage (one test) before this change.
✅ Deploy Preview for devsydev canceled.
|
✅ Deploy Preview for images-devsy-sh canceled.
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 10 |
| Duplication | 0 |
AI Reviewer: run a review on demand. To trigger the first review automatically, go to your organization or repository integration settings. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
Signed-off-by: Samuel K <skevetter@pm.me>
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.
Package reviewed
pkg/shell(in the pkg-ssh-git scope).Issue found
pkg/shellhad minimal test coverage — a single existing test(
TestRunEmulatedShell_KillExecutesRealBinary) for ~203 lines of code. ThreeRunEmulatedShellcode paths were exercised only indirectly or not at all:malformed command
/dev/nullOpenHandlerintercept that discards redirectedoutput while still running subsequent commands
nilenv fallback toos.Environ()so referenced variables resolveChange
Add three focused tests to
pkg/shell/shell_test.go(+63 lines, no productioncode changes):
TestRunEmulatedShell_ParseError— feeds a malformed command and asserts aparse error is returned.
TestRunEmulatedShell_DevNullRedirect— redirects output to/dev/nullandasserts the redirect is intercepted (discarded) while a subsequent visible
command still runs.
TestRunEmulatedShell_NilEnvFallsBackToSystem— passes anilenv andasserts
$HOMEresolves via the system environment fallback.All tests exercise real code paths (no mocks).
Verification performed
task cli:lint:ci— 0 issues (golangci-lint, new-from-patch vs origin/main).task cli:test/go test ./pkg/shell/...— all 4pkg/shelltests PASS.pkg/gitTestRepoClone*failuresremain (stale assertion on origin/main, unrelated to this change — this PR
does not touch
pkg/git).verified=true) via the Devsy GitHub App(
hack/sign_commit).This PR was created by an AI agent as part of an automated daily package review job.