Skip to content

Commit

Permalink
Expose concuerror_loader:load_binary/3
Browse files Browse the repository at this point in the history
This will allow to provide hack for implementing support for ExUnit
tests which are composed of dynamically generated modules (see parapluu#299).
  • Loading branch information
hauleth committed Jan 11, 2019
1 parent 053cfed commit 0424af2
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/concuerror_loader.erl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%%% @private
-module(concuerror_loader).

-export([initialize/1, load/1, load_initially/1, is_instrumenting/0]).
-export([initialize/1, load/1, load_initially/1, load_binary/3, is_instrumenting/0]).

%%------------------------------------------------------------------------------

Expand Down Expand Up @@ -136,16 +136,11 @@ set_is_instrumenting(Value) ->

%%------------------------------------------------------------------------------

get_instrumented_table() ->
concuerror_instrumented.
-spec load_binary(module(), string(), binary()) -> {ok, [iodata()]}.

check_shadow(File, Module) ->
Default = code:which(Module),
case Default =:= non_existing of
true -> [];
false ->
[io_lib:format("File ~s shadows ~s (found in path)", [File, Default])]
end.
load_binary(Module, Filename, Beam) ->
Instrumented = get_instrumented_table(),
load_binary(Module, Filename, Beam, Instrumented).

load_binary(Module, Filename, Beam, Instrumented) ->
Core = get_core(Beam),
Expand All @@ -162,6 +157,19 @@ load_binary(Module, Filename, Beam, Instrumented) ->
{module, Module} = code:load_binary(Module, Filename, NewBinary),
{ok, Warnings}.

%%------------------------------------------------------------------------------

get_instrumented_table() ->
concuerror_instrumented.

check_shadow(File, Module) ->
Default = code:which(Module),
case Default =:= non_existing of
true -> [];
false ->
[io_lib:format("File ~s shadows ~s (found in path)", [File, Default])]
end.

get_core(Beam) ->
{ok, {Module, [{abstract_code, ChunkInfo}]}} =
beam_lib:chunks(Beam, [abstract_code]),
Expand Down

0 comments on commit 0424af2

Please sign in to comment.