Commit | Line | Data |
75e2e551 |
1 | #!/usr/bin/perl -w |
2 | |
3 | # This test puts MakeMaker through the paces of a basic perl module |
4 | # build, test and installation of the Big::Fat::Dummy module. |
5 | |
6 | BEGIN { |
7 | if( $ENV{PERL_CORE} ) { |
8 | chdir 't' if -d 't'; |
9 | @INC = ('../lib', 'lib'); |
10 | } |
11 | else { |
12 | unshift @INC, 't/lib'; |
13 | } |
14 | } |
15 | |
16 | use strict; |
479d2113 |
17 | use Config; |
18 | |
19 | use Test::More tests => 48; |
75e2e551 |
20 | use MakeMaker::Test::Utils; |
479d2113 |
21 | use File::Find; |
75e2e551 |
22 | use File::Spec; |
75e2e551 |
23 | |
e0678a30 |
24 | my $perl = which_perl(); |
479d2113 |
25 | my $Is_VMS = $^O eq 'VMS'; |
75e2e551 |
26 | |
57b1a898 |
27 | my $root_dir = 't'; |
28 | |
29 | if( $^O eq 'VMS' ) { |
30 | # On older systems we might exceed the 8-level directory depth limit |
31 | # imposed by RMS. We get around this with a rooted logical, but we |
32 | # can't create logical names with attributes in Perl, so we do it |
33 | # in a DCL subprocess and put it in the job table so the parent sees it. |
34 | open( BFDTMP, '>bfdtesttmp.com' ) || die "Error creating command file; $!"; |
35 | print BFDTMP <<'COMMAND'; |
a67d7a01 |
36 | $ IF F$TRNLNM("PERL_CORE") .EQS. "" .AND. F$TYPE(PERL_CORE) .EQS. "" |
37 | $ THEN |
38 | $! building CPAN version |
7a069417 |
39 | $ BFD_TEST_ROOT = F$PARSE("SYS$DISK:[]",,,,"NO_CONCEAL")-".][000000"-"]["-"].;"+".]" |
a67d7a01 |
40 | $ ELSE |
41 | $! we're in the core |
7a069417 |
42 | $ BFD_TEST_ROOT = F$PARSE("SYS$DISK:[-]",,,,"NO_CONCEAL")-".][000000"-"]["-"].;"+".]" |
a67d7a01 |
43 | $ ENDIF |
57b1a898 |
44 | $ DEFINE/JOB/NOLOG/TRANSLATION=CONCEALED BFD_TEST_ROOT 'BFD_TEST_ROOT' |
45 | COMMAND |
46 | close BFDTMP; |
47 | |
48 | system '@bfdtesttmp.com'; |
49 | END { 1 while unlink 'bfdtesttmp.com' } |
7a069417 |
50 | $root_dir = 'BFD_TEST_ROOT:[t]'; |
57b1a898 |
51 | } |
52 | |
53 | chdir $root_dir; |
54 | |
75e2e551 |
55 | |
56 | perl_lib; |
57 | |
e0678a30 |
58 | my $Touch_Time = calibrate_mtime(); |
59 | |
75e2e551 |
60 | $| = 1; |
61 | |
45bc4d3a |
62 | ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) || |
75e2e551 |
63 | diag("chdir failed: $!"); |
64 | |
75e2e551 |
65 | my @mpl_out = `$perl Makefile.PL PREFIX=dummy-install`; |
66 | |
67 | cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || |
68 | diag(@mpl_out); |
69 | |
70 | my $makefile = makefile_name(); |
45bc4d3a |
71 | ok( grep(/^Writing $makefile for Big::Dummy/, |
75e2e551 |
72 | @mpl_out) == 1, |
73 | 'Makefile.PL output looks right'); |
74 | |
75 | ok( grep(/^Current package is: main$/, |
76 | @mpl_out) == 1, |
77 | 'Makefile.PL run in package main'); |
78 | |
79 | ok( -e $makefile, 'Makefile exists' ); |
80 | |
e0678a30 |
81 | # -M is flakey on VMS |
82 | my $mtime = (stat($makefile))[9]; |
83 | cmp_ok( $Touch_Time, '<=', $mtime, ' its been touched' ); |
75e2e551 |
84 | |
85 | END { unlink makefile_name(), makefile_backup() } |
86 | |
87 | my $make = make_run(); |
88 | |
89 | { |
90 | # Supress 'make manifest' noise |
91 | local $ENV{PERL_MM_MANIFEST_VERBOSE} = 0; |
92 | my $manifest_out = `$make manifest`; |
93 | ok( -e 'MANIFEST', 'make manifest created a MANIFEST' ); |
94 | ok( -s 'MANIFEST', ' its not empty' ); |
95 | } |
96 | |
97 | END { unlink 'MANIFEST'; } |
98 | |
479d2113 |
99 | |
100 | `$make ppd`; |
101 | is( $?, 0, ' exited normally' ); |
102 | ok( open(PPD, 'Big-Dummy.ppd'), ' .ppd file generated' ); |
103 | my $ppd_html; |
104 | { local $/; $ppd_html = <PPD> } |
105 | close PPD; |
106 | like( $ppd_html, qr{^<SOFTPKG NAME="Big-Dummy" VERSION="0,01,0,0">}m, |
107 | ' <SOFTPKG>' ); |
108 | like( $ppd_html, qr{^\s*<TITLE>Big-Dummy</TITLE>}m, ' <TITLE>' ); |
109 | like( $ppd_html, qr{^\s*<ABSTRACT>Try "our" hot dog's</ABSTRACT>}m, |
110 | ' <ABSTRACT>'); |
111 | like( $ppd_html, |
112 | qr{^\s*<AUTHOR>Michael G Schwern <schwern\@pobox.com></AUTHOR>}m, |
113 | ' <AUTHOR>' ); |
114 | like( $ppd_html, qr{^\s*<IMPLEMENTATION>}m, ' <IMPLEMENTATION>'); |
115 | like( $ppd_html, qr{^\s*<DEPENDENCY NAME="strict" VERSION="0,0,0,0" />}m, |
116 | ' <DEPENDENCY>' ); |
117 | like( $ppd_html, qr{^\s*<OS NAME="$Config{osname}" />}m, |
118 | ' <OS>' ); |
119 | like( $ppd_html, qr{^\s*<ARCHITECTURE NAME="$Config{archname}" />}m, |
120 | ' <ARCHITECTURE>'); |
121 | like( $ppd_html, qr{^\s*<CODEBASE HREF="" />}m, ' <CODEBASE>'); |
122 | like( $ppd_html, qr{^\s*</IMPLEMENTATION>}m, ' </IMPLEMENTATION>'); |
123 | like( $ppd_html, qr{^\s*</SOFTPKG>}m, ' </SOFTPKG>'); |
124 | END { unlink 'Big-Dummy.ppd' } |
125 | |
126 | |
75e2e551 |
127 | my $test_out = `$make test`; |
128 | like( $test_out, qr/All tests successful/, 'make test' ); |
479d2113 |
129 | is( $?, 0, ' exited normally' ); |
75e2e551 |
130 | |
131 | # Test 'make test TEST_VERBOSE=1' |
132 | my $make_test_verbose = make_macro($make, 'test', TEST_VERBOSE => 1); |
133 | $test_out = `$make_test_verbose`; |
134 | like( $test_out, qr/ok \d+ - TEST_VERBOSE/, 'TEST_VERBOSE' ); |
479d2113 |
135 | like( $test_out, qr/All tests successful/, ' successful' ); |
136 | is( $?, 0, ' exited normally' ); |
137 | |
138 | |
139 | my $install_out = `$make install`; |
140 | is( $?, 0, 'install' ) || diag $install_out; |
141 | like( $install_out, qr/^Installing /m ); |
142 | like( $install_out, qr/^Writing /m ); |
143 | |
144 | ok( -r 'dummy-install', ' install dir created' ); |
145 | my %files = (); |
146 | find( sub { |
147 | # do it case-insensitive for non-case preserving OSs |
148 | $files{lc $_} = $File::Find::name; |
149 | }, 'dummy-install' ); |
150 | ok( $files{'dummy.pm'}, ' Dummy.pm installed' ); |
151 | ok( $files{'liar.pm'}, ' Liar.pm installed' ); |
152 | ok( $files{'.packlist'}, ' packlist created' ); |
153 | ok( $files{'perllocal.pod'},' perllocal.pod created' ); |
154 | |
155 | |
156 | SKIP: { |
157 | skip "VMS install targets do not preserve PREFIX", 8 if $Is_VMS; |
158 | |
159 | $install_out = `$make install PREFIX=elsewhere`; |
160 | is( $?, 0, 'install with PREFIX override' ) || diag $install_out; |
161 | like( $install_out, qr/^Installing /m ); |
162 | like( $install_out, qr/^Writing /m ); |
163 | |
164 | ok( -r 'elsewhere', ' install dir created' ); |
165 | %files = (); |
166 | find( sub { $files{$_} = $File::Find::name; }, 'elsewhere' ); |
167 | ok( $files{'Dummy.pm'}, ' Dummy.pm installed' ); |
168 | ok( $files{'Liar.pm'}, ' Liar.pm installed' ); |
169 | ok( $files{'.packlist'}, ' packlist created' ); |
170 | ok( $files{'perllocal.pod'},' perllocal.pod created' ); |
171 | } |
172 | |
75e2e551 |
173 | |
45bc4d3a |
174 | my $dist_test_out = `$make disttest`; |
75e2e551 |
175 | is( $?, 0, 'disttest' ) || diag($dist_test_out); |
176 | |
479d2113 |
177 | # Test META.yml generation |
178 | use ExtUtils::Manifest qw(maniread); |
179 | ok( -f 'META.yml', 'META.yml written' ); |
180 | my $manifest = maniread(); |
181 | # VMS is non-case preserving, so we can't know what the MANIFEST will |
182 | # look like. :( |
183 | _normalize($manifest); |
184 | is( $manifest->{'meta.yml'}, 'Module meta-data in YAML' ); |
185 | |
e0678a30 |
186 | |
187 | # Make sure init_dirscan doesn't go into the distdir |
188 | @mpl_out = `$perl Makefile.PL "PREFIX=dummy-install"`; |
189 | |
190 | cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || |
191 | diag(@mpl_out); |
192 | |
479d2113 |
193 | ok( grep(/^Writing $makefile for Big::Dummy/, @mpl_out) == 1, |
e0678a30 |
194 | 'init_dirscan skipped distdir') || |
195 | diag(@mpl_out); |
196 | |
197 | # I know we'll get ignored errors from make here, that's ok. |
198 | # Send STDERR off to oblivion. |
199 | open(SAVERR, ">&STDERR") or die $!; |
200 | open(STDERR, ">".File::Spec->devnull) or die $!; |
201 | |
75e2e551 |
202 | my $realclean_out = `$make realclean`; |
203 | is( $?, 0, 'realclean' ) || diag($realclean_out); |
204 | |
e0678a30 |
205 | open(STDERR, ">&SAVERR") or die $!; |
206 | close SAVERR; |
479d2113 |
207 | |
208 | |
209 | sub _normalize { |
210 | my $hash = shift; |
211 | |
212 | while(my($k,$v) = each %$hash) { |
213 | delete $hash->{$k}; |
214 | $hash->{lc $k} = $v; |
215 | } |
216 | } |