eproxus / meck

A mocking library for Erlang
http://eproxus.github.io/meck
Apache License 2.0
811 stars 231 forks source link

Fix compile forms error when mock up both behaviour_info and its callback modules (by filter out option) #63

Closed shino closed 12 years ago

shino commented 12 years ago

When mock up both behaviour_info and its callback modules, an error(precisely speaking, a waning) occurs when compiling a callback module to backup it.

  1. When compiling a callback module, compiler can not find behaviour_info/1 since it is already mocked away.
  2. If warnings_as_errors exists in compile options, the warning turns into an error.

In this pull request, I filter out the warnings_as_errors option when backup original module. I think this has no drawbacks because warnings are treated before eunit runs.

PS: #64 is an altenative fix for the same error.

eproxus commented 12 years ago

The test case would pass if written like this:

meck_behaviour_info_module_test() ->
    ?assertEqual(ok, meck:new(meck_test_behaviour_info_module), [passthrough]),
    ?assertEqual(ok, meck:new(meck_test_behaviour_callback_module)),
    ?assertEqual(ok, meck:unload(meck_test_behaviour_info_module)),
    ?assertEqual(ok, meck:unload(meck_test_behaviour_callback_module)).

I think this is an okay prerequisite, is it not?

Another modification would be to change meck_mod to return a full list of compilation errors instead of just error to help debug such errors.

shino commented 12 years ago

I think this is an okay prerequisite, is it not?

It's nice! Tests run and succeed with passthrough. Thank you for so simple advice!

Close this issue because it's useless.

Thanks again.

shino commented 12 years ago

Another modification would be to change meck_mod to return a full list of compilation errors instead of just error to help debug such errors.

Looking for the cause of this error was rather troublesome. I will try this modification when I have time :-)

P.S. I found you fixed already 60e5734f . Thanks once more :-)

eproxus commented 12 years ago

5bc12e47fbb212e6f82bb744e58abe2b661c36f3 will show more compilation errors than before, it's in 0.7.2.

shino commented 12 years ago

Oops, commit hash in my comment were wrong... Thanks for right commit hash.

eproxus commented 12 years ago

No problem, just let me know if you have any additional issues with this.