Skip to content

Fix coloring of info messages in isoltest #14580

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

Merged
merged 4 commits into from
Oct 19, 2023
Merged

Conversation

cameel
Copy link
Member

@cameel cameel commented Sep 29, 2023

Depends on #14585. Merged.

Isoltest prints "info" messages colored as errors. Apparently we missed that when we introduced the new level, probably because we still have very few such messages.

Now that #14510 is printing a lot of them, it's getting really annoying. This PR fix that and does some small refactors to prevent this getting out of sync so easily in the future.

@cameel cameel self-assigned this Sep 29, 2023
@cameel cameel force-pushed the fix-isoltest-info-color branch 2 times, most recently from 9d2c376 to 6c1ed8c Compare September 29, 2023 22:06
{
case Error::Severity::Error: return RED_BACKGROUND;
case Error::Severity::Warning: return ORANGE_BACKGROUND_256;
case Error::Severity::Info: return GRAY_BACKGROUND;
Copy link
Member

Choose a reason for hiding this comment

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

LGTM. Just one question, wouldn't this allows to display the text in white over gray background?

Copy link
Member

Choose a reason for hiding this comment

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

Wait a second... we do have colored backgrounds for these :-D? That's weird - I mean, that's generally horrible, isn't it? But also I've never seen that in any output myself, even though the escape actually works in my terminal...

Copy link
Member Author

Choose a reason for hiding this comment

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

LGTM. Just one question, wouldn't this allows to display the text in white over gray background?

White text actually looks fine on this background. That's why I chose this color.

Wait a second... we do have colored backgrounds for these :-D? That's weird - I mean, that's generally horrible, isn't it? But also I've never seen that in any output myself, even though the escape actually works in my terminal...

We use it in tests for highlighting parts of the source matching a particular error/warning/info. I actually find it pretty convenient - having to decode character offsets from source locations in your head sounds more horrible :) For example you can see it in DebugWarner output in new analysis when a test does not pass. It's not used for compilation errors by the compiler.

Since it's not used outside of tests, I could put it somewhere in test utils, but putting it together with foreground colors seemed like a better choice to me. If I ever needed it and were ever looking for it, I'd probably look here (or in AnsiColorized.h, but it did not seem right to make that file depend on the Error definition).

Copy link
Member

@r0qs r0qs Oct 9, 2023

Choose a reason for hiding this comment

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

Right. Just mentioned because I remembered this issue: #14378. So I guess this PR would also fix that, right? At least in some tests I did here using a white background, everything seems to work fine.

Copy link
Member

@ekpyron ekpyron Oct 10, 2023

Choose a reason for hiding this comment

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

I actually missed the "in isoltest" part of this PR (not sure how :-)) and thought it was about regular compiler output, that's why I was confused :-).
So just to confirm, this is not meant to change colored solc output, but just to affect isoltest? (I could probably also read the code for an answer :-))

Copy link
Member

Choose a reason for hiding this comment

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

It uses errorColored which in turn is used by printExceptionInformation and by the CommandLineInterface to print compiler errors in the CLI. This was why I initially thought it could be solving the issue that I mentioned above (i.e. not only affecting isoltests), but it seems that the code doesn't really change anything in the errorColored logic.

Copy link
Member Author

Choose a reason for hiding this comment

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

So just to confirm, this is not meant to change colored solc output, but just to affect isoltest? (I could probably also read the code for an answer :-))

Exactly. There are no behavior changes outside of tests. The non-test code is only refactored.

So I guess this PR would also fix that, right?

No, at least not in a significant way. The issue is not limited to test output.

BTW, not sure what the "fix" would be there. I'd assume that the terminal that changes colors of various things would do that by remapping the meaning of these colors to something else. Or are there some "themable"/relative color codes that we should be using to play nice with such terminals?

Copy link
Member

@r0qs r0qs Oct 16, 2023

Choose a reason for hiding this comment

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

BTW, not sure what the "fix" would be there. I'd assume that the terminal that changes colors of various things would do that by remapping the meaning of these colors to something else. Or are there some "themable"/relative color codes that we should be using to play nice with such terminals?

I'm not sure either. I know that on GNU/Linux you could use tput to query for terminal-dependent information, but I don't know if a solution based on that, or on ncurses, would be reliable and cross-platform. On GNU/Linux you can do tput colors to get the maximum number of colors supported by the terminal according with the terminfo database, but it may not really reflect the current terminal capabilities. And I'm not sure you can query for specific colors either. But if there is a way to reliably detect the background color and set the default as the opposite color, then we would have a fix for it.

@cameel cameel force-pushed the fix-isoltest-info-color branch from 6c1ed8c to 8eed91a Compare October 4, 2023 11:54
@cameel cameel added the has dependencies The PR depends on other PRs that must be merged first label Oct 4, 2023
@cameel cameel changed the base branch from develop to ci-stop-using-deprecated-macos-large October 4, 2023 12:02
Base automatically changed from ci-stop-using-deprecated-macos-large to develop October 4, 2023 12:53
@cameel cameel removed the has dependencies The PR depends on other PRs that must be merged first label Oct 4, 2023
@cameel cameel force-pushed the fix-isoltest-info-color branch 2 times, most recently from 5518ebc to daca358 Compare October 13, 2023 13:08
matheusaaguiar
matheusaaguiar previously approved these changes Oct 13, 2023
Copy link
Collaborator

@matheusaaguiar matheusaaguiar left a comment

Choose a reason for hiding this comment

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

Just a couple of minor remarks.

@cameel cameel force-pushed the fix-isoltest-info-color branch 3 times, most recently from d224c61 to 4245789 Compare October 16, 2023 16:46
@cameel cameel requested review from matheusaaguiar and r0qs October 16, 2023 16:48
matheusaaguiar
matheusaaguiar previously approved these changes Oct 17, 2023
@matheusaaguiar
Copy link
Collaborator

Although I approved, I just noticed there are some conflicts.

@r0qs
Copy link
Member

r0qs commented Oct 17, 2023

Yeah, just a rebase and it is fine for me as well :)

@cameel
Copy link
Member Author

cameel commented Oct 19, 2023

Rebased.

@cameel cameel requested a review from matheusaaguiar October 19, 2023 15:47
@cameel cameel force-pushed the fix-isoltest-info-color branch from a017797 to 0da44ca Compare October 19, 2023 16:43
@cameel cameel merged commit ddb0d89 into develop Oct 19, 2023
@cameel cameel deleted the fix-isoltest-info-color branch October 19, 2023 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants