4 use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
7 if ( $ENV{TEST_SIGNATURE} ) {
8 if ( have_module( 'Module::Signature' ) ) {
11 plan skip_all => '$ENV{TEST_SIGNATURE} is set, but Module::Signature not found';
14 plan skip_all => '$ENV{TEST_SIGNATURE} is not set';
17 #########################
21 my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' );
24 my $dist = DistGen->new( dir => $tmp );
25 $dist->change_file( 'Build.PL', <<"---" );
28 my \$build = new Module::Build(
29 module_name => @{[$dist->name]},
33 \$build->create_build_script;
37 chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
39 #########################
43 my $mb = Module::Build->new_from_context;
47 eval {$mb->dispatch('distdir')};
49 chdir( $mb->dist_dir ) or die "Can't chdir to '@{[$mb->dist_dir]}': $!";
52 # Make sure the signature actually verifies
53 ok Module::Signature::verify() == Module::Signature::SIGNATURE_OK();
54 chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
58 # Fake out Module::Signature and Module::Build - the first one to
59 # run should be distmeta.
62 local $^W; # Skip 'redefined' warnings
63 local *Module::Signature::sign = sub { push @run_order, 'sign' };
64 local *Module::Build::Base::ACTION_distmeta = sub { push @run_order, 'distmeta' };
65 eval { $mb->dispatch('distdir') };
68 is $run_order[0], 'distmeta';
69 is $run_order[1], 'sign';
72 eval { $mb->dispatch('realclean') };
77 chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";