"Fossies" - the Fresh Open Source Software Archive

Member "Module-Build-0.4224/t/ppm.t" (30 May 2017, 5644 Bytes) of package /linux/privat/Module-Build-0.4224.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "ppm.t": 0.4218_vs_0.4220.

    1 #!/usr/bin/perl -w
    2 
    3 use strict;
    4 use lib 't/lib';
    5 use MBTest;
    6 use Config;
    7 
    8 blib_load('Module::Build');
    9 blib_load('Module::Build::ConfigData');
   10 my $PPM_support = Module::Build::ConfigData->feature('PPM_support');
   11 my $manpage_support = Module::Build::ConfigData->feature('manpage_support');
   12 my $HTML_support = Module::Build::ConfigData->feature('HTML_support');
   13 
   14 my $tmp;
   15 
   16 {
   17   my ($have_c_compiler, $tmp_exec) = check_compiler();
   18   if ( ! $have_c_compiler ) {
   19     plan skip_all => 'No compiler found';
   20   } elsif ( ! $tmp_exec ) {
   21     plan skip_all => 'Dysfunctional compiler detected';
   22   } elsif ( ! $PPM_support ) {
   23     plan skip_all => 'PPM support modules not installed';
   24   } elsif ( !$Config{usedl} ) {
   25     plan skip_all => 'Perl not compiled for dynamic loading';
   26   } elsif ( ! $HTML_support )  {
   27     plan skip_all => "HTML support not installed";
   28   } elsif ( ! eval {require Archive::Tar} ) {
   29     plan skip_all => "Archive::Tar not installed to read archives.";
   30   } elsif ( ! eval {IO::Zlib->VERSION(1.01)} ) {
   31     plan skip_all => "IO::Zlib 1.01 required to read compressed archives.";
   32   } elsif ( $^O eq 'VMS' ) {
   33     plan skip_all => "Needs porting work on VMS";
   34   } else {
   35     plan tests => 12;
   36   }
   37   require Cwd;
   38   $tmp = MBTest->tmpdir( $tmp_exec ? () : (DIR => Cwd::cwd) );
   39 }
   40 
   41 
   42 use DistGen;
   43 my $dist = DistGen->new( dir => $tmp, xs => 1 );
   44 $dist->add_file( 'hello', <<'---' );
   45 #!perl -w
   46 print "Hello, World!\n";
   47 __END__
   48 
   49 =pod
   50 
   51 =head1 NAME
   52 
   53 hello
   54 
   55 =head1 DESCRIPTION
   56 
   57 Says "Hello"
   58 
   59 =cut
   60 ---
   61 $dist->change_build_pl
   62 ({
   63   module_name => $dist->name,
   64   license     => 'perl',
   65   scripts     => [ 'hello' ],
   66 });
   67 $dist->regen;
   68 
   69 $dist->chdir_in;
   70 
   71 use File::Spec::Functions qw(catdir);
   72 
   73 my @installstyle = qw(lib perl5);
   74 my $mb = Module::Build->new_from_context(
   75   verbose => 0,
   76   quiet   => 1,
   77 
   78   installdirs => 'site',
   79   config => {
   80     manpage_reset(), html_reset(),
   81     ( $manpage_support ?
   82       ( installsiteman1dir  => catdir($tmp, 'site', 'man', 'man1'),
   83         installsiteman3dir  => catdir($tmp, 'site', 'man', 'man3') ) : () ),
   84     ( $HTML_support ?
   85       ( installsitehtml1dir => catdir($tmp, 'site', 'html'),
   86         installsitehtml3dir => catdir($tmp, 'site', 'html') ) : () ),
   87   },
   88   html_links => 0,
   89 );
   90 
   91 
   92 
   93 $mb->dispatch('ppd', args => {codebase => '/path/to/codebase-xs'});
   94 
   95 (my $dist_filename = $dist->name) =~ s/::/-/g;
   96 my $ppd = slurp($dist_filename . '.ppd');
   97 
   98 my $perl_version = Module::Build::PPMMaker->_ppd_version($mb->perl_version);
   99 my $varchname = Module::Build::PPMMaker->_varchname($mb->config);
  100 
  101 # This test is quite a hack since with XML you don't really want to
  102 # do a strict string comparison, but absent an XML parser it's the
  103 # best we can do.
  104 is $ppd, <<"---";
  105 <SOFTPKG NAME="$dist_filename" VERSION="0.01">
  106     <ABSTRACT>Perl extension for blah blah blah</ABSTRACT>
  107     <AUTHOR>A. U. Thor, a.u.thor\@a.galaxy.far.far.away</AUTHOR>
  108     <IMPLEMENTATION>
  109         <ARCHITECTURE NAME="$varchname" />
  110         <CODEBASE HREF="/path/to/codebase-xs" />
  111     </IMPLEMENTATION>
  112 </SOFTPKG>
  113 ---
  114 
  115 
  116 
  117 $mb->dispatch('ppmdist');
  118 is $@, '';
  119 
  120 my $tar = Archive::Tar->new;
  121 
  122 my $tarfile = $mb->ppm_name . '.tar.gz';
  123 $tar->read( $tarfile, 1 );
  124 
  125 my $files = { map { $_ => 1 } $tar->list_files };
  126 
  127 my $fname = 'Simple';
  128 $fname = DynaLoader::mod2fname([$fname]) if defined &DynaLoader::mod2fname;
  129 exists_ok($files, "blib/arch/auto/Simple/$fname." . $mb->config('dlext'));
  130 exists_ok($files, 'blib/lib/Simple.pm');
  131 exists_ok($files, 'blib/script/hello');
  132 
  133 SKIP: {
  134   skip( "manpage_support not enabled.", 2 ) unless $manpage_support;
  135 
  136   exists_ok($files, 'blib/man3/Simple.' . $mb->config('man3ext'));
  137   exists_ok($files, 'blib/man1/hello.' . $mb->config('man1ext'));
  138 }
  139 
  140 SKIP: {
  141   skip( "HTML_support not enabled.", 2 ) unless $HTML_support;
  142 
  143   exists_ok($files, 'blib/html/site/lib/Simple.html');
  144   exists_ok($files, 'blib/html/bin/hello.html');
  145 }
  146 
  147 $tar->clear;
  148 undef( $tar );
  149 
  150 $mb->dispatch('realclean');
  151 $dist->clean;
  152 
  153 
  154 SKIP: {
  155   skip( "HTML_support not enabled.", 3 ) unless $HTML_support;
  156 
  157   # Make sure html documents are generated for the ppm distro even when
  158   # they would not be built during a normal build.
  159   $mb = Module::Build->new_from_context(
  160     verbose => 0,
  161     quiet   => 1,
  162 
  163     installdirs => 'site',
  164     config => {
  165       html_reset(),
  166       installsiteman1dir  => catdir($tmp, 'site', 'man', 'man1'),
  167       installsiteman3dir  => catdir($tmp, 'site', 'man', 'man3'),
  168     },
  169     html_links => 0,
  170   );
  171 
  172   $mb->dispatch('ppmdist');
  173   is $@, '';
  174 
  175   $tar = Archive::Tar->new;
  176   $tar->read( $tarfile, 1 );
  177 
  178   $files = {map { $_ => 1 } $tar->list_files};
  179 
  180   exists_ok($files, 'blib/html/site/lib/Simple.html');
  181   exists_ok($files, 'blib/html/bin/hello.html');
  182 
  183   $tar->clear;
  184 
  185   $mb->dispatch('realclean');
  186   $dist->clean;
  187 }
  188 
  189 
  190 ########################################
  191 
  192 sub exists_ok {
  193   my $files = shift;
  194   my $file  = shift;
  195   local $Test::Builder::Level = $Test::Builder::Level + 1;
  196   ok exists( $files->{$file} ) && $files->{$file}, $file;
  197 }
  198 
  199 # A hash of all Config.pm settings related to installing
  200 # manpages with values set to an empty string.
  201 sub manpage_reset {
  202   return (
  203     installman1dir => '',
  204     installman3dir => '',
  205     installsiteman1dir => '',
  206     installsiteman3dir => '',
  207     installvendorman1dir => '',
  208     installvendorman3dir => '',
  209   );
  210 }
  211 
  212 # A hash of all Config.pm settings related to installing
  213 # html documents with values set to an empty string.
  214 sub html_reset {
  215   return (
  216     installhtmldir => '',
  217     installhtml1dir => '',
  218     installhtml3dir => '',
  219     installsitehtml1dir => '',
  220     installsitehtml3dir => '',
  221     installvendorhtml1dir => '',
  222     installvendorhtml3dir => '',
  223   );
  224 }
  225