Inject exit command to Create in tests#307
Conversation
There was an issue with test runs ending abruptly with no message when a database configuration was incorrect. In such cases the Create command ran an `exit(1)`, which exited not only the command, but the whole test run. The solution was already prepared, but not used: it was already possible to inject an alternative to just calling the actual `Kernel.exit`. This injects a test double instead and asserts it is not called.
d7d58c3 to
1876c73
Compare
|
Excellent! Confirmed this works. Getting 317 examples evaluated every time locally now. Can we get rid of the existing code that tried to solve this issue? Or could we somehow make that work, since it's simpler? I see that same line is used in the prepare_spec too, which isn't in this PR. Do we need to extend this fix to that file as well? |
|
This existing code is actually in use, at least for |
|
Ah, it looks like they come from the parent DB::Command. Yea, I think we could inject the exit for that command. Another option would be switching to In general, I wonder if we should be directly exiting at all this far down. It seems like it we could just raise a specific error for the situation and catch it higher up, and then exit in one place (in As an aside, I don't think |
|
I modified the I agree that just calling As for |
|
Thanks for this improvement, @katafrakt! The injected exit proc thing was something I had to introduce for one of those more complex DB commands that stitches together a range of other commands. It's a good change to be making this more consistent throughout. Off the top of my head, I'm not sure why the I agree with your thoughts that calling |
There was an issue with test runs ending abruptly with no message when a database configuration was incorrect. In such cases the Create command ran an
exit(1), which exited not only the command, but the whole test run.The solution was already prepared, but not used: it was already possible to inject an alternative to just calling the actual
Kernel.exit. This injects a test double instead and asserts it is not called.Fixes #306