1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
# t/10_standard_text.t
# tests of importation of standard text from
# lib/ExtUtils/Modulemaker/Defaults.pm
use strict;
use warnings;
use Carp;
use File::Spec;
use File::Temp qw(tempdir);
use Test::More tests => 30;
use_ok( 'ExtUtils::ModuleMaker' );
use_ok( 'ExtUtils::ModuleMaker::Auxiliary', qw(
prepare_mockdirs
basic_file_and_directory_tests
license_text_test
read_file_string
read_file_array
) );
{
my ($home_dir, $personal_defaults_dir) = prepare_mockdirs();
local $ENV{HOME} = $home_dir;
my $tdir = tempdir( CLEANUP => 1);
ok(chdir $tdir, 'changed to temp directory for testing');
my ($mod);
my $testmod = 'Beta';
my @components = ( 'Alpha', $testmod );
my $module_name = join('::' => @components);
my $dist_name = join('-' => @components);
ok( $mod = ExtUtils::ModuleMaker->new(
NAME => $module_name,
COMPACT => 1,
),
"call ExtUtils::ModuleMaker->new for $dist_name"
);
ok( $mod->complete_build(), 'call complete_build()' );
basic_file_and_directory_tests($dist_name);
license_text_test($dist_name, qr/Terms of Perl itself/);
my ($filetext, @pmfilelines, @makefilelines, @readmelines);
ok(@pmfilelines = read_file_array(File::Spec->catfile(
$dist_name,
'lib',
@components[0 .. ($#components - 1)],
"$components[-1].pm",
) ),
'Able to read module into array');
# test of main pod wrapper
is( (grep {/^#{20} main pod documentation (begin|end)/} @pmfilelines), 2,
"standard text for POD wrapper found");
# test of block new method
is( (grep {/^sub new/} @pmfilelines), 1,
"new method found");
# test of block module header description
is( (grep {/^sub new/} @pmfilelines), 1,
"new method found");
# test of stub documentation
is( (grep {/^Stub documentation for this module was created/} @pmfilelines),
1,
"stub documentation found");
# test of subroutine header
is( (grep {/^#{20} subroutine header (begin|end)/} @pmfilelines), 2,
"subroutine header found");
# test of final block
is( (grep { /^(1;|# The preceding line will help the module return a true value)$/ } @pmfilelines), 2,
"final module block found");
# test of Makefile.PL text
ok($filetext = read_file_string(File::Spec->catfile($dist_name, 'Makefile.PL')),
'Able to read Makefile.PL');
ok(@makefilelines = read_file_array(File::Spec->catfile($dist_name, 'Makefile.PL')),
'Able to read Makefile.PL into array');
is(
(grep {/^# Call 'perldoc ExtUtils::MakeMaker' for details of how to influence/} @makefilelines),
1,
"Makefile.PL has standard text");
# test of README text
ok(@readmelines = read_file_array(File::Spec->catfile($dist_name, 'README')),
'Able to read README into array');
is( (grep {/^pod2text $mod->{NAME}/} @readmelines),
1,
"README has correct pod2text line");
is( (grep {/^If this is still here/} @readmelines),
1,
"README has correct top part");
is( (grep {/^(perl Makefile\.PL|make( (test|install))?)/} @readmelines),
4,
"README has appropriate build instructions for MakeMaker");
is( (grep {/^If you are on a windows box/} @readmelines),
1,
"README has correct bottom part");
}
|