Skip to content

Commit

Permalink
Merge remote branch 'klaar/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Mullis committed Mar 26, 2010
2 parents a1d658b + adc8239 commit e3bd990
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/coverize.erl
Expand Up @@ -7,6 +7,7 @@
-module(coverize).
-author("michael@mullistechnologies.com").
-export([run/2,run/4,run/5]).
-export([module_summary_file/1]).

%% Wrapper for cover to make command line calling easy
-spec(run/2 :: (list(string()), atom()) -> ok).
Expand Down Expand Up @@ -79,8 +80,8 @@ dump_coverage(OutputDir, SummaryFile, [Module|RemainingModules], Acc, {TotCovere
end,

io:fwrite(SummaryFile,
"<tr style=~p><td><a href=\"~p.COVER.html\">~p</a></td><td style=\"text-align: right\">~p</td><td style=\"text-align: right\">~p</td><td style=\"text-align: center\">~p</td></tr>~n",
[BackgroundStyle,Module,Module,CoveredLines,UncoveredLines, calc_percentage(CoveredLines,UncoveredLines)]),
"<tr style=~p><td><a href=\"~s\">~p</a></td><td style=\"text-align: right\">~p</td><td style=\"text-align: right\">~p</td><td style=\"text-align: center\">~p</td></tr>~n",
[BackgroundStyle,module_summary_file(Module),Module,CoveredLines,UncoveredLines, calc_percentage(CoveredLines,UncoveredLines)]),

dump_coverage(OutputDir, SummaryFile, RemainingModules, Acc2, TotalsAcc2);

Expand All @@ -92,3 +93,6 @@ calc_percentage(0,_UncoveredLines) -> 0;
calc_percentage(_,0) -> 100;
calc_percentage(CoveredLines,UncoveredLines) ->
round((CoveredLines / (CoveredLines+UncoveredLines)) * 100).

module_summary_file(ModuleName) ->
atom_to_list(ModuleName) ++ ".COVER.html".
11 changes: 11 additions & 0 deletions test/src/simple_test.erl
Expand Up @@ -9,3 +9,14 @@
basic_test_() ->
[?_assertEqual(" ", " " )
].

-spec mod_summary_file_test_() -> [{integer(),fun(() -> 'ok')},...].
mod_summary_file_test_() ->
F = fun coverize:module_summary_file/1,
% With top level erlang modules
[?_assertEqual("lists.COVER.html", F(lists)),
?_assertEqual("q.COVER.html", F(q)),
% With a module contained within an erlang package
?_assertEqual("foo.bar.COVER.html", F(foo.bar)),
?_assertEqual("a.b_c.COVER.html", F(a.b_c))
].

0 comments on commit e3bd990

Please sign in to comment.