Skip to content

test(cli): TestPromptScopeChoice leaks the unterminated scope prompt onto the test binary's stderr #258

Description

@spxrogers

What

newPromptCmd in internal/cli/scope_internal_test.go wires cmd.SetOut(&out) and cmd.SetIn(...) but never cmd.SetErr(...). promptScopeChoice (internal/cli/apply.go) writes its prompt to cmd.ErrOrStderr(), so in TestPromptScopeChoice the string

run `agentsync apply` at which scope? [1/2]: 

goes to the real stderr of the test binary, with no trailing newline.

Why it matters

The leaked prompt glues itself onto whatever the test runner prints next. In a full ./internal/cli run that can be another test's failure header, producing a single line like

run `agentsync apply` at which scope? [1/2]: --- FAIL: TestSomethingElse

which a grep '^--- FAIL' (the usual way to extract failures from a long run) does not match. During the #233 spec review this hid a genuine failure from a first pass; it was found only by switching to go test -json.

Fix

Have the helper capture stderr too (a second buffer via cmd.SetErr, or the same buffer if the test only checks the transcript as a whole) and, if the test asserts on the prompt text, assert it against that buffer. Two lines in the helper; no production change.

Scope note

Pre-existing and unrelated to #233's fix; surfaced while measuring that spec's break-verifies. Filed separately so #233 stays a single-purpose change.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions