Skip to content

test(formatter): keep escape sequences out of the go test output - #14351

Merged
ndeloof merged 1 commit into
docker:mainfrom
htoyoda18:fix/formatter-test-ansi-output
Oct 22, 2026
Merged

ndeloof merged 1 commit into
docker:mainfrom
htoyoda18:fix/formatter-test-ansi-output

Conversation

@htoyoda18

@htoyoda18 htoyoda18 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does

Stops TestRunHandlesKeysUntilContextIsDone from being reported as a failure by gotestsum even though it passes.

Related issue

No issue: this is a minor test-only fix. Every unit test run currently ends with
=== FAIL: cmd/formatter TestRunHandlesKeysUntilContextIsDone (unknown) and DONE … 1 failure,
including green runs on main. The exit code is 0, but the summary counts one failure,
which makes real failures harder to spot (this line was mistaken for a genuine failure in #14339).

Fixes #

Changes made

  • The test sends the detach key, which calls clearNavigationMenu(). That function writes ANSI escape
    sequences to os.Stdout without a trailing newline, so they end up in front of the
    --- PASS line and gotestsum cannot parse the result.
  • Set disableAnsi = true for the duration of the test (restored with t.Cleanup),
    following the pattern already used in ansi_test.go. Test-only change; no production code is modified.

Testing done

  • Unit tests pass: make test
  • E2E tests pass: make e2e-compose or make e2e-compose-standalone
  • Linting passes: make lint
  • Code formatted: make fmt
  • Manually tested (describe):

AI tool used (if applicable)

AI Tool:

Additional context

Introduced by #14324, which added the navigation menu clearing on detach.

(not mandatory) A picture of a cute animal, if possible in relation to what you did
image

Signed-off-by: hiroto.toyoda <hiroto.toyoda@dena.com>
@htoyoda18
htoyoda18 marked this pull request as ready for review October 15, 2026 18:35
@htoyoda18
htoyoda18 requested review from a team as code owners October 15, 2026 18:35
@htoyoda18
htoyoda18 requested review from glours and ndeloof October 15, 2026 18:35

@ndeloof ndeloof left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Confirmed on a run of go test -v ./cmd/formatter: on main the escape sequences end up right before --- PASS: TestRunHandlesKeysUntilContextIsDone, with this change the output is clean (also with -race).

Nit, not blocking: restoring the previous value of disableAnsi in the cleanup (old := disableAnsi) rather than resetting it to false would be more robust, even if it matches what ansi_test.go does.

@ndeloof
ndeloof enabled auto-merge (rebase) October 22, 2026 06:59
@ndeloof
ndeloof merged commit e18ab3d into docker:main Oct 22, 2026
60 checks passed
@codecov

codecov Bot commented Oct 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants