Skip to content
Browse files

mock Module::Signature for signature.t

  • Loading branch information...
1 parent 874fcd8 commit 5062d92aa0c10a9337b65c089e10f54d16896d39 @xdg xdg committed Jan 30, 2011
Showing with 30 additions and 13 deletions.
  1. +6 −0 Changes
  2. +11 −0 t/lib/Module/Signature.pm
  3. +13 −13 t/signature.t
View
6 Changes
@@ -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
View
11 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;
View
26 t/signature.t
@@ -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');
@@ -27,6 +25,8 @@ $dist->change_build_pl
module_name => $dist->name,
license => 'perl',
sign => 1,
+ auto_configure_requires => 0,
+ quiet => 1,
});
$dist->regen;
@@ -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;
}
@@ -68,7 +66,6 @@ my $mb = Module::Build->new_from_context;
eval { $mb->dispatch('realclean') };
is $@, '';
-
{
eval {$mb->dispatch('distdir', sign => 0 )};
is $@, '';
@@ -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';
}

0 comments on commit 5062d92

Please sign in to comment.
Something went wrong with that request. Please try again.