Skip to content

fix: route test runner and CLI output through writeAnsi for Windows#239

Closed
gumruyanzh wants to merge 1 commit intojetzig-framework:mainfrom
gumruyanzh:fix-windows-coloring
Closed

fix: route test runner and CLI output through writeAnsi for Windows#239
gumruyanzh wants to merge 1 commit intojetzig-framework:mainfrom
gumruyanzh:fix-windows-coloring

Conversation

@gumruyanzh
Copy link

Summary

  • Routes test runner and CLI stderr output through writeAnsi() to support Windows terminals
  • Adds StderrAnsiWriter adapter in both src/test_runner.zig and cli/util.zig
  • On non-Windows, behavior is unchanged (ANSI bytes pass through directly)
  • On Windows, ANSI escape codes are translated to Windows console API calls

Problem

The core logging system correctly uses jetzig.util.writeAnsi() to translate ANSI color codes to Windows console API calls. However, the test runner and CLI write colored output directly to stderr via std.io.getStdErr().writer(), bypassing this translation. This causes raw ANSI escape codes to appear in Windows terminals that don't support them.

Approach

Instead of buffering all output, a lightweight StderrAnsiWriter duck-type wraps each write through writeAnsi(). Since the CLI is a separate build target and cannot import jetzig.util, an equivalent writeAnsi() function is added to cli/util.zig using the existing cli/colors.zig windows_map.

Test plan

  • zig build succeeds
  • zig build test --summary all - all 75 tests pass
  • CI validates Windows builds

Fixes #52

🤖 Generated with Claude Code

The test runner and CLI write ANSI color codes directly to stderr,
which don't render properly on Windows terminals. The core logger
already handles this via writeAnsi(), but these components bypassed it.

- Add StderrAnsiWriter to test_runner.zig that routes writes through
  jetzig.util.writeAnsi()
- Add equivalent writeAnsi() and StderrAnsiWriter to cli/util.zig
  (CLI is a separate build target, can't import jetzig.util)
- Update all stderr writes in both files to use the ANSI-aware writer

On non-Windows, writeAnsi passes through directly with no overhead.
On Windows, ANSI escape codes are translated to console API calls.

Fixes #52

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gumruyanzh gumruyanzh closed this by deleting the head repository Feb 27, 2026
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.

Support Coloring on Windows

1 participant