use strict;
use Test;
BEGIN { plan tests => 10 };
+use DynaLoader;
use ExtUtils::ParseXS qw(process_file);
use ExtUtils::CBuilder;
ok(1); # If we made it this far, we're loaded.
process_file( filename => 'XSTest.xs', output => \*FH, prototypes => 1 );
ok tied(*FH)->content, '/is_even/', "Test that output contains some text";
+my $source_file = 'XSTest.c';
+
# Try sending to file
-process_file( filename => 'XSTest.xs', output => 'XSTest.c', prototypes => 0 );
-ok -e 'XSTest.c', 1, "Create an output file";
+process_file(filename => 'XSTest.xs', output => $source_file, prototypes => 0);
+ok -e $source_file, 1, "Create an output file";
# TEST doesn't like extraneous output
my $quiet = $ENV{PERL_CORE} && !$ENV{HARNESS_ACTIVE};
if ($b->have_compiler) {
my $module = 'XSTest';
- my $obj_file = $b->compile( source => "$module.c" );
+ my $obj_file = $b->compile( source => $source_file );
ok $obj_file;
ok -e $obj_file, 1, "Make sure $obj_file exists";
ok XSTest::is_even(8);
ok !XSTest::is_even(9);
+ # Win32 needs to close the DLL before it can unlink it, but unfortunately
+ # dl_unload_file was missing on Win32 prior to perl change #24679!
+ if ($^O eq 'MSWin32' and defined &DynaLoader::dl_unload_file) {
+ for (my $i = 0; $i < @DynaLoader::dl_modules; $i++) {
+ if ($DynaLoader::dl_modules[$i] eq $module) {
+ DynaLoader::dl_unload_file($DynaLoader::dl_librefs[$i]);
+ last;
+ }
+ }
+ }
+ unlink $lib_file;
} else {
- skip "Skipped can't find a C compiler & linker", 1 for 1..6;
+ skip "Skipped can't find a C compiler & linker", 1 for 1..7;
}
+unlink $source_file;
+
#####################################################################
sub Foo::TIEHANDLE { bless {}, 'Foo' }