From 467298a34215401cdcbb1dded51bc2aba5f1f41c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Thu, 11 Jun 2015 22:32:06 +0000 Subject: Module-Build-0.4214 --- t/par.t | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 t/par.t (limited to 't/par.t') diff --git a/t/par.t b/t/par.t new file mode 100644 index 0000000..aeb39f7 --- /dev/null +++ b/t/par.t @@ -0,0 +1,96 @@ +#!/usr/bin/perl -w + +use strict; +use lib 't/lib'; +use MBTest; +blib_load('Module::Build'); +blib_load('Module::Build::ConfigData'); + +my $tmp; + +{ + my ($have_c_compiler, $tmp_exec) = check_compiler(); + if ( ! $have_c_compiler ) { + plan skip_all => 'No compiler found'; + } elsif ( ! eval {require PAR::Dist; PAR::Dist->VERSION(0.17)} ) { + plan skip_all => "PAR::Dist 0.17 or up not installed to check .par's."; + } elsif ( ! eval {require Archive::Zip} ) { + plan skip_all => "Archive::Zip required."; + } else { + plan tests => 3; + } + require Cwd; + $tmp = MBTest->tmpdir( $tmp_exec ? () : (DIR => Cwd::cwd) ); +} + + + +use DistGen; +my $dist = DistGen->new( dir => $tmp, xs => 1 ); +$dist->add_file( 'hello', <<'---' ); +#!perl -w +print "Hello, World!\n"; +__END__ + +=pod + +=head1 NAME + +hello + +=head1 DESCRIPTION + +Says "Hello" + +=cut +--- +$dist->change_build_pl +({ + module_name => $dist->name, + version => '0.01', + license => 'perl', + scripts => [ 'hello' ], +}); +$dist->regen; + +$dist->chdir_in; + +use File::Spec::Functions qw(catdir); + +my @installstyle = qw(lib perl5); +my $mb = Module::Build->new_from_context( + verbose => 0, + quiet => 1, + + installdirs => 'site', +); + +my $filename = $mb->dispatch('pardist'); + +ok( -f $filename, '.par distributions exists' ); +my $distname = $dist->name; +ok( $filename =~ /^\Q$distname\E/, 'Distribution name seems correct' ); + +#--------------------------------------------------------------------------# +# must work around broken Archive::Zip (1.28) which breaks PAR::Dist +#--------------------------------------------------------------------------# + +SKIP: { + my $zip = Archive::Zip->new; + my $tmp2 = MBTest->tmpdir; + local %SIG; + $SIG{__WARN__} = sub { print STDERR $_[0] unless $_[0] =~ /\bstat\b/ }; + skip "broken Archive::Zip", 1 + unless eval { $zip->read($filename) == Archive::Zip::AZ_OK() } + && eval { $zip->extractTree('', "$tmp2/") == Archive::Zip::AZ_OK() } + && -r File::Spec->catfile( $tmp2, 'blib', 'META.yml' ); + + my $meta; + eval { $meta = PAR::Dist::get_meta($filename) }; + + ok( + (not $@ and defined $meta and not $meta eq ''), + 'Distribution contains META.yml' + ); +} + -- cgit v1.2.1