Only colorize the profiler report when writing to a terminal - #9383
Open
abadams wants to merge 1 commit into
Open
Only colorize the profiler report when writing to a terminal#9383abadams wants to merge 1 commit into
abadams wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9383 +/- ##
==========================================
+ Coverage 69.89% 70.09% +0.19%
==========================================
Files 261 261
Lines 79362 79362
Branches 19349 19349
==========================================
+ Hits 55474 55628 +154
+ Misses 17926 17898 -28
+ Partials 5962 5836 -126 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
|
That's a real Windows failure |
| bool support_colors = | ||
| !(no_color && no_color[0]) && | ||
| term && (strstr(term, "color") || strstr(term, "xterm")) && | ||
| isatty(STDOUT_FILENO); |
Member
There was a problem hiding this comment.
It's _isatty on Windows, I'm pretty sure.
The report gated ANSI color escapes on the TERM environment variable alone. CI and other redirected environments commonly set TERM=xterm-256color while stdout is a pipe or file, so the escapes were written straight into the captured log as noise. Also require isatty(STDOUT_FILENO) (the report is printed via halide_print, whose default writes to stdout), and honor the NO_COLOR convention. The no-color path already emits plain box-drawing separators, so the table stays well-formed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
abadams
force-pushed
the
abadams/profiler_report_isatty
branch
from
August 25, 2026 19:42
db40ccc to
f7d6109
Compare
| // redirected environments often set TERM=xterm-256color while stdout is a | ||
| // pipe or file, which would splatter escape codes into the captured log. | ||
| // The report is printed via halide_print, whose default writes to stdout. | ||
| const char *no_color = getenv("NO_COLOR"); |
Member
There was a problem hiding this comment.
This should ideally honor the same logic as IRPrinter.h, but note I'm about to fix a bug there #9393
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.
The profiler report gated its ANSI color escapes on the
TERMenvironment variable alone. CI and other redirected environments commonly setTERM=xterm-256colorwhile stdout is actually a pipe or file, so the escape codes were written straight into the captured log as noise (this showed up as[NON-XML-CHAR-0x1B]…garbage in buildbot test logs).This adds an
isatty(STDOUT_FILENO)check to the gate (the report is printed viahalide_print, whose default writes to stdout) and honors theNO_COLORconvention.isattyis declared inruntime_internal.hnext to the existingwrite/getenvdeclarations.The no-color path already emits plain box-drawing separators, so the table stays well-formed — only the escape sequences are dropped.
Verified against a rebuilt runtime with a JIT pipeline compiled with
Target::Profile:TERM=xterm-256color→ 0 escape bytesTERM=xterm-256color→ colors presentNO_COLOR=1→ 0 escape bytes🤖 Generated with Claude Code