-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emit ansi color codes in the rendered
field of json diagnostics
#59128
Conversation
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
I've been looking at doing something similar to this. I'm considering using JSON output only for Cargo for a few reasons. Do you happen to know if the "rendered" field is fully consistent with the normal output? |
This comment has been minimized.
This comment has been minimized.
Yes it's identical. It's actually generated by invoking the regular diagnostic renderer and just recording the output. |
@oli-obk Can we get |
Oh yea, totally forgot about this. I've been meaning to fix that in forever. I'll do that in this PR as to not regress the status quo even further. |
My email is telling me I was r?-ed, but I can't see myself in this thread... am I missing something? |
the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, even though I don't have r? permissions :)
Note that this would not have changed the rendered output (because that would severely screw with r? @eddyb |
This comment has been minimized.
This comment has been minimized.
"failed to decode compiler output as json: \ | ||
`{}`\nline: {}\noutput: {}", | ||
error, line, output | ||
))); | ||
); | ||
panic!() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this panic!
match what proc_res.fatal
would do?
Nevermind, it avoids fatal
trying to print the rendered field from JSON (and failing).
self.status, self.cmdline, self.stdout, self.stderr | ||
self.status, self.cmdline, | ||
json::extract_rendered(&self.stdout), | ||
json::extract_rendered(&self.stderr), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is the main compiletest
change? 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jop
@bors r=mark-i-m,eddyb |
📌 Commit 8f1d62befd2db8bfbe0eef0cd163945fafde2bf4 has been approved by |
This comment has been minimized.
This comment has been minimized.
@bors r- |
This comment has been minimized.
This comment has been minimized.
@bors r=mark-i-m,eddyb |
📌 Commit b5fc2c41b39c666fce1c275690a79bdc9cdc33d0 has been approved by |
@@ -1,5 +1,5 @@ | |||
// ignore-cloudabi | |||
// compile-flags: --error-format pretty-json -Zunstable-options | |||
// compile-flags: --error-format pretty-json -Zunstable-options --colorful-json=true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a test for the current output here :-/
Also, although I see the immediate benefit of this, I would like for us to tackle a more "general" solution at some point where we can also produce HTML, for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do have other --error-format pretty-json
ui tests.
So you're imagining something like --json-rendered=(plain|termcolor|html)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping @estebank
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my mind something like --json-rendered=extended
where the textual output would be the same and we'd have extra json fields annotating those with extra information:
{"text": "path `std::string::String`", "annotations": [{"start": 6, "end": 25, "highlight_type": "highlighted"}]}
That way any tool can consume these and turn them into whatever their needs may be.
That being said, having specific support for both terminal and html output make sense to me, given they probably cover 80% of all likely use cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The --json-rendered
list can be extended in the future to support schemes like the one you proposed. I will change the PR to only support plain
and termcolor
for now.
🌲 The tree is currently closed for pull requests below priority 15, this pull request will be tested once the tree is reopened |
⌛ Testing commit 325936a with merge 1d700581f3bce5188c75e2e789d93ea6b97acfed... |
💔 Test failed - status-appveyor |
I guess color codes differ between windows and linux? |
@bors r- |
@bors r=mark-i-m,eddyb |
📌 Commit 55534e41dda3847c605f56a32b6e7d5b1ea483c5 has been approved by |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@bors r- |
@bors r=mark-i-m,eddyb |
📌 Commit 5c6a43a has been approved by |
…ddyb Emit ansi color codes in the `rendered` field of json diagnostics cc @ljedrz Implemented for rust-lang#56595 (comment) (x.py clippy)
Rollup of 5 pull requests Successful merges: - #59128 (Emit ansi color codes in the `rendered` field of json diagnostics) - #59646 (const fn: Improve wording) - #59986 (Miri: refactor new allocation tagging) - #60003 (LLD is not supported on Darwin) - #60018 (Miri now supports entropy, but is still slow) Failed merges: r? @ghost
cc @ljedrz
Implemented for #56595 (comment) (x.py clippy)