GithubHelp home page GithubHelp logo

covertool's Introduction

Cover-to-Cobertura Conversion Tool

Build Status

Hex.pm version

A simple tool to convert exported Erlang cover data sets into Cobertura XML reports. The report could be then feed to the Jenkins Cobertura plug-in.

Plugin rename notice

This plugin is now known on Hex as covertool. Previously, it was called rebar_covertool. That package name is now retired, although it will remain compatible.

As of covertool 1.3.0, the covertool Erlang module now contains callbacks for all supported plugin formats (rebar 2, rebar3, and mix). Going forward, referencing covertool as rebar_covertool or mix_covertool in plugins is deprecated. Use covertool instead (see usage below).

This change was made to make the applications more straightforward to integrate with. See #42 for more information.

Usage

  1. Install Jenkins Cobertura Plug-in.
  2. Pick one of the options below (standalone/rebar/rebar3/mix)
  3. Configure "Publish Cobertura Coverage Report" post-build action, set path to the generated coverage.xml
  4. Run the build. At the end, "Coverage Report" link should appear on project page.

Standalone

  1. Build command line script (WARNING: EUnit test for plugin may fail for OTP =< 17.3, due to a bug in cover app)

     $ make
    
  2. Configure cover to export data. Sample cover.spec for Common Test:

     {incl_app, app0, details}.
     {export, "all.coverdata"}.
    
  3. Configure Jenkins to convert cover reports into Cobertura format:

     $ covertool -cover all.coverdata -output coverage.xml -src src/
    

Rebar

Configure rebar to generate reports in Cobertura format:

{deps, [
    {covertool, "", {git, "https://github.com/covertool/covertool.git", {branch, master}}}
]}.
{plugins, [covertool]}.
{cover_export_enabled, true}.
{covertool_eunit, {".eunit/eunit.coverdata", "eunit.coverage.xml"}}. % Source file name, output report file name
{covertool_ct, {"ct.coverdata", "ct.coverage.xml"}}. % Source file name, output report file name
{covertool_prefix_len, 2}. % Optional: include the module prefix in the package name

The covertool_prefix_len option allows including the first n sections of the '_'-delimited module name in the package name. For example, with a covertool_prefix_len of 2 and a module named app0_worker_srv_sup, the term app0.worker would be added to the end of the package name. Defaults to 0 (no module prefix included).

Rebar3

Configure rebar3 to generate reports in Cobertura format:

{project_plugins, [covertool]}.
% Alternate form (w/o Hex):
% {project_plugins, [
%     {covertool, {git, "https://github.com/covertool/covertool.git", {branch, "master"}}}
% ]}.
{cover_export_enabled, true}.
{covertool, [{coverdata_files, ["ct.coverdata", "eunit.coverdata"]},
             {include_apps, [dep0, dep1]},
             {prefix_len, 2}]}. % Optional: Use module prefix as (imaginary) package name

The include_apps option allows specifying a list of dependent OTP applications to include in the coverage export (default: []). Note that the coverage data must be included in the input .coverdata file in order for any values to be populated in the output XML file. This can be done using the ct cover spec file.

The include_apps option can also be specified via the command line as a CSV of application names, e.g.:

rebar3 covertool generate -a"dep0,dep1"

The prefix_len option allows including the first n sections of the '_'-delimited module name in the package name. For example, with a prefix_len of 2 and a module named app0_worker_srv_sup, the term app0.worker would be added to the end of the package name. Defaults to 0 (no module prefix included). This option can also be specified via the command line, e.g.:

rebar3 covertool generate -p2

Mix

Configure mix to generate reports in Cobertura format:

def project do
  [
    test_coverage: [tool: :covertool]
  ]
end

If you need, then you can add summary: true to print summary on the standard output. Useful in CI tools that can extract total coverage from there.

Screenshots

Screenshot1

Screenshot2

covertool's People

Contributors

albertored avatar antoinegagne avatar binarin avatar chrisavl avatar cypherfox avatar ddosia avatar djui avatar efine avatar fenek avatar fishliver avatar fp avatar gwre-ivan avatar hauleth avatar idubrov avatar lauramcastro avatar marcelog avatar markusn avatar nalundgaard avatar petrkozorezov avatar rlipscombe avatar sebastien-guay avatar shino avatar sylane avatar tsloughter avatar tverlaan avatar vkatsuba avatar voluntas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

covertool's Issues

coverdata is imported twice

When running as an escript, coverdata files are imported twice. The first time is in main/1 and the second time in generate_report/2. This causes the following ugly printout:

Importing 'cover/eunit.coverdata' data file...
Found 17 modules.
WARNING: Module xxx already imported from "/home/viktor/blabla/cover/eunit.coverdata"
Not importing again!
WARNING: Module yyy already imported from "/home/viktor/blabla/cover/eunit.coverdata"
Not importing again!

(and so on, repeated for every module)

Proposal: rename package on hex.pm

I would like to propose to rename the package on hex.pm to covertool. Very often the name of the package on hex is the same as the application name. This is actually my first encounter where it's different. Also, the current name suggests it's specifically for rebar which it isn't anymore :-).

With mix you usually write your dependency like this: {:covertool, "~> 1.2"}
The current name requires you to specify the app name as well: {:covertool, "~> 1.2", hex: :rebar_covertool}
With rebar I think it's similar, although I don't know if people are used to that.

On hex we can retire a package with the reason renamed and point people to the new package name. That would help people in moving over.

I'd like to know how others feel about this before submitting a PR.

Rebar3 support

I suppose it would have to be a separate project, but is rebar3 support planned?

Accept full input paths

I'll try to put a PR together but wanted to open this first in case I'm missing something.

It looks like covertool will always prepend _build/test/cover/ to the path to cover data. This won't always be the case.

I think what you want is to have covertool run in the test profile and use rebar_dir:base_dir which would then return _build/test, or in my case it'll return _build/ci+test/.

It also seems to hardcode what the file names can be. Rebar3 supports an option cover_export_name for CT to output to different names depending on the run. So the rebar3 plugin should accept a list of cover data files to include.

Fails when 'compile_info' doesn't have 'source' key in it

I've got some beam files in my project that are built from raw terms -- see https://github.com/rlipscombe/mix_embed_binaries/blob/master/lib/mix_embed_binaries.ex#L44 -- , and they don't have a 'source' key in them. This causes covertool to fail with the following:

escript: exception error: no function clause matching lists:prefix("src/",undefined) (lists.erl, line 192)
  in function  covertool:relative_to_src_path/2 (src/covertool.erl, line 312)
  in call from covertool:package_name/3 (src/covertool.erl, line 169)
  in call from covertool:'-generate_packages/3-fun-0-'/4 (src/covertool.erl, line 145)
  in call from lists:foldl/3 (lists.erl, line 1263)
  in call from covertool:generate_packages/3 (src/covertool.erl, line 144)
  in call from covertool:generate_report/2 (src/covertool.erl, line 118)
  in call from covertool:main/1 (src/covertool.erl, line 36)

`badmatch` error in OTP-21

By using OTP-21 and this plugin (v1.2.0), I encountered the following error (build log):

$ git clone https://github.com/sile/jsone.git
$ cd jsone/
$ ./rebar3 eunit
$ ./rebar3 cover
$ DEBUG=1 ./rebar3 as test covertool generate
Generating report '/home/travis/build/sile/jsone/_build/test/covertool/jsone.covertool.xml'...
===> Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace or consult rebar3.crashdump
===> Uncaught error: {badmatch,"0.285714"}
===> Stack trace to the error location:
[{covertool,rate,1,
            [{file,"/home/travis/build/sile/jsone/_build/test/plugins/rebar_covertool/src/covertool.erl"},
             {line,259}]},
 {covertool,generate_class,1,
            [{file,"/home/travis/build/sile/jsone/_build/test/plugins/rebar_covertool/src/covertool.erl"},
             {line,207}]},
 {covertool,'-generate_classes/1-fun-0-',2,
            [{file,"/home/travis/build/sile/jsone/_build/test/plugins/rebar_covertool/src/covertool.erl"},
             {line,172}]},
 {lists,mapfoldl,3,[{file,"lists.erl"},{line,1354}]},
 {covertool,generate_classes,1,
            [{file,"/home/travis/build/sile/jsone/_build/test/plugins/rebar_covertool/src/covertool.erl"},
             {line,184}]},
 {covertool,generate_package,2,
            [{file,"/home/travis/build/sile/jsone/_build/test/plugins/rebar_covertool/src/covertool.erl"},
             {line,160}]},
 {covertool,'-generate_packages/3-fun-1-',2,
            [{file,"/home/travis/build/sile/jsone/_build/test/plugins/rebar_covertool/src/covertool.erl"}
             {line,126}]},
 {lists,mapfoldl,3,[{file,"lists.erl"},{line,1354}]}]

The expression io_lib:format("~f", [Covered / Valid]) at covertool.erl#L259 seems to return ["0.285714"] in OTP-20, but return "0.285714" in OTP-21.

Rebar issue

I wasn't able to build because i have a different rebar @ my machine. And the rebar used to make compile is pointing to it....

At your Makefile

@$(REBAR) compile escriptize

Should be

./deps/rebar/rebar compile escriptize

Bests.

"line" data in "result" record is lost in generate_package(...)

I have an issue while using covertool on my ct.coverdata file. Each XML files for all my Erlang apps have line-rate="0" lines-covered="0".

It seems that the data is lost at line 196 in generate_package(..).
It should return Classes#result{data = Data}. instead of #result{data = Data}

License of source codes

Hi,

I want to use and/or contribute to some part of code in covertool.
So whould you tell me the license for this library?

Rebar messing the code path

I have covertool as a dependency, it brings rebar as well.
I have locally installed rebar, which I use to build software.
For some reasons whenever I try to build my project(which depends on covertool), I have weird compilation issues: it puts "deps/rebar" in codepath earlier than my rebar. Thus new rebar calls modules from "deps/rebar" and a lot of "error:undef" as result.
Not quite sure is this problem of rebar? Do you guys have an advice?

Include all project apps

Does covertool not include all applications in a project by default? I noticed that regular cover has all the apps of a project I'm working on in it but the result of covertool gen and reporting to codecov I find it only has 1 applications in the coverage. So trying to find where the information is getting dropped.

`make` doesn't actually work?

With rebar in $PATH:

$ make
==> covertool (get-deps)
==> covertool (update-deps)
make -C deps/rebar
make[1]: *** deps/rebar: No such file or directory. Stop.
Makefile:11: recipe for target 'deps' failed
make: *** [deps] Error 2

I had to rebar compile && rebar escript.

undefined function elixir_erl:debug_info/4

Googling for the above error gets me to josefs/Gradualizer#73 (comment), which suggests that I "didn't link in the Elixir library location".

This makes some kind of sense: I'm compiling a mixed Erlang/Elixir project, and covertool is dying on the Elixir part with the above error. How do I tell covertool about the "Elixir library location"?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.