File Coverage

lib/Module/Build/TAPArchive.pm
Criterion Covered Total %
statement 21 21 100.0
branch n/a
condition 1 2 50.0
subroutine 6 6 100.0
pod 0 1 0.0
total 28 30 93.3


line stmt bran cond sub pod time code
1             package Module::Build::TAPArchive;
2 2     2   29190 use warnings;
  2         4  
  2         63  
3 2     2   10 use strict;
  2         4  
  2         68  
4 2     2   9 use base 'Module::Build';
  2         8  
  2         5849  
5 2     2   260302 use TAP::Harness::Archive;
  2         238277  
  2         458  
6              
7             our $VERSION = '0.04';
8              
9             __PACKAGE__->add_property(archive_file => 'test_archive.tar.gz');
10              
11             =head1 NAME
12              
13             Module::Build::TAPArchive - Extra build targets for creating TAP archives
14              
15             =head1 SYNOPSIS
16              
17             Easily add support for extra build targets that create TAP archives of the tests.
18              
19             In your Build.PL
20              
21             use Module::Builder::TAPArchive;
22             my $builder = Module::Builder::TAPArchive->new(
23             ...
24             );
25              
26             Now you get these build targets
27              
28             ]$ perl Build.PL
29             ]$ ./Build test_archive
30              
31             =head1 NEW TARGETS
32              
33             The following build targets are provided:
34              
35             =head2 test_archive
36              
37             Create a TAP archive to the test run. This archive is placed at
38             F in the current directory by default. You can override this by
39             specifying the C<--archive_file> parameter.
40              
41             ./Build test_archive --archive_file mytests.tar.gz
42              
43             =cut
44              
45             sub ACTION_test_archive {
46 1     1 0 102269 my $self = shift;
47 1         14 $self->{properties}{use_tap_harness} = 1;
48 1   50     26 my $archive_file = $self->{properties}{archive_file} || 'test_archive.tar.gz';
49              
50             # make Module::Build use our archive method instead of run_tap_harness
51             local *Module::Build::run_tap_harness = sub {
52 1     1   1325 my ($self, $tests) = @_;
53 1         9 TAP::Harness::Archive->new(
54             {
55             lib => \@INC,
56             verbosity => $self->{properties}{verbose},
57             switches => [$self->harness_switches],
58             archive => $archive_file,
59 1         21 %{$self->tap_harness_args},
60             }
61             )->runtests(@$tests);
62 1         19 };
63 1         39 $self->add_to_cleanup($archive_file);
64 1         250 $self->generic_test(type => 'default');
65             }
66              
67              
68             =head1 AUTHOR
69              
70             Michael Peters, C<< >>
71              
72             =head1 BUGS
73              
74             Please report any bugs or feature requests to C, or through
75             the web interface at L. I will be notified, and then you'll
76             automatically be notified of progress on your bug as I make changes.
77              
78             =head1 SUPPORT
79              
80             You can find documentation for this module with the perldoc command.
81              
82             perldoc Module::Build::TAPArchive
83              
84             You can also look for information at:
85              
86             =over 4
87              
88             =item * RT: CPAN's request tracker
89              
90             L
91              
92             =item * AnnoCPAN: Annotated CPAN documentation
93              
94             L
95              
96             =item * CPAN Ratings
97              
98             L
99              
100             =item * Search CPAN
101              
102             L
103              
104             =back
105              
106             =head1 COPYRIGHT & LICENSE
107              
108             Copyright 2009 Michael Peters, all rights reserved.
109              
110             This program is free software; you can redistribute it and/or modify it
111             under the same terms as Perl itself.
112              
113             =cut
114              
115             1;