Support running meck with modules built with '+deterministic' compile option
authorMiika-Petteri Matikainen <miikapetteri@gmail.com>
Tue, 21 Nov 2017 06:56:46 +0000 (08:56 +0200)
committerAdam Lindberg <hello@alind.io>
Mon, 27 Nov 2017 11:48:49 +0000 (12:48 +0100)
commit32e62908a9670f316648e6a68467f3f177b81a61
tree514d13bb88b05b61536f0bce1e9c3b99b7853c10
parenta1f83d3a33642c30df05a79520aa7397712a76bc
Support running meck with modules built with '+deterministic' compile 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 https://github.com/eproxus/meck/issues/184
src/meck_code.erl