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 = File::Spec->catdir( $cwd, 't', '_tmp' );
35 my $dist = DistGen->new( dir => $tmp, xs => 1 );
36 $dist->add_file( 'hello', <<'---' );
38 print "Hello, World!\n";
53 $dist->change_file( 'Build.PL', <<"---" );
55 my \$build = new Module::Build(
56 module_name => @{[$dist->name]},
58 scripts => [ 'hello' ],
61 \$build->create_build_script;
65 chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
67 use File::Spec::Functions qw(catdir);
70 my @installstyle = qw(lib perl5);
71 my $mb = Module::Build->new_from_context(
75 installdirs => 'site',
77 manpage_reset(), html_reset(),
79 ( installsiteman1dir => catdir($tmp, 'site', 'man', 'man1'),
80 installsiteman3dir => catdir($tmp, 'site', 'man', 'man3') ) : () ),
82 ( installsitehtml1dir => catdir($tmp, 'site', 'html'),
83 installsitehtml3dir => catdir($tmp, 'site', 'html') ) : () ),
89 $mb->dispatch('ppd', args => {codebase => '/path/to/codebase-xs'});
91 (my $dist_filename = $dist->name) =~ s/::/-/g;
92 my $ppd = slurp($dist_filename . '.ppd');
94 my $perl_version = Module::Build::PPMMaker->_ppd_version($mb->perl_version);
95 my $varchname = Module::Build::PPMMaker->_varchname($mb->config);
97 # This test is quite a hack since with XML you don't really want to
98 # do a strict string comparison, but absent an XML parser it's the
101 <SOFTPKG NAME="$dist_filename" VERSION="0,01,0,0">
102 <TITLE>@{[$dist->name]}</TITLE>
103 <ABSTRACT>Perl extension for blah blah blah</ABSTRACT>
104 <AUTHOR>A. U. Thor, a.u.thor\@a.galaxy.far.far.away</AUTHOR>
106 <PERLCORE VERSION="$perl_version" />
108 <ARCHITECTURE NAME="$varchname" />
109 <CODEBASE HREF="/path/to/codebase-xs" />
116 $mb->dispatch('ppmdist');
119 my $tar = Archive::Tar->new;
121 my $tarfile = $mb->ppm_name . '.tar.gz';
122 $tar->read( $tarfile, 1 );
124 my $files = { map { $_ => 1 } $tar->list_files };
126 my $fname = 'Simple';
127 $fname = DynaLoader::mod2fname([$fname]) if defined &DynaLoader::mod2fname;
128 exists_ok($files, "blib/arch/auto/Simple/$fname." . $mb->config('dlext'));
129 exists_ok($files, 'blib/lib/Simple.pm');
130 exists_ok($files, 'blib/script/hello');
133 skip( "manpage_support not enabled.", 2 ) unless $manpage_support;
135 exists_ok($files, 'blib/man3/Simple.' . $mb->config('man3ext'));
136 exists_ok($files, 'blib/man1/hello.' . $mb->config('man1ext'));
140 skip( "HTML_support not enabled.", 2 ) unless $HTML_support;
142 exists_ok($files, 'blib/html/site/lib/Simple.html');
143 exists_ok($files, 'blib/html/bin/hello.html');
149 $mb->dispatch('realclean');
154 skip( "HTML_support not enabled.", 3 ) unless $HTML_support;
156 # Make sure html documents are generated for the ppm distro even when
157 # they would not be built during a normal build.
158 $mb = Module::Build->new_from_context(
162 installdirs => 'site',
165 installsiteman1dir => catdir($tmp, 'site', 'man', 'man1'),
166 installsiteman3dir => catdir($tmp, 'site', 'man', 'man3'),
170 $mb->dispatch('ppmdist');
173 $tar = Archive::Tar->new;
174 $tar->read( $tarfile, 1 );
176 $files = {map { $_ => 1 } $tar->list_files};
178 exists_ok($files, 'blib/html/site/lib/Simple.html');
179 exists_ok($files, 'blib/html/bin/hello.html');
183 $mb->dispatch('realclean');
188 chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
195 ########################################
200 local $Test::Builder::Level = $Test::Builder::Level + 1;
201 ok exists( $files->{$file} ) && $files->{$file}, $file;
204 # A hash of all Config.pm settings related to installing
205 # manpages with values set to an empty string.
208 installman1dir => '',
209 installman3dir => '',
210 installsiteman1dir => '',
211 installsiteman3dir => '',
212 installvendorman1dir => '',
213 installvendorman3dir => '',
217 # A hash of all Config.pm settings related to installing
218 # html documents with values set to an empty string.
221 installhtmldir => '',
222 installhtml1dir => '',
223 installhtml3dir => '',
224 installsitehtml1dir => '',
225 installsitehtml3dir => '',
226 installvendorhtml1dir => '',
227 installvendorhtml3dir => '',