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

Can not unload after passthrough meck #214

Closed
TC-yWu opened this issue Oct 10, 2020 · 3 comments
Closed

Can not unload after passthrough meck #214

TC-yWu opened this issue Oct 10, 2020 · 3 comments

Comments

@TC-yWu
Copy link

TC-yWu commented Oct 10, 2020

The original module can not be recovered after passthrough meck.

Reproduction Steps

  1. meck:new(my_module,[passthrough]).
  2. meck:unload().
  3. erlang:module_loaded(my_module). --> false

Expected behavior

erlang:module_loaded(my_module) return true.

Observed behavior

Here is my trace, please notice that the parameter no_passthrough_cover is expected to be a binary one.
% 14:31:26 <0.4841.0>(my_module_meck)
% meck_proc:export_original_cover(my_module, {false,no_passthrough_cover})

% 14:31:26 <0.4841.0>(my_module_meck)
% meck_proc:export_original_cover/2 -> undefined

export_original_cover(Mod, {_, Bin}) when is_binary(Bin) ->
    OriginalMod = meck_util:original_name(Mod),
    BackupCover = meck_cover:dump_coverdata(OriginalMod),
    ok = meck_cover:rename_module(BackupCover, Mod),
    BackupCover;
export_original_cover(_, _) ->
    undefined.

Versions

  • Meck version: 0.9.0
  • Erlang version: OTP 22
@eproxus
Copy link
Owner

eproxus commented Feb 17, 2021

This might be unexpected. If my_module wasn't loaded or didn't exist before mocking, this is not so strange. However, if it was loaded it could be considered a desired feature that Meck loads it back into memory the last thing it does. Currently Meck relies on Erlang to automatically load the module when it is used the next time.

@eproxus
Copy link
Owner

eproxus commented Feb 17, 2021

To clarify: the behavior for Meck has always been like this and it is not something we've considered before.

@eproxus
Copy link
Owner

eproxus commented Mar 25, 2021

This is now fixed by #228.

@eproxus eproxus closed this as completed Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants