6 chdir '../lib/ExtUtils/ParseXS'
7 or die "Can't chdir to lib/ExtUtils/ParseXS: $!";
8 @INC = qw(../.. ../../.. .);
15 use ExtUtils::CBuilder;
19 my ($source_file, $obj_file, $lib_file);
21 require_ok( 'ExtUtils::ParseXS' );
22 ExtUtils::ParseXS->import('process_file');
24 chdir 't' or die "Can't chdir to t/, $!";
26 use Carp; $SIG{__WARN__} = \&Carp::cluck;
28 #########################
30 # Try sending to filehandle
32 process_file( filename => 'XSTest.xs', output => \*FH, prototypes => 1 );
33 like tied(*FH)->content, '/is_even/', "Test that output contains some text";
35 $source_file = 'XSTest.c';
38 process_file(filename => 'XSTest.xs', output => $source_file, prototypes => 0);
39 ok -e $source_file, "Create an output file";
41 my $quiet = $ENV{PERL_CORE} && !$ENV{HARNESS_ACTIVE};
42 my $b = ExtUtils::CBuilder->new(quiet => $quiet);
45 skip "no compiler available", 2
46 if ! $b->have_compiler;
47 $obj_file = $b->compile( source => $source_file );
49 ok -e $obj_file, "Make sure $obj_file exists";
53 skip "no dynamic loading", 5
54 if !$b->have_compiler || !$Config{usedl};
55 my $module = 'XSTest';
56 $lib_file = $b->link( objects => $obj_file, module_name => $module );
58 ok -e $lib_file, "Make sure $lib_file exists";
60 eval {require XSTest};
62 ok XSTest::is_even(8);
63 ok !XSTest::is_even(9);
65 # Win32 needs to close the DLL before it can unlink it, but unfortunately
66 # dl_unload_file was missing on Win32 prior to perl change #24679!
67 if ($^O eq 'MSWin32' and defined &DynaLoader::dl_unload_file) {
68 for (my $i = 0; $i < @DynaLoader::dl_modules; $i++) {
69 if ($DynaLoader::dl_modules[$i] eq $module) {
70 DynaLoader::dl_unload_file($DynaLoader::dl_librefs[$i]);
77 unless ($ENV{PERL_NO_CLEANUP}) {
78 for ( $obj_file, $lib_file, $source_file) {
79 next unless defined $_;
84 #####################################################################
86 sub Foo::TIEHANDLE { bless {}, 'Foo' }
87 sub Foo::PRINT { shift->{buf} .= join '', @_ }
88 sub Foo::content { shift->{buf} }