fix: route test runner and CLI output through writeAnsi for Windows#239
Closed
gumruyanzh wants to merge 1 commit intojetzig-framework:mainfrom
Closed
fix: route test runner and CLI output through writeAnsi for Windows#239gumruyanzh wants to merge 1 commit intojetzig-framework:mainfrom
gumruyanzh wants to merge 1 commit intojetzig-framework:mainfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
writeAnsi()to support Windows terminalsStderrAnsiWriteradapter in bothsrc/test_runner.zigandcli/util.zigProblem
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 viastd.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
StderrAnsiWriterduck-type wraps each write throughwriteAnsi(). Since the CLI is a separate build target and cannot importjetzig.util, an equivalentwriteAnsi()function is added tocli/util.zigusing the existingcli/colors.zigwindows_map.Test plan
zig buildsucceedszig build test --summary all- all 75 tests passFixes #52
🤖 Generated with Claude Code