aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2011-01-26 20:21:34 +0100
committerLukas Larsson <[email protected]>2011-01-26 20:21:34 +0100
commit3a4ed77a4b8d29ec6889e60a56e440c7db440628 (patch)
treef6c323b58fd333f2361ff27788375800b9f0e9ce
parent8f3148df7809a67a8ebf7a9762f4c85c2611a9f3 (diff)
downloadotp-3a4ed77a4b8d29ec6889e60a56e440c7db440628.tar.gz
otp-3a4ed77a4b8d29ec6889e60a56e440c7db440628.tar.bz2
otp-3a4ed77a4b8d29ec6889e60a56e440c7db440628.zip
Update cover to allow multiple analyse and analyze_to_file calls at the same time. For each call a seperate process will be spawned to handle the request.
-rw-r--r--lib/tools/src/cover.erl86
1 files changed, 49 insertions, 37 deletions
diff --git a/lib/tools/src/cover.erl b/lib/tools/src/cover.erl
index 128aa84831..b8cb8e58cf 100644
--- a/lib/tools/src/cover.erl
+++ b/lib/tools/src/cover.erl
@@ -596,7 +596,6 @@ main_process_loop(State) ->
{From, {export,OutFile,Module}} ->
spawn(fun() ->
- io:format(user, "EXPORTING: ~p to ~p~n",[Module, OutFile]),
do_export(Module, OutFile, From, State)
end),
main_process_loop(State);
@@ -667,20 +666,11 @@ main_process_loop(State) ->
{From, {{analyse, Analysis, Level}, Module}} ->
S = try
Loaded = is_loaded(Module, State),
- analyse_info(Module,State#main_state.imported),
- C = case Loaded of
- {loaded, _File} ->
- [{Module,Clauses}] =
- ets:lookup(?COVER_TABLE,Module),
- collect(Module,Clauses,State#main_state.nodes),
- Clauses;
- _ ->
- [{Module,Clauses}] =
- ets:lookup(?COLLECTION_TABLE,Module),
- Clauses
- end,
- R = do_analyse(Module, Analysis, Level, C),
- reply(From, R),
+ spawn(fun() ->
+ do_parallel_analysis(
+ Module, Analysis, Level,
+ Loaded, From, State)
+ end),
State
catch throw:Reason ->
reply(From,{error, {not_cover_compiled,Module}}),
@@ -691,28 +681,12 @@ main_process_loop(State) ->
{From, {{analyse_to_file, OutFile, Opts},Module}} ->
S = try
Loaded = is_loaded(Module, State),
- File = case Loaded of
- {loaded, File0} ->
- [{Module,Clauses}] =
- ets:lookup(?COVER_TABLE,Module),
- collect(Module, Clauses,
- State#main_state.nodes),
- File0;
- {imported, File0, _} ->
- File0
- end,
- case find_source(File) of
- {beam,_BeamFile} ->
- reply(From, {error,no_source_code_found}),
- State;
- ErlFile ->
- analyse_info(Module,State#main_state.imported),
- HTML = lists:member(html,Opts),
- R = do_analyse_to_file(Module,OutFile,
- ErlFile,HTML),
- reply(From, R),
- State
- end
+ spawn(fun() ->
+ do_parallel_analysis_to_file(
+ Module, OutFile, Opts,
+ Loaded, From, State)
+ end),
+ State
catch throw:Reason ->
reply(From,{error, {not_cover_compiled,Module}}),
not_loaded(Module, Reason, State)
@@ -1842,6 +1816,22 @@ find_source(File0) ->
end
end.
+do_parallel_analysis(Module, Analysis, Level, Loaded, From, State) ->
+ analyse_info(Module,State#main_state.imported),
+ C = case Loaded of
+ {loaded, _File} ->
+ [{Module,Clauses}] =
+ ets:lookup(?COVER_TABLE,Module),
+ collect(Module,Clauses,State#main_state.nodes),
+ Clauses;
+ _ ->
+ [{Module,Clauses}] =
+ ets:lookup(?COLLECTION_TABLE,Module),
+ Clauses
+ end,
+ R = do_analyse(Module, Analysis, Level, C),
+ reply(From, R).
+
%% do_analyse(Module, Analysis, Level, Clauses)-> {ok,Answer} | {error,Error}
%% Clauses = [{Module,Function,Arity,Clause,Lines}]
do_analyse(Module, Analysis, line, _Clauses) ->
@@ -1918,6 +1908,28 @@ merge_functions([{_MFA,R}|Functions], MFun, Result) ->
merge_functions([], _MFun, Result) ->
Result.
+do_parallel_analysis_to_file(Module, OutFile, Opts, Loaded, From, State) ->
+ File = case Loaded of
+ {loaded, File0} ->
+ [{Module,Clauses}] =
+ ets:lookup(?COVER_TABLE,Module),
+ collect(Module, Clauses,
+ State#main_state.nodes),
+ File0;
+ {imported, File0, _} ->
+ File0
+ end,
+ case find_source(File) of
+ {beam,_BeamFile} ->
+ reply(From, {error,no_source_code_found});
+ ErlFile ->
+ analyse_info(Module,State#main_state.imported),
+ HTML = lists:member(html,Opts),
+ R = do_analyse_to_file(Module,OutFile,
+ ErlFile,HTML),
+ reply(From, R)
+ end.
+
%% do_analyse_to_file(Module,OutFile,ErlFile) -> {ok,OutFile} | {error,Error}
%% Module = atom()
%% OutFile = ErlFile = string()