File: 31_make-defaults.t

package info (click to toggle)
libextutils-modulemaker-perl 0.63-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 744 kB
  • sloc: perl: 7,331; makefile: 11
file content (141 lines) | stat: -rw-r--r-- 4,598 bytes parent folder | download | duplicates (2)
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# t/31_make-defaults.t
# tests of options to make modulemaker selections default personal values
use strict;
use warnings;
use Carp;
use Cwd;
use File::Spec;
use File::Temp qw(tempdir);
use Test::More tests => 39;
use_ok( 'ExtUtils::ModuleMaker' );
use_ok( 'ExtUtils::ModuleMaker::Auxiliary', qw(
    prepare_mockdirs
    basic_file_and_directory_tests
    license_text_test
    check_MakefilePL
) );

my $cwd = cwd();

my ($home_dir, $personal_defaults_dir) = prepare_mockdirs();
local $ENV{HOME} = $home_dir;

my $personal_defaults_file = ExtUtils::ModuleMaker::MockHomeDir::personal_defaults_file();
ok(-f $personal_defaults_file, "Able to create file $personal_defaults_file for testing");

{

=pod TestingModality:
    Suppress any Personal::Defaults currently installed on system.  Create a
new EU::MM object.  To be certain of values, require Testing::Defaults and
explicitly call the default_values() method from that package.  Build files
and verify structure and content with tests previously
developed.  Then, call make_selections_defaults().  That installs a
Personal::Defaults on system.
    Now create a second EU::MM object with new values for several keys.  Build
files from that object.  Use tests previously developed to analyze the content
of the Makefile.PL, the directory/file structure, etc.  Then do cleanup:
restore any Personal::Defaults which was originally on system.  Verify that
was done.

=cut

    my ($module_name, @components, $dist_name, $path_str, $module_file, @pred);
    my ($mf);

    my $tdir = tempdir( CLEANUP => 1);
    ok(chdir $tdir, 'changed to temp directory for testing');

    push @INC, File::Spec->catdir($home_dir, '.modulemaker');
    require ExtUtils::ModuleMaker::Personal::Defaults;
    my $testing_defaults_ref = ExtUtils::ModuleMaker::Personal::Defaults::default_values();

    note("Object 1");
    my $obj1 = ExtUtils::ModuleMaker->new( %{$testing_defaults_ref} );
    isa_ok( $obj1, 'ExtUtils::ModuleMaker' );

    ok( $obj1->complete_build(), 'call complete_build()' );

    $module_name = $obj1->{NAME};
    @components = split(/::/, $module_name);
    $dist_name = join('-' => @components);
    $path_str = File::Spec->catdir(@components);

    basic_file_and_directory_tests($path_str);
    license_text_test($path_str, qr/Terms of Perl itself/);

    @pred = (
         q{EU::MM::Testing::Defaults},
        qq{lib\/EU\/MM\/Testing\/Defaults\.pm},
        qq{Hilton\\sStallone},
        qq{hiltons\@parliamentarypictures\.com},
        qq{Module\\sabstract\\s\\(<=\\s44\\scharacters\\)\\sgoes\\shere},
    );

    check_MakefilePL($path_str, \@pred);

    $obj1->make_selections_defaults();

    note("Object 2");
    my $obj2 = ExtUtils::ModuleMaker->new(
        NAME    => q{Ackus::Frackus},
        AUTHOR  => q{Marilyn Shmarilyn},
        EMAIL   => q{marilyns@nineteenthcenturyfox.com},
        COMPACT => 1,
        SAVE_AS_DEFAULTS => 1,
    );
    isa_ok( $obj2, 'ExtUtils::ModuleMaker' );

    ok( $obj2->complete_build(), 'call complete_build()' );

    $module_name = $obj2->{NAME};
    @components = split(/::/, $module_name);
    $dist_name = join('-' => @components);
    $path_str = File::Spec->catdir(@components);
    $mf = join('/' => (
        'lib', @components[0 .. ($#components - 1)], "$components[-1].pm"));


    basic_file_and_directory_tests($dist_name);
    license_text_test($dist_name, qr/Terms of Perl itself/);

    @pred = (
        $module_name,
        quotemeta($mf),
        qq{Marilyn\\sShmarilyn},
        qq{marilyns\@nineteenthcenturyfox\.com},
        qq{Module\\sabstract\\s\\(<=\\s44\\scharacters\\)\\sgoes\\shere},
    );

    check_MakefilePL($dist_name, \@pred);

    note("Object 3");
    do 'ExtUtils/ModuleMaker/Personal/Defaults.pm';
    my $obj3 = ExtUtils::ModuleMaker->new(
        NAME    => q{Hocus::Pocus},
    );
    isa_ok( $obj3, 'ExtUtils::ModuleMaker' );

    ok( $obj3->complete_build(), 'call complete_build()' );

    $module_name = $obj3->{NAME};
    @components = split(/::/, $module_name);
    $dist_name = join('-' => @components);
    $path_str = File::Spec->catdir(@components);
    $mf = join('/' => (
        'lib', @components[0 .. ($#components - 1)], "$components[-1].pm"));

    basic_file_and_directory_tests($dist_name);
    license_text_test($dist_name, qr/Terms of Perl itself/);

    @pred = (
        $module_name,
        quotemeta($mf),
        qq{Marilyn\\sShmarilyn},
        qq{marilyns\@nineteenthcenturyfox\.com},
        qq{Module\\sabstract\\s\\(<=\\s44\\scharacters\\)\\sgoes\\shere},
    );

    check_MakefilePL($dist_name, \@pred);
}