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

Meck doesn't support modules built with '+deterministic' compile option #184

Closed
nablaa opened this issue Nov 21, 2017 · 1 comment · Fixed by #185
Closed

Meck doesn't support modules built with '+deterministic' compile option #184

nablaa opened this issue Nov 21, 2017 · 1 comment · Fixed by #185

Comments

@nablaa
Copy link
Contributor

nablaa commented Nov 21, 2017

Running meck against modules built with +deterministic compile option fails with the following stacktrace:

::{function_clause,[{lists,'-filter/2-lc$^0/1-0-',
                           [undefined],
                           [{file,"lists.erl"},{line,1286}]},
                    {meck_proc,backup_original,3,
                               [{file,"/home/foobar/meck/_build/default/lib/meck/src/meck_proc.erl"},
                                {line,361}]},
                    {meck_proc,init,1,
                               [{file,"/home/foobar/meck/_build/default/lib/meck/src/meck_proc.erl"},
                                {line,206}]},
                    {gen_server,init_it,2,
                                [{file,"gen_server.erl"},{line,365}]},
                    {gen_server,init_it,6,[{file,[...]},{line,...}]},
                    {proc_lib,init_p_do_apply,3,[{file,...},{...}]}]}

This is caused by the fact that the module doesn't have compile options in module_info/1:

$ cat foo.erl
-module(foo).
$ erlc foo.erl
$ erl -noshell -eval 'io:format("~p~n", [foo:module_info(compile)])' -run init stop
[{options,[]},
{version,"7.1.1"},
{source,"/home/foobar/foo.erl"}]
$ rm foo.beam
$ erlc +deterministic foo.erl
$ erl -noshell -eval 'io:format("~p~n", [foo:module_info(compile)])' -run init stop
[{version,"7.1.1"}]

Reproduction Steps

Run meck against modules built with +deterministic option.

Expected behavior

Meck should run against modules built with +deterministic.

Versions

  • Meck version: a1f83d3
  • Erlang version: OTP/20
nablaa added a commit to nablaa/meck that referenced this issue Nov 21, 2017
… option

When modules are built with '+deterministic' option, the BEAM files
don't have compile options available in the module_info/1:

    $ cat foo.erl
    -module(foo).
    $ erlc foo.erl
    $ erl -noshell -eval 'io:format("~p~n", [foo:module_info(compile)])' -run init stop
    [{options,[]},
    {version,"7.1.1"},
    {source,"/home/foobar/foo.erl"}]
    $ rm foo.beam
    $ erlc +deterministic foo.erl
    $ erl -noshell -eval 'io:format("~p~n", [foo:module_info(compile)])' -run init stop
    [{version,"7.1.1"}]

Running meck against these modules fail:

    ::{function_clause,[{lists,'-filter/2-lc$^0/1-0-',
                               [undefined],
                               [{file,"lists.erl"},{line,1286}]},
                        {meck_proc,backup_original,3,
                                   [{file,"/home/foobar/meck/_build/default/lib/meck/src/meck_proc.erl"},
                                    {line,361}]},
                        {meck_proc,init,1,
                                   [{file,"/home/foobar/meck/_build/default/lib/meck/src/meck_proc.erl"},
                                    {line,206}]},
                        {gen_server,init_it,2,
                                    [{file,"gen_server.erl"},{line,365}]},
                        {gen_server,init_it,6,[{file,[...]},{line,...}]},
                        {proc_lib,init_p_do_apply,3,[{file,...},{...}]}]}

This commit fixes the problem.

Fixes eproxus#184:
eproxus#184
nablaa added a commit to nablaa/meck that referenced this issue Nov 21, 2017
… option

When modules are built with '+deterministic' option, the BEAM files
don't have compile options available in the module_info/1:

    $ cat foo.erl
    -module(foo).
    $ erlc foo.erl
    $ erl -noshell -eval 'io:format("~p~n", [foo:module_info(compile)])' -run init stop
    [{options,[]},
    {version,"7.1.1"},
    {source,"/home/foobar/foo.erl"}]
    $ rm foo.beam
    $ erlc +deterministic foo.erl
    $ erl -noshell -eval 'io:format("~p~n", [foo:module_info(compile)])' -run init stop
    [{version,"7.1.1"}]

Running meck against these modules fail:

    ::{function_clause,[{lists,'-filter/2-lc$^0/1-0-',
                               [undefined],
                               [{file,"lists.erl"},{line,1286}]},
                        {meck_proc,backup_original,3,
                                   [{file,"/home/foobar/meck/_build/default/lib/meck/src/meck_proc.erl"},
                                    {line,361}]},
                        {meck_proc,init,1,
                                   [{file,"/home/foobar/meck/_build/default/lib/meck/src/meck_proc.erl"},
                                    {line,206}]},
                        {gen_server,init_it,2,
                                    [{file,"gen_server.erl"},{line,365}]},
                        {gen_server,init_it,6,[{file,[...]},{line,...}]},
                        {proc_lib,init_p_do_apply,3,[{file,...},{...}]}]}

This commit fixes the problem.

Fixes eproxus#184
@nablaa
Copy link
Contributor Author

nablaa commented Nov 21, 2017

Fix in this pull request: #185

eproxus pushed a commit that referenced this issue Nov 27, 2017
… option

When modules are built with '+deterministic' option, the BEAM files
don't have compile options available in the module_info/1:

    $ cat foo.erl
    -module(foo).
    $ erlc foo.erl
    $ erl -noshell -eval 'io:format("~p~n", [foo:module_info(compile)])' -run init stop
    [{options,[]},
    {version,"7.1.1"},
    {source,"/home/foobar/foo.erl"}]
    $ rm foo.beam
    $ erlc +deterministic foo.erl
    $ erl -noshell -eval 'io:format("~p~n", [foo:module_info(compile)])' -run init stop
    [{version,"7.1.1"}]

Running meck against these modules fail:

    ::{function_clause,[{lists,'-filter/2-lc$^0/1-0-',
                               [undefined],
                               [{file,"lists.erl"},{line,1286}]},
                        {meck_proc,backup_original,3,
                                   [{file,"/home/foobar/meck/_build/default/lib/meck/src/meck_proc.erl"},
                                    {line,361}]},
                        {meck_proc,init,1,
                                   [{file,"/home/foobar/meck/_build/default/lib/meck/src/meck_proc.erl"},
                                    {line,206}]},
                        {gen_server,init_it,2,
                                    [{file,"gen_server.erl"},{line,365}]},
                        {gen_server,init_it,6,[{file,[...]},{line,...}]},
                        {proc_lib,init_p_do_apply,3,[{file,...},{...}]}]}

This commit fixes the problem.

Fixes #184
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant