MM_Unix.pm : work around File::Find problem on VMS
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / t / Constant.t
CommitLineData
9f0ea43f 1#!/usr/bin/perl -w
2
ccc70a53 3print "1..51\n";
af6c647e 4
5BEGIN {
39234879 6 if( $ENV{PERL_CORE} ) {
7 chdir 't' if -d 't';
8 @INC = '../lib';
9 }
af6c647e 10}
11
d7f97632 12# use warnings;
af6c647e 13use strict;
14use ExtUtils::MakeMaker;
15use ExtUtils::Constant qw (constant_types C_constant XS_constant autoload);
16use Config;
357229c3 17use File::Spec::Functions qw(catfile rel2abs);
835f860c 18# Because were are going to be changing directory before running Makefile.PL
8338e367 19my $perl;
d7f97632 20$perl = rel2abs( $^X ) unless $] < 5.006; # Hack. Until 5.00503 has rel2abs
6d79cad2 21# ExtUtils::Constant::C_constant uses $^X inside a comment, and we want to
22# compare output to ensure that it is the same. We were probably run as ./perl
23# whereas we will run the child with the full path in $perl. So make $^X for
24# us the same as our child will see.
25$^X = $perl;
af6c647e 26
835f860c 27print "# perl=$perl\n";
39234879 28my $runperl = "$perl \"-I../../lib\"";
94b1a389 29
af6c647e 30$| = 1;
31
32my $dir = "ext-$$";
0ddb8edc 33my @files;
94b1a389 34
35print "# $dir being created...\n";
36mkdir $dir, 0777 or die "mkdir: $!\n";
37
535acd0f 38my $output = "output";
af6c647e 39
6557ab03 40# For debugging set this to 1.
41my $keep_files = 0;
42
af6c647e 43END {
94b1a389 44 use File::Path;
45 print "# $dir being removed...\n";
6557ab03 46 rmtree($dir) unless $keep_files;
af6c647e 47}
48
6d79cad2 49my $package = "ExtTest";
50
8ac27563 51# Test the code that generates 1 and 2 letter name comparisons.
52my %compass = (
d7f97632 53N => 0, 'NE' => 45, E => 90, SE => 135, S => 180, SW => 225, W => 270, NW => 315
8ac27563 54);
55
cea00dc5 56my $parent_rfc1149 =
57 'A Standard for the Transmission of IP Datagrams on Avian Carriers';
6557ab03 58# Check that 8 bit and unicode names don't cause problems.
63e7cc8f 59my $pound;
60if (ord('A') == 193) { # EBCDIC platform
61 $pound = chr 177; # A pound sign. (Currency)
62} else { # ASCII platform
63 $pound = chr 163; # A pound sign. (Currency)
64}
6557ab03 65my $inf = chr 0x221E;
66# Check that we can distiguish the pathological case of a string, and the
67# utf8 representation of that string.
68my $pound_bytes = my $pound_utf8 = $pound . '1';
69utf8::encode ($pound_bytes);
cea00dc5 70
835f860c 71my @names = ("FIVE", {name=>"OK6", type=>"PV",},
72 {name=>"OK7", type=>"PVN",
73 value=>['"not ok 7\\n\\0ok 7\\n"', 15]},
af6c647e 74 {name => "FARTHING", type=>"NV"},
6d79cad2 75 {name => "NOT_ZERO", type=>"UV", value=>"~(UV)0"},
72f7b9a1 76 {name => "OPEN", type=>"PV", value=>'"/*"', macro=>1},
6d79cad2 77 {name => "CLOSE", type=>"PV", value=>'"*/"',
78 macro=>["#if 1\n", "#endif\n"]},
3414cef0 79 {name => "ANSWER", default=>["UV", 42]}, "NOTDEF",
80 {name => "Yes", type=>"YES"},
81 {name => "No", type=>"NO"},
19d75eda 82 {name => "Undef", type=>"UNDEF"},
cea00dc5 83# OK. It wasn't really designed to allow the creation of dual valued constants.
84# It was more for INADDR_ANY INADDR_BROADCAST INADDR_LOOPBACK INADDR_NONE
85 {name=>"RFC1149", type=>"SV", value=>"sv_2mortal(temp_sv)",
86 pre=>"SV *temp_sv = newSVpv(RFC1149, 0); "
87 . "(void) SvUPGRADE(temp_sv,SVt_PVIV); SvIOK_on(temp_sv); "
88 . "SvIVX(temp_sv) = 1149;"},
6557ab03 89 {name=>"perl", type=>"PV",},
3414cef0 90);
af6c647e 91
8ac27563 92push @names, $_ foreach keys %compass;
93
6557ab03 94# Automatically compile the list of all the macro names, and make them
95# exported constants.
af6c647e 96my @names_only = map {(ref $_) ? $_->{name} : $_} @names;
97
6557ab03 98# Exporter::Heavy (currently) isn't able to export these names:
99push @names, ({name=>"*/", type=>"PV", value=>'"CLOSE"', macro=>1},
100 {name=>"/*", type=>"PV", value=>'"OPEN"', macro=>1},
101 {name=>$pound, type=>"PV", value=>'"Sterling"', macro=>1},
102 {name=>$inf, type=>"PV", value=>'"Infinity"', macro=>1},
103 {name=>$pound_utf8, type=>"PV", value=>'"1 Pound"', macro=>1},
104 {name=>$pound_bytes, type=>"PV", value=>'"1 Pound (as bytes)"',
105 macro=>1},
106 );
107
108=pod
109
110The above set of names seems to produce a suitably bad set of compile
111problems on a Unicode naive version of ExtUtils::Constant (ie 0.11):
112
113nick@thinking-cap 15439-32-utf$ PERL_CORE=1 ./perl lib/ExtUtils/t/Constant.t
1141..33
115# perl=/stuff/perl5/15439-32-utf/perl
116# ext-30370 being created...
117Wide character in print at lib/ExtUtils/t/Constant.t line 140.
118ok 1
119ok 2
120# make = 'make'
121ExtTest.xs: In function `constant_1':
122ExtTest.xs:80: warning: multi-character character constant
123ExtTest.xs:80: warning: case value out of range
124ok 3
125
126=cut
127
6d79cad2 128my $types = {};
129my $constant_types = constant_types(); # macro defs
130my $C_constant = join "\n",
131 C_constant ($package, undef, "IV", $types, undef, undef, @names);
132my $XS_constant = XS_constant ($package, $types); # XS for ExtTest::constant
133
af6c647e 134################ Header
94b1a389 135my $header = catfile($dir, "test.h");
0ddb8edc 136push @files, "test.h";
94b1a389 137open FH, ">$header" or die "open >$header: $!\n";
cea00dc5 138print FH <<"EOT";
835f860c 139#define FIVE 5
7b6ffde5 140#define OK6 "ok 6\\n"
835f860c 141#define OK7 1
af6c647e 142#define FARTHING 0.25
143#define NOT_ZERO 1
3414cef0 144#define Yes 0
145#define No 1
146#define Undef 1
cea00dc5 147#define RFC1149 "$parent_rfc1149"
6d79cad2 148#undef NOTDEF
6557ab03 149#define perl "rules"
af6c647e 150EOT
8ac27563 151
152while (my ($point, $bearing) = each %compass) {
153 print FH "#define $point $bearing\n"
154}
94b1a389 155close FH or die "close $header: $!\n";
af6c647e 156
157################ XS
94b1a389 158my $xs = catfile($dir, "$package.xs");
0ddb8edc 159push @files, "$package.xs";
94b1a389 160open FH, ">$xs" or die "open >$xs: $!\n";
af6c647e 161
162print FH <<'EOT';
163#include "EXTERN.h"
164#include "perl.h"
165#include "XSUB.h"
166EOT
167
168print FH "#include \"test.h\"\n\n";
6d79cad2 169print FH $constant_types;
170print FH $C_constant, "\n";
af6c647e 171print FH "MODULE = $package PACKAGE = $package\n";
172print FH "PROTOTYPES: ENABLE\n";
6d79cad2 173print FH $XS_constant;
94b1a389 174close FH or die "close $xs: $!\n";
af6c647e 175
176################ PM
94b1a389 177my $pm = catfile($dir, "$package.pm");
0ddb8edc 178push @files, "$package.pm";
94b1a389 179open FH, ">$pm" or die "open >$pm: $!\n";
af6c647e 180print FH "package $package;\n";
181print FH "use $];\n";
182
183print FH <<'EOT';
184
185use strict;
d7f97632 186EOT
187printf FH "use warnings;\n" unless $] < 5.006;
188print FH <<'EOT';
af6c647e 189use Carp;
190
191require Exporter;
192require DynaLoader;
d7f97632 193use vars qw ($VERSION @ISA @EXPORT_OK $AUTOLOAD);
af6c647e 194
195$VERSION = '0.01';
196@ISA = qw(Exporter DynaLoader);
197@EXPORT_OK = qw(
198EOT
199
6557ab03 200# Print the names of all our autoloaded constants
af6c647e 201print FH "\t$_\n" foreach (@names_only);
202print FH ");\n";
6557ab03 203# Print the AUTOLOAD subroutine ExtUtils::Constant generated for us
af6c647e 204print FH autoload ($package, $]);
205print FH "bootstrap $package \$VERSION;\n1;\n__END__\n";
94b1a389 206close FH or die "close $pm: $!\n";
af6c647e 207
208################ test.pl
94b1a389 209my $testpl = catfile($dir, "test.pl");
0ddb8edc 210push @files, "test.pl";
94b1a389 211open FH, ">$testpl" or die "open >$testpl: $!\n";
af6c647e 212
6d79cad2 213print FH "use strict;\n";
af6c647e 214print FH "use $package qw(@names_only);\n";
535acd0f 215print FH <<"EOT";
216
6557ab03 217use utf8;
218
535acd0f 219print "1..1\n";
220if (open OUTPUT, ">$output") {
221 print "ok 1\n";
222 select OUTPUT;
223} else {
224 print "not ok 1 # Failed to open '$output': $!\n";
225 exit 1;
226}
227EOT
af6c647e 228
535acd0f 229print FH << 'EOT';
230
231# What follows goes to the temporary file.
6d79cad2 232# IV
835f860c 233my $five = FIVE;
234if ($five == 5) {
235 print "ok 5\n";
af6c647e 236} else {
835f860c 237 print "not ok 5 # $five\n";
af6c647e 238}
239
6d79cad2 240# PV
835f860c 241print OK6;
af6c647e 242
6d79cad2 243# PVN containing embedded \0s
835f860c 244$_ = OK7;
af6c647e 245s/.*\0//s;
246print;
247
6d79cad2 248# NV
af6c647e 249my $farthing = FARTHING;
250if ($farthing == 0.25) {
835f860c 251 print "ok 8\n";
af6c647e 252} else {
835f860c 253 print "not ok 8 # $farthing\n";
af6c647e 254}
255
6d79cad2 256# UV
af6c647e 257my $not_zero = NOT_ZERO;
258if ($not_zero > 0 && $not_zero == ~0) {
835f860c 259 print "ok 9\n";
af6c647e 260} else {
835f860c 261 print "not ok 9 # \$not_zero=$not_zero ~0=" . (~0) . "\n";
af6c647e 262}
263
6d79cad2 264# Value includes a "*/" in an attempt to bust out of a C comment.
265# Also tests custom cpp #if clauses
266my $close = CLOSE;
267if ($close eq '*/') {
268 print "ok 10\n";
269} else {
270 print "not ok 10 # \$close='$close'\n";
271}
272
273# Default values if macro not defined.
274my $answer = ANSWER;
275if ($answer == 42) {
276 print "ok 11\n";
277} else {
278 print "not ok 11 # What do you get if you multiply six by nine? '$answer'\n";
279}
280
281# not defined macro
282my $notdef = eval { NOTDEF; };
283if (defined $notdef) {
284 print "not ok 12 # \$notdef='$notdef'\n";
285} elsif ($@ !~ /Your vendor has not defined ExtTest macro NOTDEF/) {
286 print "not ok 12 # \$@='$@'\n";
287} else {
288 print "ok 12\n";
289}
290
291# not a macro
292my $notthere = eval { &ExtTest::NOTTHERE; };
293if (defined $notthere) {
294 print "not ok 13 # \$notthere='$notthere'\n";
295} elsif ($@ !~ /NOTTHERE is not a valid ExtTest macro/) {
296 chomp $@;
297 print "not ok 13 # \$@='$@'\n";
298} else {
299 print "ok 13\n";
300}
af6c647e 301
3414cef0 302# Truth
303my $yes = Yes;
304if ($yes) {
305 print "ok 14\n";
306} else {
307 print "not ok 14 # $yes='\$yes'\n";
308}
309
310# Falsehood
311my $no = No;
312if (defined $no and !$no) {
313 print "ok 15\n";
314} else {
315 print "not ok 15 # \$no=" . defined ($no) ? "'$no'\n" : "undef\n";
316}
317
318# Undef
319my $undef = Undef;
320unless (defined $undef) {
321 print "ok 16\n";
322} else {
323 print "not ok 16 # \$undef='$undef'\n";
324}
325
8ac27563 326
327# invalid macro (chosen to look like a mix up between No and SW)
328$notdef = eval { &ExtTest::So };
329if (defined $notdef) {
330 print "not ok 17 # \$notdef='$notdef'\n";
331} elsif ($@ !~ /^So is not a valid ExtTest macro/) {
332 print "not ok 17 # \$@='$@'\n";
333} else {
334 print "ok 17\n";
335}
336
337# invalid defined macro
338$notdef = eval { &ExtTest::EW };
339if (defined $notdef) {
340 print "not ok 18 # \$notdef='$notdef'\n";
341} elsif ($@ !~ /^EW is not a valid ExtTest macro/) {
342 print "not ok 18 # \$@='$@'\n";
343} else {
344 print "ok 18\n";
345}
346
347my %compass = (
348EOT
349
350while (my ($point, $bearing) = each %compass) {
d7f97632 351 print FH "'$point' => $bearing, "
8ac27563 352}
353
354print FH <<'EOT';
355
356);
357
358my $fail;
359while (my ($point, $bearing) = each %compass) {
360 my $val = eval $point;
361 if ($@) {
362 print "# $point: \$@='$@'\n";
363 $fail = 1;
364 } elsif (!defined $bearing) {
365 print "# $point: \$val=undef\n";
366 $fail = 1;
367 } elsif ($val != $bearing) {
368 print "# $point: \$val=$val, not $bearing\n";
369 $fail = 1;
370 }
371}
372if ($fail) {
373 print "not ok 19\n";
374} else {
375 print "ok 19\n";
376}
377
af6c647e 378EOT
379
cea00dc5 380print FH <<"EOT";
381my \$rfc1149 = RFC1149;
382if (\$rfc1149 ne "$parent_rfc1149") {
383 print "not ok 20 # '\$rfc1149' ne '$parent_rfc1149'\n";
384} else {
385 print "ok 20\n";
386}
387
388if (\$rfc1149 != 1149) {
389 printf "not ok 21 # %d != 1149\n", \$rfc1149;
390} else {
391 print "ok 21\n";
392}
72f7b9a1 393
394EOT
395
396print FH <<'EOT';
397# test macro=>1
398my $open = OPEN;
399if ($open eq '/*') {
400 print "ok 22\n";
401} else {
402 print "not ok 22 # \$open='$open'\n";
403}
cea00dc5 404EOT
6557ab03 405
406# Do this in 7 bit in case someone is testing with some settings that cause
407# 8 bit files incapable of storing this character.
408my @values
409 = map {"'" . join (",", unpack "U*", $_) . "'"}
410 ($pound, $inf, $pound_bytes, $pound_utf8);
411# Values is a list of strings, such as ('194,163,49', '163,49')
412
413print FH <<'EOT';
414
415# I can see that this child test program might be about to use parts of
416# Test::Builder
417
418my $test = 23;
419my ($pound, $inf, $pound_bytes, $pound_utf8) = map {eval "pack 'U*', $_"}
420EOT
421
422print FH join ",", @values;
423
424print FH << 'EOT';
425;
426
427foreach (["perl", "rules", "rules"],
428 ["/*", "OPEN", "OPEN"],
429 ["*/", "CLOSE", "CLOSE"],
430 [$pound, 'Sterling', []],
431 [$inf, 'Infinity', []],
432 [$pound_utf8, '1 Pound', '1 Pound (as bytes)'],
433 [$pound_bytes, '1 Pound (as bytes)', []],
434 ) {
435 # Flag an expected error with a reference for the expect string.
436 my ($string, $expect, $expect_bytes) = @$_;
437 (my $name = $string) =~ s/([^ -~])/sprintf '\x{%X}', ord $1/ges;
438 print "# \"$name\" => \'$expect\'\n";
439 # Try to force this to be bytes if possible.
440 utf8::downgrade ($string, 1);
441EOT
442
443print FH "my (\$error, \$got) = ${package}::constant (\$string);\n";
444
445print FH <<'EOT';
446 if ($error or $got ne $expect) {
447 print "not ok $test # error '$error', got '$got'\n";
448 } else {
449 print "ok $test\n";
450 }
451 $test++;
452 print "# Now upgrade '$name' to utf8\n";
453 utf8::upgrade ($string);
454EOT
455
456print FH "my (\$error, \$got) = ${package}::constant (\$string);\n";
457
458print FH <<'EOT';
459 if ($error or $got ne $expect) {
460 print "not ok $test # error '$error', got '$got'\n";
461 } else {
462 print "ok $test\n";
463 }
464 $test++;
465 if (defined $expect_bytes) {
466 print "# And now with the utf8 byte sequence for name\n";
467 # Try the encoded bytes.
468 utf8::encode ($string);
469EOT
470
471print FH "my (\$error, \$got) = ${package}::constant (\$string);\n";
472
473print FH <<'EOT';
474 if (ref $expect_bytes) {
475 # Error expected.
476 if ($error) {
477 print "ok $test # error='$error' (as expected)\n";
478 } else {
479 print "not ok $test # expected error, got no error and '$got'\n";
480 }
481 } elsif ($got ne $expect_bytes) {
482 print "not ok $test # error '$error', expect '$expect_bytes', got '$got'\n";
483 } else {
484 print "ok $test\n";
485 }
486 $test++;
487 }
488}
489EOT
490
94b1a389 491close FH or die "close $testpl: $!\n";
af6c647e 492
6557ab03 493# This is where the test numbers carry on after the test number above are
494# relayed
495my $test = 44;
496
835f860c 497################ Makefile.PL
6d79cad2 498# We really need a Makefile.PL because make test for a no dynamic linking perl
499# will run Makefile.PL again as part of the "make perl" target.
94b1a389 500my $makefilePL = catfile($dir, "Makefile.PL");
0ddb8edc 501push @files, "Makefile.PL";
94b1a389 502open FH, ">$makefilePL" or die "open >$makefilePL: $!\n";
835f860c 503print FH <<"EOT";
6d79cad2 504#!$perl -w
835f860c 505use ExtUtils::MakeMaker;
506WriteMakefile(
507 'NAME' => "$package",
508 'VERSION_FROM' => "$package.pm", # finds \$VERSION
509 (\$] >= 5.005 ?
510 (#ABSTRACT_FROM => "$package.pm", # XXX add this
511 AUTHOR => "$0") : ())
512 );
513EOT
514
94b1a389 515close FH or die "close $makefilePL: $!\n";
af6c647e 516
ccc70a53 517################ MANIFEST
518# We really need a MANIFEST because make distclean checks it.
519my $manifest = catfile($dir, "MANIFEST");
520push @files, "MANIFEST";
521open FH, ">$manifest" or die "open >$manifest: $!\n";
522print FH "$_\n" foreach @files;
523close FH or die "close $manifest: $!\n";
524
af6c647e 525chdir $dir or die $!; push @INC, '../../lib';
526END {chdir ".." or warn $!};
527
4bfb3f62 528my @perlout = `$runperl Makefile.PL PERL_CORE=1`;
835f860c 529if ($?) {
530 print "not ok 1 # $runperl Makefile.PL failed: $?\n";
531 print "# $_" foreach @perlout;
532 exit($?);
533} else {
534 print "ok 1\n";
535}
536
537
24874030 538my $makefile = ($^O eq 'VMS' ? 'descrip' : 'Makefile');
539my $makefile_ext = ($^O eq 'VMS' ? '.mms' : '');
540if (-f "$makefile$makefile_ext") {
835f860c 541 print "ok 2\n";
af6c647e 542} else {
835f860c 543 print "not ok 2\n";
af6c647e 544}
ccc70a53 545
546# Renamed by make clean
547my $makefile_rename = $makefile . ($^O eq 'VMS' ? '.mms' : '.old');
af6c647e 548
549my $make = $Config{make};
94b1a389 550
af6c647e 551$make = $ENV{MAKE} if exists $ENV{MAKE};
94b1a389 552
91e5ac1f 553if ($^O eq 'MSWin32' && $make eq 'nmake') { $make .= " -nologo"; }
76f26e35 554
535acd0f 555my @makeout;
94b1a389 556
8b2eb6ba 557if ($^O eq 'VMS') { $make .= ' all'; }
af6c647e 558print "# make = '$make'\n";
535acd0f 559@makeout = `$make`;
94b1a389 560if ($?) {
835f860c 561 print "not ok 3 # $make failed: $?\n";
535acd0f 562 print "# $_" foreach @makeout;
94b1a389 563 exit($?);
af6c647e 564} else {
835f860c 565 print "ok 3\n";
566}
567
8b2eb6ba 568if ($^O eq 'VMS') { $make =~ s{ all}{}; }
569
835f860c 570if ($Config{usedl}) {
571 print "ok 4\n";
572} else {
835f860c 573 my $makeperl = "$make perl";
574 print "# make = '$makeperl'\n";
535acd0f 575 @makeout = `$makeperl`;
835f860c 576 if ($?) {
577 print "not ok 4 # $makeperl failed: $?\n";
535acd0f 578 print "# $_" foreach @makeout;
835f860c 579 exit($?);
580 } else {
581 print "ok 4\n";
582 }
af6c647e 583}
584
0ddb8edc 585my $maketest = "$make test";
586print "# make = '$maketest'\n";
3414cef0 587
535acd0f 588@makeout = `$maketest`;
94b1a389 589
535acd0f 590if (open OUTPUT, "<$output") {
591 print while <OUTPUT>;
592 close OUTPUT or print "# Close $output failed: $!\n";
593} else {
594 # Harness will report missing test results at this point.
595 print "# Open <$output failed: $!\n";
596}
835f860c 597
3414cef0 598if ($?) {
599 print "not ok $test # $maketest failed: $?\n";
535acd0f 600 print "# $_" foreach @makeout;
3414cef0 601} else {
39234879 602 print "ok $test - maketest\n";
6d79cad2 603}
604$test++;
605
39234879 606
607# -x is busted on Win32 < 5.6.1, so we emulate it.
608my $regen;
609if( $^O eq 'MSWin32' && $] <= 5.006001 ) {
610 open(REGENTMP, ">regentmp") or die $!;
611 open(XS, "$package.xs") or die $!;
612 my $saw_shebang;
613 while(<XS>) {
614 $saw_shebang++ if /^#!.*/i ;
615 print REGENTMP $_ if $saw_shebang;
616 }
617 close XS; close REGENTMP;
618 $regen = `$runperl regentmp`;
619 unlink 'regentmp';
620}
621else {
622 $regen = `$runperl -x $package.xs`;
623}
6d79cad2 624if ($?) {
39234879 625 print "not ok $test # $runperl -x $package.xs failed: $?\n";
6d79cad2 626} else {
39234879 627 print "ok $test - regen\n";
af6c647e 628}
6d79cad2 629$test++;
630
631my $expect = $constant_types . $C_constant .
632 "\n#### XS Section:\n" . $XS_constant;
633
634if ($expect eq $regen) {
39234879 635 print "ok $test - regen worked\n";
6d79cad2 636} else {
39234879 637 print "not ok $test - regen worked\n";
6d79cad2 638 # open FOO, ">expect"; print FOO $expect;
639 # open FOO, ">regen"; print FOO $regen; close FOO;
640}
641$test++;
0ddb8edc 642
643my $makeclean = "$make clean";
644print "# make = '$makeclean'\n";
535acd0f 645@makeout = `$makeclean`;
0ddb8edc 646if ($?) {
6d79cad2 647 print "not ok $test # $make failed: $?\n";
535acd0f 648 print "# $_" foreach @makeout;
0ddb8edc 649} else {
6d79cad2 650 print "ok $test\n";
0ddb8edc 651}
6d79cad2 652$test++;
0ddb8edc 653
ccc70a53 654sub check_for_bonus_files {
655 my $dir = shift;
67dff657 656 my %expect = map {($^O eq 'VMS' ? lc($_) : $_), 1} @_;
ccc70a53 657
658 my $fail;
659 opendir DIR, $dir or die "opendir '$dir': $!";
660 while (defined (my $entry = readdir DIR)) {
67dff657 661 $entry =~ s/\.$// if $^O eq 'VMS'; # delete trailing dot that indicates no extension
ccc70a53 662 next if $expect{$entry};
663 print "# Extra file '$entry'\n";
664 $fail = 1;
6557ab03 665 }
0ddb8edc 666
ccc70a53 667 closedir DIR or warn "closedir '.': $!";
668 if ($fail) {
669 print "not ok $test\n";
670 } else {
671 print "ok $test\n";
672 }
673 $test++;
0ddb8edc 674}
ccc70a53 675
676check_for_bonus_files ('.', @files, $output, $makefile_rename, '.', '..');
677
678rename $makefile_rename, $makefile
679 or die "Can't rename '$makefile_rename' to '$makefile': $!";
680
681unlink $output or warn "Can't unlink '$output': $!";
682
683# Need to make distclean to remove ../../lib/ExtTest.pm
684my $makedistclean = "$make distclean";
685print "# make = '$makedistclean'\n";
686@makeout = `$makedistclean`;
687if ($?) {
688 print "not ok $test # $make failed: $?\n";
689 print "# $_" foreach @makeout;
0ddb8edc 690} else {
6d79cad2 691 print "ok $test\n";
0ddb8edc 692}
ccc70a53 693$test++;
694
695check_for_bonus_files ('.', @files, '.', '..');
696
697unless ($keep_files) {
698 foreach (@files) {
699 unlink $_ or warn "unlink $_: $!";
700 }
701}
702
703check_for_bonus_files ('.', '.', '..');