Closed hissssst closed 2 months ago
The changes to the macros and the catch all handle_info are fine. The included fix for the 1.16 warning can not be included because that syntax is invalid in any version of Elixir prior to 1.12 when the range literal with step syntax was introduced. Since the library supports users down to Elixir 1.7 I wrote https://github.com/ihumanable/patch/pull/64 to address that particular concern in a backwards compatible way.
As an aside, no one should be sending the Mock.Server any messages, given the bug description it seems likely that the patch you are providing is establishing a monitor to a process which is being evaluated in the Mock.Server process context and that's why it's getting extraneous messages. It might be a good idea not to do that in the first place, but I have no objection to including the catch all if you remove the incompatible range literal code.
remove the incompatible range literal code
Thanks for the explanation. Done.
Since this got addressed in https://github.com/ihumanable/patch/pull/64 I'm going to close out this PR.
@ihumanable but what about the GenServer message silence?
@hissssst did you ever track down the cause of that? I'm sorta torn on whether or not suppressing those is a good idea.
The only code that should be calling the mock server is the mock delegate, extraneous messages to the mock server generally mean something is wrong with the test (most commonly uncontrolled lifecycle or accidental use of the mock server pid). The messages can serve the purpose of informing the test author that there's an underlying issue with the way they've arranged their test. Suppressing that feels a bit like hiding away important information for the end user and making it "seem" like everything is ok.
Can you provide me more information on what you found about where the messages were coming from? If there is a usage of patch that seems fine but produces nuisance logs I'd like to fix that.
FWIW, there's a larger architectural issue in patch about how mock values work, they get executed in the mock server, which makes it too easy to address the mock server directly. I have a plan on how to fix this, which is to move the execution of the mock values over to the delegate, which might be a better solution than suppressing errors in the mock server. Instead of making the mock server more tolerant of unexpected messages this would make the sending of messages to the mock server nearly impossible to do by accident and achieve the same result, no annoying logs.
they get executed in the mock server, which makes it too easy to address the mock server directly
Yes, that's the reason. Try setting up a task or any process with trap exit in the patch and you'll have this problem
@ihumanable , hey, I need this PR, otherwise I get a lot of log messages
@hissssst I saw that you closed this PR, I'm sorry it took a bit to fix this. Can you take a look at version 0.14.0, I've changed how mocks work to fix this issue. Mocks will actually execute in the proper context now.
Hey, thanks for this great library!
My testing logs are getting flooded by messages like
And also
This PR overrides default handle_info into a handler which does nothing. And adds
generated
tag to all macros, plus fixes the deprecation itselfPS: Minor version bump and publish would be heavily appreciated.