-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Test supervisor has :"$callers" populated with the test pid, but the child process does not #13666
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
Comments
We should probably revert that commit. I think the approach there only works if you spawn tasks, but even then I am not sure, and I don't think it makes sense to spawn tasks directly in the test supervisor anyway. |
Thanks for the quick response, @josevalim! Would you be interested in a different approach that works for all processes with the test supervisor or do you think the additional complexity required wouldn't be worth it? For context, I have a GenServer that would ideally authenticate with a remote service at startup, saving the auth token for future requests. That way, we can know right away if authentication fails instead of waiting to find out when making a request. I previously enabled testing this process using Bypass, but that requires adding complexity and overhead to both the tests and the production code. I recently removed Bypass from our test suite in favor of I've also been told by some of my teammates that they've run into similar ownership issues using Mox, but I don't know the details. |
I am not sure it can be made to work. The issue is that we require each child process to set the callers themselves. So it ends up being the same as calling allow. |
Ok, I thought that might be the case. Thanks again! |
I think there are two different parts to discuss here:
So given 1. I'm with @josevalim – I don't think there is a way to make this work for any kind of process. But I wouldn't want to see 2. removed as a result of that. |
Apologies for the bad commit message, |
Thanks for the clarification! Now that I understand the situation better, I was able to come up with a pretty clean test helper setup using the new functionality. |
Uh oh!
There was an error while loading. Please reload this page.
Elixir and Erlang/OTP versions
Operating system
MacOS 14.5
Current behavior
When starting a GenServer in a test with
start_supervised/1
, the supervisor has:"$callers"
set with the test pid, but the child process does not:Expected behavior
From the discussion in #13252 and the documentation added in #13253, I expected that the child process would have
:"$callers"
populated with the test process's pid.The text was updated successfully, but these errors were encountered: