Add the original source packages to maemo, source lenny
[dh-make-perl] / dev / i386 / libmodule-build-perl / libmodule-build-perl-0.2808.01 / t / par.t
1 #!/usr/bin/perl -w
2
3 use strict;
4 use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
5 use MBTest;
6 use Module::Build;
7 use Module::Build::ConfigData;
8
9 {
10   my ($have_c_compiler, $C_support_feature) = check_compiler();
11   if (! $C_support_feature) {
12     plan skip_all => 'C_support not enabled';
13   } elsif ( ! $have_c_compiler ) {
14     plan skip_all => 'C_support enabled, but no compiler found';
15   } elsif ( ! eval {require PAR::Dist; PAR::Dist->VERSION(0.17)} ) {
16     plan skip_all => "PAR::Dist 0.17 or up not installed to check .par's.";
17   } elsif ( ! eval {require Archive::Zip} ) {
18     plan skip_all => "Archive::Zip required.";
19   } else {
20     plan tests => 3;
21   }
22 }
23
24
25 use Cwd ();
26 my $cwd = Cwd::cwd;
27 my $tmp = MBTest->tmpdir;
28
29
30 use DistGen;
31 my $dist = DistGen->new( dir => $tmp, xs => 1 );
32 $dist->add_file( 'hello', <<'---' );
33 #!perl -w
34 print "Hello, World!\n";
35 __END__
36
37 =pod
38
39 =head1 NAME
40
41 hello
42
43 =head1 DESCRIPTION
44
45 Says "Hello"
46
47 =cut
48 ---
49 $dist->change_build_pl
50 ({
51   module_name => $dist->name,
52   version => '0.01',
53   license     => 'perl',
54   scripts     => [ 'hello' ],
55 });
56 $dist->regen;
57
58 chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
59
60 use File::Spec::Functions qw(catdir);
61
62 use Module::Build;
63 my @installstyle = qw(lib perl5);
64 my $mb = Module::Build->new_from_context(
65   verbose => 0,
66   quiet   => 1,
67
68   installdirs => 'site',
69 );
70
71 my $filename = $mb->dispatch('pardist');
72
73 ok( -f $filename, '.par distributions exists' );
74 my $distname = $dist->name;
75 ok( $filename =~ /^\Q$distname\E/, 'Distribution name seems correct' );
76
77 my $meta;
78 eval { $meta = PAR::Dist::get_meta($filename) };
79
80 ok(
81   (not $@ and defined $meta and not $meta eq ''),
82   'Distribution contains META.yml'
83 );
84
85 $dist->clean();
86
87 chdir( $cwd );
88 use File::Path;
89 rmtree( $tmp );
90