Created
November 25, 2009 16:31
-
-
Save dams/242848 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Module::Build; | |
my $class = Module::Build->subclass( | |
class => "Module::Build::Custom", | |
code => <<'SUBCLASS' ); | |
sub ACTION_hudson_test { | |
my $self = shift; | |
$self->depends_on("build"); | |
# set hudson mode | |
$self->{HUDSON_MODE} = 1; | |
$self->generic_test(type => 'default'); | |
} | |
sub do_tests { | |
my $self = shift; | |
# if we are not running for Hudson, just execute normal test routine (parent) | |
$self->{HUDSON_MODE} | |
or return $self->SUPER::do_tests($self, @_); | |
# We are in Hudson mode, use TAP::Harness::JUnit | |
my $tests = $self->find_test_files; | |
if(@$tests) { | |
$self->run_tap_harness_JUnit($tests); | |
} else { | |
$self->log_info("No tests defined.\n"); | |
} | |
} | |
sub run_tap_harness_JUnit { | |
my ($self, $tests) = @_; | |
print "------ JUnit tap harness \n"; | |
require TAP::Harness::JUnit; | |
my $harness = TAP::Harness::JUnit->new({ | |
xmlfile => 'hudson_test_output.xml', | |
merge => 1, | |
lib => [@INC], | |
verbosity => $self->{properties}{verbose}, | |
switches => [ $self->harness_switches ], | |
%{ $self->tap_harness_args }, | |
})->runtests(@$tests); | |
} | |
SUBCLASS | |
# here, instead of instantiating from Module::Build, we use our new class | |
my $builder = $class->new( | |
module_name => 'My::Module', | |
# ... the rest as usual | |
); | |
$builder->create_build_script(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment