开发者

How can I get Devel::Cover results to show up in Hudson?

Is it possible to have the coverage statistics generated by Devel::Co开发者_StackOverflow中文版ver to show up in the project view in Hudson, much like the Cobertura plugin does? Even vague ideas are appreciated!


After a great deal of studying sparse documentation mixed with more than a dash of trial & error, here's a distilled version of what I came up with.

#!/usr/bin/perl -w

use strict;
use warnings;
{
    use TAP::Harness::JUnit;
    use English qw( -no_match_vars $EXECUTABLE_NAME );
}

my $harness = TAP::Harness::JUnit->new(
    {   xmlfile    => 'results.xml',
        exec       => [
            $EXECUTABLE_NAME,
            "-I/repo/trunk/PerlLib",
            '-MDevel::Cover=-silent,1,-coverage,all',
            '-w',
        ],  
        package => 'ARC::FB',
    }   
);      

$harness->runtests(
    [ "/repo/trunk/ARC/FB/Base/basic.t"             => 'Base.basic.t' ],
    [ "/repo/trunk/ARC/FB/Base/copy_file.t"         => 'Base.copy_file.t' ],
    [ "/repo/trunk/ARC/FB/Base/create_file.t"       => 'Base.create_file.t' ],
    [ "/repo/trunk/ARC/FB/Base/new.t"               => 'Base.new.t' ],
    [ "/repo/trunk/ARC/FB/Base/report.t"            => 'Base.report.t' ],
    [ "/repo/trunk/ARC/FB/Lurker/build_data_file.t" => 'Lurker.build_data_file.t' ],
    [ "/repo/trunk/ARC/FB/Lurker/cleanup.t"         => 'Lurker.cleanup.t' ],
    [ "/repo/trunk/ARC/FB/Lurker/remove_file.t"     => 'Lurker.remove_file.t' ],
    [ "/repo/trunk/ARC/FB/Lurker/write_config.t"    => 'Lurker.write_config.t' ],
    [ "/repo/trunk/ARC/FB/Sign/add_tokens.t"        => 'Sign.add_tokens.t' ], 
    [ "/repo/trunk/ARC/FB/Sign/interpret.t"         => 'Sign.interpret.t' ],
    [ "/repo/trunk/ARC/FB/Sign/new.t"               => 'Sign.new.t' ],
);  

__END__

Save the above program in /usr/local/bin/harness.pl and then configure your Jenkins job to execute this in the shell:

cover -delete

/usr/bin/perl -w /usr/local/bin/harness.pl

cover -report clover

Then add two post-build actions:

  1. Publish Clover Coverage Report (w/ directory cover_db, filename clover.xml)
  2. Publish JUnit test result report (w/ XMLs results.xml)

Save it & run it.

Key concepts:

  • Jenkins does not understand TAP (i.e. output of Perl *.t) but it does understand JUnit XML. Thus the TAP::Harness::JUnit module adds the JUnit conversion as a TAP generating TAP::Harness wrapper.
  • Devel::Cover and its options need to be given inline as part of the TAP::Harness exec parameter.
  • Devel::Cover emits mega warning noise if running with taint checking.

The JUnit converted TAP data renders well in Jenkins. However, the Clover reports are lacking the source coverage view. When you drill into the final clover report link Jenkins gives a 404 page.

This is on Jenkins ver 4.478 with Clover plugin ver 4.0.6-h-1.


Combine a custom TAP formatter like TAP::Formatter::JUnit with Devel::Cover or Devel::CoverReport's prove_cover

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜