-
-
Notifications
You must be signed in to change notification settings - Fork 231
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
{:error, {:no_abstract_code, ...}}
with Elixir 1.5.0-rc.0 and Erlang 20.0
#179
Comments
Thanks for the detailed bug report! It seems Mock is running with an older version of Meck, before Erlang 20+ compatibility fixes were added. Can you try to override Meck to version |
Sorry, I wrote the wrong version (I was using meck via the Elixir |
Possibly related: a |
Preliminary analysis points to that the module |
$ iex -pa _build/test/lib/meck_test/ebin -e 'IO.inspect MeckTest.module_info' -e System.halt
Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]
[module: MeckTest,
exports: [__info__: 1, hello: 0, module_info: 0, module_info: 1],
attributes: [vsn: [97807801047081573425803547081250957748]],
compile: [options: [], version: '7.1',
source: '/private/tmp/meck_test/lib/meck_test.ex'], native: false,
md5: <<73, 149, 24, 231, 139, 253, 152, 246, 234, 96, 23, 219, 28, 103, 233,
180>>] It should be |
Tried to use the option @josevalim @ericmj Any ideas? Did something change in Elixir 1.5.0 that modifies compiler options? |
@eproxus on OTP 20, we use the long |
To be more precise, what do |
Ok, since @paulswartz was awesome and provided all mechanism to reproduce this issue, I decided to give it a try. The chunk is definitely there: $ elixir -pa _build/test/lib/meck_test/ebin -e "IO.inspect :beam_lib.chunks :code.which(MeckTest), [:abstract_code]"
{:ok,
{MeckTest,
[abstract_code: {:raw_abstract_v1, Now to find the misbehaving parts. |
@josevalim Thanks for looking into it so quickly! Didn't know about the new extended
In this bug, I think the error comes from %% Beam is a binary or a .beam file name
do_compile_beam1(Module,Beam,UserOptions) ->
%% Clear database
do_clear(Module),
%% Extract the abstract format and insert calls to bump/6 at
%% every executable line and, as a side effect, initiate
%% the database
case get_abstract_code(Module, Beam) of
no_abstract_code=E ->
{error,E};
encrypted_abstract_code=E ->
{error,E};
{raw_abstract_v1,Code} ->
Forms0 = epp:interpret_file_attribute(Code),
case find_main_filename(Forms0) of
{ok,MainFile} ->
do_compile_beam2(Module,Beam,UserOptions,Forms0,MainFile);
Error ->
Error
end;
{_VSN,_Code} ->
%% Wrong version of abstract code. Just report that there
%% is no abstract code.
{error,no_abstract_code}
end.
get_abstract_code(Module, Beam) ->
case beam_lib:chunks(Beam, [abstract_code]) of
{ok, {Module, [{abstract_code, AbstractCode}]}} ->
AbstractCode;
{error,beam_lib,{key_missing_or_invalid,_,_}} ->
encrypted_abstract_code;
Error -> Error
end. |
Nevermind, PATH problems. Your example works fine. |
Figured out what happens, I think. Meck just takes |
Yes, from OTP 20, the debug_info option is just one way of attaching debug_info. Strictly speaking, that was also true in previous versions, since a chunk can be attached at any time, but I guess nobody relied on that. |
@josevalim I'm having a bit of trouble understanding how to reliably detect if ErlangWithout options:
With
ElixirWithout options:
With
The only difference I see for Elixir is the |
@eproxus let's take a step back. Why do you need to detect if debug_info has been used? Asking for the abstract_code should work just fine and be completely transparent for you. |
Good point, but I'm not sure. In this case it is
The procedure so far has been to copy the compilation options from the original module, assuming that's the "only" way to get it compiled as originally intended. Not sure how to treat the new |
That's what |
Yeah, makes sense. Thanks for all your input, it has been very helpful! |
eproxus/meck#179 was fixed in the most recent meck release, this should unbreak mock for users with elixir 1.5 / OTP 20 meck PR here: eproxus/meck#180
After updating to the latest RC of Elixir, I started seeing errors when running my test with coverage enabled. It only appears to happen on 1.5.0-rc.0 /and/ 20.0: Elixir 1.4.5 or Erlang 19.3 are okay.
Repo: https://github.com/paulswartz/meck_test
Travis CI builds: https://travis-ci.org/paulswartz/meck_test
Reproduction Steps
git clone https://github.com/paulswartz/meck_test.git
cd meck_test
mix deps.get
mix test --cover
Expected behavior
Observed behavior
Versions
The text was updated successfully, but these errors were encountered: