Skip to content

Commit

Permalink
Started implementation, added DTD for coverage report
Browse files Browse the repository at this point in the history
  • Loading branch information
idubrov committed Sep 10, 2011
1 parent aba6e52 commit d359277
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
51 changes: 51 additions & 0 deletions covertool
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env escript
%% -*- erlang -*-

main(Args) ->
% default config
DefConfig = [{cover, "all.coverdata"},
{output, "coverage.xml"},
{sources, "src/"}],
Config = scan_args(Args, DefConfig),

CoverData = proplists:get_value(cover, Config),
io:format("Importing '~s' data file...~n", [CoverData]),
cover:import(CoverData),
io:format("Found ~w modules.~n", [length(cover:imported_modules())]),

Output = proplists:get_value(output, Config),
io:format("Writing output report '~s'...~n", [Output]),

generate_report(Output),
io:format("Done."),
ok.

usage() ->
ScriptName = escript:script_name(),
io:format("Usage: ~s [-cover CoverDataFile] [-output CoberturaXML] [-src SourcesDir]~n", [ScriptName]),
ok.

generate_report(Output) ->
ok.

% Parse arguments into tuple list
scan_args([], Args) -> Args;
scan_args([[$- | Name] | Args], Config) ->
NameAtom = list_to_atom(Name),
{Value, Args2} =
case has_arg(NameAtom) of
true when length(Args) > 0 ->
{hd(Args), tl(Args)};
true -> usage(), halt(1);
false -> {true, Args}
end,
Config2 = lists:keystore(NameAtom, 1, Config, {NameAtom, Value}),
scan_args(Args2, Config2);
scan_args(_Args, _Config) ->
usage(),
halt(1).

has_arg(cover) -> true;
has_arg(output) -> true;
has_arg(src) -> true;
has_arg(_Other) -> false.
60 changes: 60 additions & 0 deletions dtd/coverage-04.dtd
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<!-- Portions (C) International Organization for Standardization 1986:
Permission to copy in any form is granted for use with
conforming SGML systems and applications as defined in
ISO 8879, provided this notice is included in all copies.
-->

<!ELEMENT coverage (sources?,packages)>
<!ATTLIST coverage line-rate CDATA #REQUIRED>
<!ATTLIST coverage branch-rate CDATA #REQUIRED>
<!ATTLIST coverage lines-covered CDATA #REQUIRED>
<!ATTLIST coverage lines-valid CDATA #REQUIRED>
<!ATTLIST coverage branches-covered CDATA #REQUIRED>
<!ATTLIST coverage branches-valid CDATA #REQUIRED>
<!ATTLIST coverage complexity CDATA #REQUIRED>
<!ATTLIST coverage version CDATA #REQUIRED>
<!ATTLIST coverage timestamp CDATA #REQUIRED>

<!ELEMENT sources (source*)>

<!ELEMENT source (#PCDATA)>

<!ELEMENT packages (package*)>

<!ELEMENT package (classes)>
<!ATTLIST package name CDATA #REQUIRED>
<!ATTLIST package line-rate CDATA #REQUIRED>
<!ATTLIST package branch-rate CDATA #REQUIRED>
<!ATTLIST package complexity CDATA #REQUIRED>

<!ELEMENT classes (class*)>

<!ELEMENT class (methods,lines)>
<!ATTLIST class name CDATA #REQUIRED>
<!ATTLIST class filename CDATA #REQUIRED>
<!ATTLIST class line-rate CDATA #REQUIRED>
<!ATTLIST class branch-rate CDATA #REQUIRED>
<!ATTLIST class complexity CDATA #REQUIRED>

<!ELEMENT methods (method*)>

<!ELEMENT method (lines)>
<!ATTLIST method name CDATA #REQUIRED>
<!ATTLIST method signature CDATA #REQUIRED>
<!ATTLIST method line-rate CDATA #REQUIRED>
<!ATTLIST method branch-rate CDATA #REQUIRED>

<!ELEMENT lines (line*)>

<!ELEMENT line (conditions*)>
<!ATTLIST line number CDATA #REQUIRED>
<!ATTLIST line hits CDATA #REQUIRED>
<!ATTLIST line branch CDATA "false">
<!ATTLIST line condition-coverage CDATA "100%">

<!ELEMENT conditions (condition*)>

<!ELEMENT condition EMPTY>
<!ATTLIST condition number CDATA #REQUIRED>
<!ATTLIST condition type CDATA #REQUIRED>
<!ATTLIST condition coverage CDATA #REQUIRED>

0 comments on commit d359277

Please sign in to comment.