-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Make creating test models more straightforward and revert to swallowing exceptions #9526
Conversation
@derrabus I'm requesting your review now because it's the most legible and interesting part. EDIT: less so now that I have completed the first item of that todo list |
a173b08
to
74cefd7
Compare
DropSchema might be a bad idea, because schema creation is so expensive except for sqlite |
@beberlei I didn't check that in #8962 Once this is completed, I can rework EDIT: oh now it's failing because some tests create |
75be1a0
to
fbbb858
Compare
@beberlei it looks like the performance loss is so big I can even "feel" it, even with SQLite. Let's revert to swallowing exceptions. I'll use a more specific exception, which should fix the issue I was aiming to fix in #8962 (I remember getting mad because the test was hiding an exception from me, which was probably from a different hierarchy that the one we want to catch). |
fbbb858
to
ec9d0c4
Compare
9307dac
to
6a1657a
Compare
15b685e
to
0261a15
Compare
LGTM, once the doc block is fixed. The code is much more readable this way, very nice. |
In doctrine#8962, I established that swallowing exceptions while creating model was bad because it could hide other helpful exceptions. As it turns out however, swallowing exceptions is really the way to go here, because of the performance implication of calling dropSchema(). It is possible to catch a more precise exception as well, which should preserve the benefits of not swallowing them. It looks like I based my grep on the comment inside the catch and today, I found many other occurrences of this pattern, without the easy to grep comment. I decided to fix them as well, but in a lazier way: one no longer has to remember to call dropSchema in tearDown() now, it is automated.
0261a15
to
26e85b8
Compare
In #8962, I established that
swallowing exceptions while creating model was bad because it could hide
other helpful exceptions.
As it turns out however, swallowing exceptions is really the way to go
here, because of the performance implication of calling dropSchema(). It
is possible to catch a more precise exception as well, which should
preserve the benefits of not swallowing them.
It looks like I based my grep on the comment inside the catch and today,
I found many other occurrences of this pattern, without the easy to grep
comment.
I decided to fix them as well, but in a lazier way: one no longer has to
remember to call dropSchema in tearDown() now, it is automated.
Here is the
grep
I used this time:rg --multiline '\} catch \(Exception \$e\) \{\n\s+\}'
TODO
grep
fordropSchema
and improve tests changed in Stop swallowing exceptions #8962 as well.