-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Resolve inconsistent use of #inspect in expect_raises #16265
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
base: master
Are you sure you want to change the base?
Resolve inconsistent use of #inspect in expect_raises #16265
Conversation
dc82cfe to
f8fb47c
Compare
|
The failures caused by the change: I assume that that relaxing and matching only a substring was not intentional and the expected behaviour to check for equality. Does it make sense? |
|
Wondering if there is a reasonable way to check correctness of backtrace in an error message. It seems a hardcoded https://github.com/crystal-lang/crystal/actions/runs/18786062634/job/53605370730?pr=16265 https://github.com/crystal-lang/crystal/actions/runs/18786062643/job/53604507713?pr=16265 |
|
I don't think we need to check the backtrace here. That's a task for more specialized specs (like |
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.
Great job on the extensive specs ❤️
|
There are a lot of failed compiler tests. Wondering how they are related to the changes. https://github.com/crystal-lang/crystal/actions/runs/18788933780/job/53614137106 |
|
@andrykonchin Maybe it's because you're now using |
|
Yeah. |
|
Right, indeed. Wondering how important is this There is one minor issue with the Also does it sound good just to modify the spec helper So instead of Lines 161 to 165 in 6a14b81
it might look like the following def assert_error(str, message = nil, *, inject_primitives = false, flags = nil, file = __FILE__, line = __LINE__)
semantic str, inject_primitives: inject_primitives, flags: flags
rescue e : TypeException
e.to_s.should contain(message) if message
else
fail "expected TypeException but nothing was raised"
end
|
Yes! We can't do that.
Maybe that's all a bit sloppy naming. Perhaps we can improve this somehow and make expectations more clear?
Such an empty exception still wouldn't match any expected message. So that should be entirely fine.
I'm not sure where you're going with this? We cannot change the semantics of |
|
Done. There is a single failure in "wasm32-test" job. Wondering how to deal with it properly. https://github.com/crystal-lang/crystal/actions/runs/18802079919/job/53650943220?pr=16265 |
I understand.
Yeah, indeed. Even if the
Indeed, it doesn't lead to false positives or negatives. I am talking about "failed test output". Let's consider an example expect_raises(Exception, "abc") do
raise Exception.new(nil)
endThe output is the following: My point is that the In general both partial matching and |
Hm, would it be a breaking change if it isn't documented? If the only specs that rely on this behaviour is Crystal internal specs (e.g. the compiler specs) then we are free to make the changes. |
Changes:
#inspectfor both expected and actual message in the same way#expect_raisesExample:
For the given test:
Output is the following
Closes #14030