vm run --rm: suppress the still-running reminder
The deferred --rm delete fires AFTER runSSHSession returns, but runSSHSession prints "vm X is still running (stop with ...)" before returning. Net effect: the user sees the reminder, then the VM gets deleted behind it — misleading. Thread a skipReminder bool into runSSHSession. `vm run` passes the same value as removeOnExit; other callers (`vm ssh`) pass false. Reinforced by a new assertion in the --rm happy-path test that the reminder string never appears in stderr. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b33f24865c
commit
cdd857b288
2 changed files with 12 additions and 7 deletions
|
|
@ -838,7 +838,7 @@ func TestRunSSHSessionPrintsReminderWhenHealthCheckPasses(t *testing.T) {
|
|||
}
|
||||
|
||||
var stderr bytes.Buffer
|
||||
if err := runSSHSession(context.Background(), "/tmp/bangerd.sock", "devbox", strings.NewReader(""), &bytes.Buffer{}, &stderr, []string{"root@127.0.0.1"}); err != nil {
|
||||
if err := runSSHSession(context.Background(), "/tmp/bangerd.sock", "devbox", strings.NewReader(""), &bytes.Buffer{}, &stderr, []string{"root@127.0.0.1"}, false); err != nil {
|
||||
t.Fatalf("runSSHSession: %v", err)
|
||||
}
|
||||
if !strings.Contains(stderr.String(), "devbox is still running") {
|
||||
|
|
@ -862,7 +862,7 @@ func TestRunSSHSessionPreservesSSHExitStatusOnHealthWarning(t *testing.T) {
|
|||
}
|
||||
|
||||
var stderr bytes.Buffer
|
||||
err := runSSHSession(context.Background(), "/tmp/bangerd.sock", "devbox", strings.NewReader(""), &bytes.Buffer{}, &stderr, []string{"root@127.0.0.1"})
|
||||
err := runSSHSession(context.Background(), "/tmp/bangerd.sock", "devbox", strings.NewReader(""), &bytes.Buffer{}, &stderr, []string{"root@127.0.0.1"}, false)
|
||||
var exitErr *exec.ExitError
|
||||
if !errors.As(err, &exitErr) {
|
||||
t.Fatalf("runSSHSession error = %v, want exit error", err)
|
||||
|
|
@ -890,7 +890,7 @@ func TestRunSSHSessionSkipsReminderOnSSHAuthFailure(t *testing.T) {
|
|||
}
|
||||
|
||||
var stderr bytes.Buffer
|
||||
err := runSSHSession(context.Background(), "/tmp/bangerd.sock", "devbox", strings.NewReader(""), &bytes.Buffer{}, &stderr, []string{"root@127.0.0.1"})
|
||||
err := runSSHSession(context.Background(), "/tmp/bangerd.sock", "devbox", strings.NewReader(""), &bytes.Buffer{}, &stderr, []string{"root@127.0.0.1"}, false)
|
||||
var exitErr *exec.ExitError
|
||||
if !errors.As(err, &exitErr) || exitErr.ExitCode() != 255 {
|
||||
t.Fatalf("runSSHSession error = %v, want exit 255", err)
|
||||
|
|
@ -1670,6 +1670,11 @@ func TestRunVMRunRMDeletesAfterSessionExits(t *testing.T) {
|
|||
if deletedRef != "tmpbox" {
|
||||
t.Fatalf("deletedRef = %q, want tmpbox", deletedRef)
|
||||
}
|
||||
// The "VM is still running" reminder would be misleading when
|
||||
// the VM is about to be deleted; it must be suppressed.
|
||||
if strings.Contains(stderr.String(), "is still running") {
|
||||
t.Fatalf("stderr = %q, should not print still-running reminder under --rm", stderr.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunVMRunRMSkipsDeleteOnSSHWaitTimeout(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue