-
-
Notifications
You must be signed in to change notification settings - Fork 396
[Ruby 3.2] Add test for no extra escaping in error messages #1340
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
Conversation
command_line/error_message_spec.rb
Outdated
| end | ||
|
|
||
| it "is not modified with extra escaping of control characters and backslashes" do | ||
| out = ruby_exe('raise "\e[31mRed\x1b[0m error\\\message"', args: "2>&1", exit_status: 1) |
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.
Why the \\\? (3 of them)
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.
Single-quoted string turns \\ into \, and we need two backslashes inside the double-quoted string, so this needs 3 or 4 backslashes to output 1.
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.
Let's do 4 then, 3 is quite hard to figure out and feels hacky
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.
Done. Actually, there seems to be no spec for backslash escaping at all, at least in language/string_spec.rb? Regexp quoting is probably relevant, but it relies on this.
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.
Right, though I suppose it's already pretty well tested directly in Prism as that's where most of that backslash handling happens (in string literals at least).
eregon
left a comment
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.
Looks good
9226f3a to
ad917a9
Compare
Ruby no longer escapes control characters and backslashes in an error message. [Feature #18367]
ad917a9 to
8877450
Compare
From #1016