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.
What
newPromptCmdininternal/cli/scope_internal_test.gowirescmd.SetOut(&out)andcmd.SetIn(...)but nevercmd.SetErr(...).promptScopeChoice(internal/cli/apply.go) writes its prompt tocmd.ErrOrStderr(), so inTestPromptScopeChoicethe stringgoes 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/clirun that can be another test's failure header, producing a single line likewhich 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 togo 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.