Skip to content

Commit

Permalink
mock Module::Signature for signature.t
Browse files Browse the repository at this point in the history
  • Loading branch information
xdg committed Jan 31, 2011
1 parent 874fcd8 commit 5062d92
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
6 changes: 6 additions & 0 deletions Changes
Expand Up @@ -2,6 +2,12 @@ Revision history for Perl extension Module::Build.

0.37_01 -

[BUG FIXES]

- t/signature.t now uses a mocked Module::Signature; this should be
more robust across platforms as it only needs to confirm that
Module::Build is calling Module::Signature when expected

0.3624 - Thu Jan 27 11:38:39 EST 2011

- Fixed pod2html directory bugs and fixed creation of spurious blib
Expand Down
11 changes: 11 additions & 0 deletions t/lib/Module/Signature.pm
@@ -0,0 +1,11 @@
package Module::Signature; # mocked
use strict;
use warnings;
our $VERSION = 999;

sub sign {
open my $fh, ">", "SIGNATURE";
print {$fh} "SIGNATURE";
}

1;
26 changes: 13 additions & 13 deletions t/signature.t
Expand Up @@ -4,14 +4,12 @@ use strict;
use lib 't/lib';
use MBTest;

if ( $ENV{TEST_SIGNATURE} ) {
if ( have_module( 'Module::Signature' ) ) {
plan tests => 13;
} else {
plan skip_all => '$ENV{TEST_SIGNATURE} is set, but Module::Signature not found';
}
if ( have_module( 'Module::Signature' )
&& $INC{'Module/Signature.pm'} =~ m{t/lib/Module/Signature\.pm}
) {
plan tests => 12;
} else {
plan skip_all => '$ENV{TEST_SIGNATURE} is not set';
plan skip_all => "Mock Module::Signature not loadable";
}

blib_load('Module::Build');
Expand All @@ -27,6 +25,8 @@ $dist->change_build_pl
module_name => $dist->name,
license => 'perl',
sign => 1,
auto_configure_requires => 0,
quiet => 1,
});
$dist->regen;

Expand All @@ -36,15 +36,13 @@ $dist->chdir_in;

my $mb = Module::Build->new_from_context;


{
eval {$mb->dispatch('distdir')};
is $@, '';
my $err = $@;
is $err, '';
chdir( $mb->dist_dir ) or die "Can't chdir to '@{[$mb->dist_dir]}': $!";
ok -e 'SIGNATURE';

# Make sure the signature actually verifies
ok Module::Signature::verify() == Module::Signature::SIGNATURE_OK();
$dist->chdir_in;
}

Expand All @@ -68,7 +66,6 @@ my $mb = Module::Build->new_from_context;
eval { $mb->dispatch('realclean') };
is $@, '';


{
eval {$mb->dispatch('distdir', sign => 0 )};
is $@, '';
Expand All @@ -86,14 +83,17 @@ $dist->chdir_in;
$dist->change_build_pl({
module_name => $dist->name,
license => 'perl',
auto_configure_requires => 0,
quiet => 1,
});
$dist->regen;

my $mb = Module::Build->new_from_context;
is $mb->{properties}{sign}, 1;

eval {$mb->dispatch('distdir')};
is $@, '';
my $err = $@;
is $err, '';
chdir( $mb->dist_dir ) or die "Can't chdir to '@{[$mb->dist_dir]}': $!";
ok -e 'SIGNATURE', 'Build.PL --sign=1 signs';
}
Expand Down

0 comments on commit 5062d92

Please sign in to comment.