banger/internal/cli
Thales Maciel 672d7151e9
smoke: five more scenarios + fix exit-code propagation bug the new ones caught
Five new smoke scenarios layered on top of the existing bare + workspace
vm-run tests:

  - exit-code propagation: `sh -c 'exit 42'` must rc=42
  - workspace dry-run: --dry-run lists tracked files without a VM
  - workspace --include-untracked: opt-in ships files outside the git
    index (regression guard on the security-default flip from review 4)
  - concurrent vm runs: two --rm invocations in parallel both succeed
    (stresses per-VM locks, createVMMu reservation window, tap pool)
  - invalid spec rejection: --vcpu 0 must fail with no VM row left
    behind (the "cleanup on partial failure" path the review flagged)

The exit-code scenario caught a real bug on first run:

  `banger vm run --rm -- sh -c 'exit 42'` returned rc=0, not 42.

Root cause in internal/cli/ssh.go's sshCommandArgs: extra args were
appended to the ssh argv verbatim, relying on ssh(1)'s implicit
space-join to deliver the remote command. That works for single
tokens (echo hello) but re-tokenises multi-word commands on the
remote side: `ssh host sh -c 'exit 42'` becomes remote
`sh -c exit 42`, where `42` is $0 for the already-completed `exit`,
and the exit code the user asked for is lost.

Fix: shell-quote every element of extra (`'sh'` `'-c'` `'exit 42'`)
and join them into a single trailing argv entry. ssh's space-join
then produces exactly the command the user typed on the remote
shell. TestSSHCommandArgs was updated to pin the quoting; the
existing TestRunVMRunCommandModePropagatesExitCode test needed a
one-word quote tweak (`false` → `'false'`).

Smoke run after fix passes all seven scenarios in ~2 min on warm
state. cmd/banger coverage jumped to 100% (the invalid-spec
scenario hits the error-reporting path that wasn't covered
before).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 19:37:07 -03:00
..
aliases_test.go remove vm session feature 2026-04-20 12:47:58 -03:00
banger.go ssh-config: make the ssh <name>.vm shortcut opt-in 2026-04-20 13:57:26 -03:00
bangerd.go Add Go daemon-driven VM control plane 2026-03-16 12:52:54 -03:00
cli_test.go smoke: five more scenarios + fix exit-code propagation bug the new ones caught 2026-04-22 19:37:07 -03:00
commands_daemon.go cli + daemon: move test seams off package globals onto injected structs 2026-04-19 19:03:55 -03:00
commands_image.go cli + daemon: move test seams off package globals onto injected structs 2026-04-19 19:03:55 -03:00
commands_internal.go cli + daemon: move test seams off package globals onto injected structs 2026-04-19 19:03:55 -03:00
commands_kernel.go cli + daemon: move test seams off package globals onto injected structs 2026-04-19 19:03:55 -03:00
commands_ssh_config.go ssh-config: make the ssh <name>.vm shortcut opt-in 2026-04-20 13:57:26 -03:00
commands_vm.go noteUntrackedSkipped: fix subdir underreport + be best-effort everywhere 2026-04-22 12:42:33 -03:00
completion.go remove vm session feature 2026-04-20 12:47:58 -03:00
completion_test.go remove vm session feature 2026-04-20 12:47:58 -03:00
daemon_lifecycle.go cli + daemon: move test seams off package globals onto injected structs 2026-04-19 19:03:55 -03:00
deps.go seams: move the last four package globals onto instance fields 2026-04-22 12:07:14 -03:00
formatters_test.go remove vm session feature 2026-04-20 12:47:58 -03:00
make_bundle_test.go banger internal make-bundle: build image bundles from flat rootfs tars 2026-04-17 15:17:50 -03:00
printers.go remove vm session feature 2026-04-20 12:47:58 -03:00
prune_test.go cli + daemon: move test seams off package globals onto injected structs 2026-04-19 19:03:55 -03:00
ssh.go smoke: five more scenarios + fix exit-code propagation bug the new ones caught 2026-04-22 19:37:07 -03:00
vm_create.go cli + daemon: move test seams off package globals onto injected structs 2026-04-19 19:03:55 -03:00
vm_run.go noteUntrackedSkipped: fix subdir underreport + be best-effort everywhere 2026-04-22 12:42:33 -03:00
vm_spec_test.go vm defaults: host-aware sizing + spec line on spawn + doctor check 2026-04-19 13:06:51 -03:00
workspace_preview.go noteUntrackedSkipped: fix subdir underreport + be best-effort everywhere 2026-04-22 12:42:33 -03:00
workspace_preview_test.go noteUntrackedSkipped: fix subdir underreport + be best-effort everywhere 2026-04-22 12:42:33 -03:00