Skip to content
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

Enable mocking of sticky modules (not used by code_server) #29

Merged
merged 9 commits into from Jul 13, 2011

Conversation

MattVonVielen
Copy link
Contributor

This is a quick patch for #7 that handles the simple case mentioned there (I.E., modules not in use by code_server).

Have there been any attempts to use erlang:load_module/2 as mentioned in the initial issue, or some other solution, to allow mocking the other affected modules, especially gen_server?

If not, I'd love to give it a try myself, but I'm not yet sure I understand quite where the erlang:load_module/2 call would fit into the system, and would love some discussion on the subject.

Thanks!

@eproxus
Copy link
Owner

eproxus commented Jul 7, 2011

Good stuff.

I'd like to see an option unstick to enable this functionality. I think it's too dangerous to just unstick modules automatically.

I have not looked at using erlang:load_module/2 for this yet. I expect this patch would cover 99% of the cases, hopefully.

Damon Richardson and others added 5 commits July 7, 2011 09:26
* Renamed the field originally_sticky to was_sticky
* unsticking test module at end of test run

Matt & Damon
code:is_sticky/1 returns false when the module is not yet loaded,
even if it's in the kernel or stdlib.
@MattVonVielen
Copy link
Contributor Author

I've updated the branch and pull request with your recommended changes, as well as fixing some pretty serious flaws in my first implementation.

@eproxus
Copy link
Owner

eproxus commented Jul 8, 2011

Great stuff. I had some more picky comments. :-)

What happens when you don't use the unstick option on a sticky module? Wouldn't it make sense with a test case for that as well.

What happens when you use the unstick option with a non-sticky module? Test case for that as well? :-)

@eproxus
Copy link
Owner

eproxus commented Jul 12, 2011

Let me know if you want to add the test cases I suggested. Otherwise I can pull it into a separate branch to add them myself.

@MattVonVielen
Copy link
Contributor Author

I spent a large part of yesterday trying to get these tests written and passing, with not a lot of luck. I can't seem to meaningfully trap any errors coming out of the gen_server part of meck, even if they're just caused by init/1 returning {error, Reason} - gen_server is turning that response into an exit, and I can't get a try/catch to work for that. I would greatly appreciate it if you could handle these last couple tests.

@eproxus
Copy link
Owner

eproxus commented Jul 12, 2011

Sure, I'll look at it as soon as possible.

@eproxus eproxus merged commit 2e47f78 into eproxus:master Jul 13, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants