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