Skip to content

test(shell): cover emulated shell branches - #1058

Open
devsy-app[bot] wants to merge 4 commits into
mainfrom
pkg-ssh-git/shell-emulation-branch-tests
Open

test(shell): cover emulated shell branches#1058
devsy-app[bot] wants to merge 4 commits into
mainfrom
pkg-ssh-git/shell-emulation-branch-tests

Conversation

@devsy-app

@devsy-app devsy-app Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Package reviewed

pkg/shell (in the pkg-ssh-git scope).

Issue found

pkg/shell had minimal test coverage — a single existing test
(TestRunEmulatedShell_KillExecutesRealBinary) for ~203 lines of code. Three
RunEmulatedShell code paths were exercised only indirectly or not at all:

  • the parse-error return when the emulated shell interpreter rejects a
    malformed command
  • the custom /dev/null OpenHandler intercept that discards redirected
    output while still running subsequent commands
  • the nil env fallback to os.Environ() so referenced variables resolve

Change

Add three focused tests to pkg/shell/shell_test.go (+63 lines, no production
code changes):

  • TestRunEmulatedShell_ParseError — feeds a malformed command and asserts a
    parse error is returned.
  • TestRunEmulatedShell_DevNullRedirect — redirects output to /dev/null and
    asserts the redirect is intercepted (discarded) while a subsequent visible
    command still runs.
  • TestRunEmulatedShell_NilEnvFallsBackToSystem — passes a nil env and
    asserts $HOME resolves 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 4 pkg/shell tests PASS.
  • Full suite: only the known pre-existing pkg/git TestRepoClone* failures
    remain (stale assertion on origin/main, unrelated to this change — this PR
    does not touch pkg/git).
  • Commit is app-signed and verified (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.

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.
@netlify

netlify Bot commented Aug 15, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit c241c2c
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a829d2014eb430008190570

@netlify

netlify Bot commented Aug 15, 2026

Copy link
Copy Markdown

Deploy Preview for images-devsy-sh canceled.

Name Link
🔨 Latest commit c241c2c
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a829d20a816d00008639849

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 10 complexity · 0 duplication

Metric Results
Complexity 10
Duplication 0

View in Codacy

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.

Run reviewer

TIP This summary will be updated as you push new changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant