Skip to content

Commit 398bcee

Browse files
authored
Fix phantom test failures from tool first-run spinners writing to os.Stdout (#9028)
The tool first-run middleware creates detect/install spinners via uxlib.NewSpinner without setting Writer, so they default to os.Stdout and emit cursor escape codes (\033[?25l / \033[?25h) during unit tests. Under 'go test -json' these raw bytes corrupt the event stream, causing phantom 'unknown'/FAIL results on this and adjacent middleware tests. Route both spinners through m.console.Handles().Stdout, matching the prompts in the same file. Under MockConsole this handle is io.Discard (no leakage in tests); in production it is the real stdout, so behavior is unchanged.
1 parent 1071d70 commit 398bcee

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

cli/azd/cmd/middleware/tool_first_run.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ func (m *ToolFirstRunMiddleware) runFirstRunExperience(ctx context.Context) erro
230230
detectSpinner := uxlib.NewSpinner(&uxlib.SpinnerOptions{
231231
Text: "Detecting tools...",
232232
ClearOnStop: true,
233+
Writer: m.console.Handles().Stdout,
233234
})
234235
if err := detectSpinner.Run(ctx, func(ctx context.Context) error {
235236
var detectErr error
@@ -416,6 +417,7 @@ func (m *ToolFirstRunMiddleware) offerInstall(
416417
installSpinner := uxlib.NewSpinner(&uxlib.SpinnerOptions{
417418
Text: "Installing tools...",
418419
ClearOnStop: true,
420+
Writer: m.console.Handles().Stdout,
419421
})
420422
installErr := installSpinner.Run(ctx, func(ctx context.Context) error {
421423
var batchErr error

0 commit comments

Comments
 (0)