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 | |
1df8d179 |
19 | use Test::More tests => 54; |
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 | |
431b0fc4 |
31 | chdir($Is_VMS ? 'BFD_TEST_ROOT:[t]' : 't'); |
57b1a898 |
32 | |
75e2e551 |
33 | |
34 | perl_lib; |
35 | |
e0678a30 |
36 | my $Touch_Time = calibrate_mtime(); |
37 | |
75e2e551 |
38 | $| = 1; |
39 | |
45bc4d3a |
40 | ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) || |
75e2e551 |
41 | diag("chdir failed: $!"); |
42 | |
1df8d179 |
43 | my @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"}); |
75e2e551 |
44 | |
45 | cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || |
46 | diag(@mpl_out); |
47 | |
48 | my $makefile = makefile_name(); |
45bc4d3a |
49 | ok( grep(/^Writing $makefile for Big::Dummy/, |
75e2e551 |
50 | @mpl_out) == 1, |
51 | 'Makefile.PL output looks right'); |
52 | |
53 | ok( grep(/^Current package is: main$/, |
54 | @mpl_out) == 1, |
55 | 'Makefile.PL run in package main'); |
56 | |
57 | ok( -e $makefile, 'Makefile exists' ); |
58 | |
e0678a30 |
59 | # -M is flakey on VMS |
60 | my $mtime = (stat($makefile))[9]; |
61 | cmp_ok( $Touch_Time, '<=', $mtime, ' its been touched' ); |
75e2e551 |
62 | |
63 | END { unlink makefile_name(), makefile_backup() } |
64 | |
65 | my $make = make_run(); |
66 | |
67 | { |
68 | # Supress 'make manifest' noise |
69 | local $ENV{PERL_MM_MANIFEST_VERBOSE} = 0; |
dedf98bc |
70 | my $manifest_out = run("$make manifest"); |
75e2e551 |
71 | ok( -e 'MANIFEST', 'make manifest created a MANIFEST' ); |
72 | ok( -s 'MANIFEST', ' its not empty' ); |
73 | } |
74 | |
75 | END { unlink 'MANIFEST'; } |
76 | |
479d2113 |
77 | |
dedf98bc |
78 | my $ppd_out = run("$make ppd"); |
79 | is( $?, 0, ' exited normally' ) || diag $ppd_out; |
479d2113 |
80 | ok( open(PPD, 'Big-Dummy.ppd'), ' .ppd file generated' ); |
81 | my $ppd_html; |
82 | { local $/; $ppd_html = <PPD> } |
83 | close PPD; |
84 | like( $ppd_html, qr{^<SOFTPKG NAME="Big-Dummy" VERSION="0,01,0,0">}m, |
85 | ' <SOFTPKG>' ); |
86 | like( $ppd_html, qr{^\s*<TITLE>Big-Dummy</TITLE>}m, ' <TITLE>' ); |
87 | like( $ppd_html, qr{^\s*<ABSTRACT>Try "our" hot dog's</ABSTRACT>}m, |
88 | ' <ABSTRACT>'); |
89 | like( $ppd_html, |
90 | qr{^\s*<AUTHOR>Michael G Schwern <schwern\@pobox.com></AUTHOR>}m, |
91 | ' <AUTHOR>' ); |
92 | like( $ppd_html, qr{^\s*<IMPLEMENTATION>}m, ' <IMPLEMENTATION>'); |
93 | like( $ppd_html, qr{^\s*<DEPENDENCY NAME="strict" VERSION="0,0,0,0" />}m, |
94 | ' <DEPENDENCY>' ); |
95 | like( $ppd_html, qr{^\s*<OS NAME="$Config{osname}" />}m, |
96 | ' <OS>' ); |
97 | like( $ppd_html, qr{^\s*<ARCHITECTURE NAME="$Config{archname}" />}m, |
98 | ' <ARCHITECTURE>'); |
99 | like( $ppd_html, qr{^\s*<CODEBASE HREF="" />}m, ' <CODEBASE>'); |
100 | like( $ppd_html, qr{^\s*</IMPLEMENTATION>}m, ' </IMPLEMENTATION>'); |
101 | like( $ppd_html, qr{^\s*</SOFTPKG>}m, ' </SOFTPKG>'); |
102 | END { unlink 'Big-Dummy.ppd' } |
103 | |
104 | |
dedf98bc |
105 | my $test_out = run("$make test"); |
75e2e551 |
106 | like( $test_out, qr/All tests successful/, 'make test' ); |
479d2113 |
107 | is( $?, 0, ' exited normally' ); |
75e2e551 |
108 | |
109 | # Test 'make test TEST_VERBOSE=1' |
110 | my $make_test_verbose = make_macro($make, 'test', TEST_VERBOSE => 1); |
dedf98bc |
111 | $test_out = run("$make_test_verbose"); |
75e2e551 |
112 | like( $test_out, qr/ok \d+ - TEST_VERBOSE/, 'TEST_VERBOSE' ); |
479d2113 |
113 | like( $test_out, qr/All tests successful/, ' successful' ); |
114 | is( $?, 0, ' exited normally' ); |
115 | |
116 | |
dedf98bc |
117 | my $install_out = run("$make install"); |
479d2113 |
118 | is( $?, 0, 'install' ) || diag $install_out; |
119 | like( $install_out, qr/^Installing /m ); |
120 | like( $install_out, qr/^Writing /m ); |
121 | |
1df8d179 |
122 | ok( -r '../dummy-install', ' install dir created' ); |
479d2113 |
123 | my %files = (); |
124 | find( sub { |
125 | # do it case-insensitive for non-case preserving OSs |
126 | $files{lc $_} = $File::Find::name; |
1df8d179 |
127 | }, '../dummy-install' ); |
479d2113 |
128 | ok( $files{'dummy.pm'}, ' Dummy.pm installed' ); |
129 | ok( $files{'liar.pm'}, ' Liar.pm installed' ); |
130 | ok( $files{'.packlist'}, ' packlist created' ); |
131 | ok( $files{'perllocal.pod'},' perllocal.pod created' ); |
132 | |
133 | |
134 | SKIP: { |
135 | skip "VMS install targets do not preserve PREFIX", 8 if $Is_VMS; |
136 | |
dedf98bc |
137 | $install_out = run("$make install PREFIX=elsewhere"); |
479d2113 |
138 | is( $?, 0, 'install with PREFIX override' ) || diag $install_out; |
139 | like( $install_out, qr/^Installing /m ); |
140 | like( $install_out, qr/^Writing /m ); |
141 | |
142 | ok( -r 'elsewhere', ' install dir created' ); |
143 | %files = (); |
144 | find( sub { $files{$_} = $File::Find::name; }, 'elsewhere' ); |
145 | ok( $files{'Dummy.pm'}, ' Dummy.pm installed' ); |
146 | ok( $files{'Liar.pm'}, ' Liar.pm installed' ); |
147 | ok( $files{'.packlist'}, ' packlist created' ); |
148 | ok( $files{'perllocal.pod'},' perllocal.pod created' ); |
149 | } |
150 | |
75e2e551 |
151 | |
dedf98bc |
152 | my $dist_test_out = run("$make disttest"); |
75e2e551 |
153 | is( $?, 0, 'disttest' ) || diag($dist_test_out); |
154 | |
479d2113 |
155 | # Test META.yml generation |
156 | use ExtUtils::Manifest qw(maniread); |
157 | ok( -f 'META.yml', 'META.yml written' ); |
158 | my $manifest = maniread(); |
159 | # VMS is non-case preserving, so we can't know what the MANIFEST will |
160 | # look like. :( |
161 | _normalize($manifest); |
2530b651 |
162 | is( $manifest->{'meta.yml'}, 'Module meta-data (added by MakeMaker)' ); |
479d2113 |
163 | |
431b0fc4 |
164 | # Test NO_META META.yml suppression |
165 | unlink 'META.yml'; |
166 | ok( !-f 'META.yml', 'META.yml deleted' ); |
167 | @mpl_out = run(qq{$perl Makefile.PL "NO_META=1"}); |
168 | cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out); |
169 | my $metafile_out = run("$make metafile"); |
170 | is( $?, 0, 'metafile' ) || diag($metafile_out); |
171 | ok( !-f 'META.yml', 'META.yml generation suppressed by NO_META' ); |
172 | |
1df8d179 |
173 | # Test if MANIFEST is read-only. |
174 | chmod 0444, 'MANIFEST'; |
175 | @mpl_out = run(qq{$perl Makefile.PL}); |
176 | cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out); |
177 | $metafile_out = run("$make metafile_addtomanifest"); |
178 | is( $?, 0, q{metafile_addtomanifest didn't die with locked MANIFEST} ) || |
179 | diag($metafile_out); |
180 | |
e0678a30 |
181 | |
182 | # Make sure init_dirscan doesn't go into the distdir |
1df8d179 |
183 | @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"}); |
e0678a30 |
184 | |
431b0fc4 |
185 | cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diag(@mpl_out); |
e0678a30 |
186 | |
479d2113 |
187 | ok( grep(/^Writing $makefile for Big::Dummy/, @mpl_out) == 1, |
e0678a30 |
188 | 'init_dirscan skipped distdir') || |
189 | diag(@mpl_out); |
190 | |
191 | # I know we'll get ignored errors from make here, that's ok. |
192 | # Send STDERR off to oblivion. |
193 | open(SAVERR, ">&STDERR") or die $!; |
194 | open(STDERR, ">".File::Spec->devnull) or die $!; |
195 | |
dedf98bc |
196 | my $realclean_out = run("$make realclean"); |
75e2e551 |
197 | is( $?, 0, 'realclean' ) || diag($realclean_out); |
198 | |
e0678a30 |
199 | open(STDERR, ">&SAVERR") or die $!; |
200 | close SAVERR; |
479d2113 |
201 | |
202 | |
203 | sub _normalize { |
204 | my $hash = shift; |
205 | |
206 | while(my($k,$v) = each %$hash) { |
207 | delete $hash->{$k}; |
208 | $hash->{lc $k} = $v; |
209 | } |
210 | } |