12 use ExtUtils::MakeMaker;
13 use ExtUtils::Constant qw (constant_types C_constant XS_constant autoload);
23 print "# $dir being created...\n";
24 mkdir $dir, 0777 or die "mkdir: $!\n";
26 use File::Spec::Functions;
30 print "# $dir being removed...\n";
34 my @names = ("THREE", {name=>"OK4", type=>"PV",},
35 {name=>"OK5", type=>"PVN",
36 value=>['"not ok 5\\n\\0ok 5\\n"', 15]},
37 {name => "FARTHING", type=>"NV"},
38 {name => "NOT_ZERO", type=>"UV", value=>"~(UV)0"});
40 my @names_only = map {(ref $_) ? $_->{name} : $_} @names;
42 my $package = "ExtTest";
43 ################ Header
44 my $header = catfile($dir, "test.h");
45 push @files, "test.h";
46 open FH, ">$header" or die "open >$header: $!\n";
54 close FH or die "close $header: $!\n";
57 my $xs = catfile($dir, "$package.xs");
58 push @files, "$package.xs";
59 open FH, ">$xs" or die "open >$xs: $!\n";
67 print FH "#include \"test.h\"\n\n";
68 print FH constant_types(); # macro defs
70 foreach (C_constant (undef, "IV", $types, undef, undef, @names) ) {
71 print FH $_, "\n"; # C constant subs
73 print FH "MODULE = $package PACKAGE = $package\n";
74 print FH "PROTOTYPES: ENABLE\n";
75 print FH XS_constant ($package, $types); # XS for ExtTest::constant
76 close FH or die "close $xs: $!\n";
79 my $pm = catfile($dir, "$package.pm");
80 push @files, "$package.pm";
81 open FH, ">$pm" or die "open >$pm: $!\n";
82 print FH "package $package;\n";
94 use vars qw ($VERSION @ISA @EXPORT_OK);
97 @ISA = qw(Exporter DynaLoader);
101 print FH "\t$_\n" foreach (@names_only);
103 print FH autoload ($package, $]);
104 print FH "bootstrap $package \$VERSION;\n1;\n__END__\n";
105 close FH or die "close $pm: $!\n";
107 ################ test.pl
108 my $testpl = catfile($dir, "test.pl");
109 push @files, "test.pl";
110 open FH, ">$testpl" or die "open >$testpl: $!\n";
112 print FH "use $package qw(@names_only);\n";
119 print "not ok 3 # $three\n";
128 my $farthing = FARTHING;
129 if ($farthing == 0.25) {
132 print "not ok 6 # $farthing\n";
135 my $not_zero = NOT_ZERO;
136 if ($not_zero > 0 && $not_zero == ~0) {
139 print "not ok 7 # \$not_zero=$not_zero ~0=" . (~0) . "\n";
145 close FH or die "close $testpl: $!\n";
147 ################ dummy Makefile.PL
148 # Keep the dependancy in the Makefile happy
149 my $makefilePL = catfile($dir, "Makefile.PL");
150 push @files, "Makefile.PL";
151 open FH, ">$makefilePL" or die "open >$makefilePL: $!\n";
152 close FH or die "close $makefilePL: $!\n";
154 chdir $dir or die $!; push @INC, '../../lib';
155 END {chdir ".." or warn $!};
157 # Grr. MakeMaker hardwired to write its message to STDOUT.
161 'VERSION_FROM' => "$package.pm", # finds $VERSION
163 (#ABSTRACT_FROM => "$package.pm", # XXX add this
171 push @files, "Makefile.old"; # Renamed by make clean
173 my $make = $Config{make};
175 $make = $ENV{MAKE} if exists $ENV{MAKE};
179 print "# make = '$make'\n";
182 print "not ok 2 # $make failed: $?\n";
188 my $maketest = "$make test";
189 print "# make = '$maketest'\n";
190 $makeout = `$maketest`;
192 print "not ok 8 # $make failed: $?\n";
195 $makeout =~ s/^\s*PERL_DL_NONLAZY=.+?\n//m;
198 $makeout =~ s/^\w*?make.+?(?:entering|leaving) directory.+?\n//mig;
204 my $makeclean = "$make clean";
205 print "# make = '$makeclean'\n";
206 $makeout = `$makeclean`;
208 print "not ok 9 # $make failed: $?\n";
214 unlink $_ or warn "unlink $_: $!";
218 opendir DIR, "." or die "opendir '.': $!";
219 while (defined (my $entry = readdir DIR)) {
220 next if $entry =~ /^\.\.?$/;
221 print "# Extra file '$entry'\n";
224 closedir DIR or warn "closedir '.': $!";