4 use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
7 use Module::Build::ConfigData;
9 my $manpage_support = Module::Build::ConfigData->feature('manpage_support');
10 my $HTML_support = Module::Build::ConfigData->feature('HTML_support');
14 my ($have_c_compiler, $C_support_feature) = check_compiler();
15 if (! $C_support_feature) {
16 plan skip_all => 'C_support not enabled';
17 } elsif ( ! $have_c_compiler ) {
18 plan skip_all => 'C_support enabled, but no compiler found';
19 } elsif ( ! eval {require Archive::Tar} ) {
20 plan skip_all => "Archive::Tar not installed to read archives.";
21 } elsif ( ! eval {IO::Zlib->VERSION(1.01)} ) {
22 plan skip_all => "IO::Zlib 1.01 required to read compressed archives.";
23 } elsif ( $^O eq 'VMS' ) {
24 plan skip_all => "Needs porting work on VMS";
33 my $tmp = MBTest->tmpdir;
37 my $dist = DistGen->new( dir => $tmp, xs => 1 );
38 $dist->add_file( 'hello', <<'---' );
40 print "Hello, World!\n";
55 $dist->change_build_pl
57 module_name => $dist->name,
59 scripts => [ 'hello' ],
63 chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
65 use File::Spec::Functions qw(catdir);
68 my @installstyle = qw(lib perl5);
69 my $mb = Module::Build->new_from_context(
73 installdirs => 'site',
75 manpage_reset(), html_reset(),
77 ( installsiteman1dir => catdir($tmp, 'site', 'man', 'man1'),
78 installsiteman3dir => catdir($tmp, 'site', 'man', 'man3') ) : () ),
80 ( installsitehtml1dir => catdir($tmp, 'site', 'html'),
81 installsitehtml3dir => catdir($tmp, 'site', 'html') ) : () ),
87 $mb->dispatch('ppd', args => {codebase => '/path/to/codebase-xs'});
89 (my $dist_filename = $dist->name) =~ s/::/-/g;
90 my $ppd = slurp($dist_filename . '.ppd');
92 my $perl_version = Module::Build::PPMMaker->_ppd_version($mb->perl_version);
93 my $varchname = Module::Build::PPMMaker->_varchname($mb->config);
95 # This test is quite a hack since with XML you don't really want to
96 # do a strict string comparison, but absent an XML parser it's the
99 <SOFTPKG NAME="$dist_filename" VERSION="0,01,0,0">
100 <TITLE>@{[$dist->name]}</TITLE>
101 <ABSTRACT>Perl extension for blah blah blah</ABSTRACT>
102 <AUTHOR>A. U. Thor, a.u.thor\@a.galaxy.far.far.away</AUTHOR>
104 <PERLCORE VERSION="$perl_version" />
106 <ARCHITECTURE NAME="$varchname" />
107 <CODEBASE HREF="/path/to/codebase-xs" />
114 $mb->dispatch('ppmdist');
117 my $tar = Archive::Tar->new;
119 my $tarfile = $mb->ppm_name . '.tar.gz';
120 $tar->read( $tarfile, 1 );
122 my $files = { map { $_ => 1 } $tar->list_files };
124 my $fname = 'Simple';
125 $fname = DynaLoader::mod2fname([$fname]) if defined &DynaLoader::mod2fname;
126 exists_ok($files, "blib/arch/auto/Simple/$fname." . $mb->config('dlext'));
127 exists_ok($files, 'blib/lib/Simple.pm');
128 exists_ok($files, 'blib/script/hello');
131 skip( "manpage_support not enabled.", 2 ) unless $manpage_support;
133 exists_ok($files, 'blib/man3/Simple.' . $mb->config('man3ext'));
134 exists_ok($files, 'blib/man1/hello.' . $mb->config('man1ext'));
138 skip( "HTML_support not enabled.", 2 ) unless $HTML_support;
140 exists_ok($files, 'blib/html/site/lib/Simple.html');
141 exists_ok($files, 'blib/html/bin/hello.html');
147 $mb->dispatch('realclean');
152 skip( "HTML_support not enabled.", 3 ) unless $HTML_support;
154 # Make sure html documents are generated for the ppm distro even when
155 # they would not be built during a normal build.
156 $mb = Module::Build->new_from_context(
160 installdirs => 'site',
163 installsiteman1dir => catdir($tmp, 'site', 'man', 'man1'),
164 installsiteman3dir => catdir($tmp, 'site', 'man', 'man3'),
168 $mb->dispatch('ppmdist');
171 $tar = Archive::Tar->new;
172 $tar->read( $tarfile, 1 );
174 $files = {map { $_ => 1 } $tar->list_files};
176 exists_ok($files, 'blib/html/site/lib/Simple.html');
177 exists_ok($files, 'blib/html/bin/hello.html');
181 $mb->dispatch('realclean');
186 chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
193 ########################################
198 local $Test::Builder::Level = $Test::Builder::Level + 1;
199 ok exists( $files->{$file} ) && $files->{$file}, $file;
202 # A hash of all Config.pm settings related to installing
203 # manpages with values set to an empty string.
206 installman1dir => '',
207 installman3dir => '',
208 installsiteman1dir => '',
209 installsiteman3dir => '',
210 installvendorman1dir => '',
211 installvendorman3dir => '',
215 # A hash of all Config.pm settings related to installing
216 # html documents with values set to an empty string.
219 installhtmldir => '',
220 installhtml1dir => '',
221 installhtml3dir => '',
222 installsitehtml1dir => '',
223 installsitehtml3dir => '',
224 installvendorhtml1dir => '',
225 installvendorhtml3dir => '',