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.";
31 my $tmp = MBTest->tmpdir;
35 my $dist = DistGen->new( dir => $tmp, xs => 1 );
36 $dist->add_file( 'hello', <<'---' );
38 print "Hello, World!\n";
53 $dist->change_build_pl
55 module_name => $dist->name,
57 scripts => [ 'hello' ],
61 chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
63 use File::Spec::Functions qw(catdir);
66 my @installstyle = qw(lib perl5);
67 my $mb = Module::Build->new_from_context(
71 installdirs => 'site',
73 manpage_reset(), html_reset(),
75 ( installsiteman1dir => catdir($tmp, 'site', 'man', 'man1'),
76 installsiteman3dir => catdir($tmp, 'site', 'man', 'man3') ) : () ),
78 ( installsitehtml1dir => catdir($tmp, 'site', 'html'),
79 installsitehtml3dir => catdir($tmp, 'site', 'html') ) : () ),
85 $mb->dispatch('ppd', args => {codebase => '/path/to/codebase-xs'});
87 (my $dist_filename = $dist->name) =~ s/::/-/g;
88 my $ppd = slurp($dist_filename . '.ppd');
90 my $perl_version = Module::Build::PPMMaker->_ppd_version($mb->perl_version);
91 my $varchname = Module::Build::PPMMaker->_varchname($mb->config);
93 # This test is quite a hack since with XML you don't really want to
94 # do a strict string comparison, but absent an XML parser it's the
97 <SOFTPKG NAME="$dist_filename" VERSION="0,01,0,0">
98 <TITLE>@{[$dist->name]}</TITLE>
99 <ABSTRACT>Perl extension for blah blah blah</ABSTRACT>
100 <AUTHOR>A. U. Thor, a.u.thor\@a.galaxy.far.far.away</AUTHOR>
102 <PERLCORE VERSION="$perl_version" />
104 <ARCHITECTURE NAME="$varchname" />
105 <CODEBASE HREF="/path/to/codebase-xs" />
112 $mb->dispatch('ppmdist');
115 my $tar = Archive::Tar->new;
117 my $tarfile = $mb->ppm_name . '.tar.gz';
118 $tar->read( $tarfile, 1 );
120 my $files = { map { $_ => 1 } $tar->list_files };
122 my $fname = 'Simple';
123 $fname = DynaLoader::mod2fname([$fname]) if defined &DynaLoader::mod2fname;
124 exists_ok($files, "blib/arch/auto/Simple/$fname." . $mb->config('dlext'));
125 exists_ok($files, 'blib/lib/Simple.pm');
126 exists_ok($files, 'blib/script/hello');
129 skip( "manpage_support not enabled.", 2 ) unless $manpage_support;
131 exists_ok($files, 'blib/man3/Simple.' . $mb->config('man3ext'));
132 exists_ok($files, 'blib/man1/hello.' . $mb->config('man1ext'));
136 skip( "HTML_support not enabled.", 2 ) unless $HTML_support;
138 exists_ok($files, 'blib/html/site/lib/Simple.html');
139 exists_ok($files, 'blib/html/bin/hello.html');
145 $mb->dispatch('realclean');
150 skip( "HTML_support not enabled.", 3 ) unless $HTML_support;
152 # Make sure html documents are generated for the ppm distro even when
153 # they would not be built during a normal build.
154 $mb = Module::Build->new_from_context(
158 installdirs => 'site',
161 installsiteman1dir => catdir($tmp, 'site', 'man', 'man1'),
162 installsiteman3dir => catdir($tmp, 'site', 'man', 'man3'),
166 $mb->dispatch('ppmdist');
169 $tar = Archive::Tar->new;
170 $tar->read( $tarfile, 1 );
172 $files = {map { $_ => 1 } $tar->list_files};
174 exists_ok($files, 'blib/html/site/lib/Simple.html');
175 exists_ok($files, 'blib/html/bin/hello.html');
179 $mb->dispatch('realclean');
184 chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
191 ########################################
196 local $Test::Builder::Level = $Test::Builder::Level + 1;
197 ok exists( $files->{$file} ) && $files->{$file}, $file;
200 # A hash of all Config.pm settings related to installing
201 # manpages with values set to an empty string.
204 installman1dir => '',
205 installman3dir => '',
206 installsiteman1dir => '',
207 installsiteman3dir => '',
208 installvendorman1dir => '',
209 installvendorman3dir => '',
213 # A hash of all Config.pm settings related to installing
214 # html documents with values set to an empty string.
217 installhtmldir => '',
218 installhtml1dir => '',
219 installhtml3dir => '',
220 installsitehtml1dir => '',
221 installsitehtml3dir => '',
222 installvendorhtml1dir => '',
223 installvendorhtml3dir => '',