7 use ExtUtils::CBuilder;
11 my ($source_file, $obj_file, $lib_file);
13 require_ok( 'ExtUtils::ParseXS' );
14 ExtUtils::ParseXS->import('process_file');
16 chdir 't' or die "Can't chdir to t/, $!";
18 use Carp; $SIG{__WARN__} = \&Carp::cluck;
20 #########################
22 # Try sending to filehandle
24 process_file( filename => 'XSTest.xs', output => \*FH, prototypes => 1 );
25 like tied(*FH)->content, '/is_even/', "Test that output contains some text";
27 $source_file = 'XSTest.c';
30 process_file(filename => 'XSTest.xs', output => $source_file, prototypes => 0);
31 ok -e $source_file, "Create an output file";
33 my $quiet = $ENV{PERL_CORE} && !$ENV{HARNESS_ACTIVE};
34 my $b = ExtUtils::CBuilder->new(quiet => $quiet);
37 skip "no compiler available", 2
38 if ! $b->have_compiler;
39 $obj_file = $b->compile( source => $source_file );
41 ok -e $obj_file, "Make sure $obj_file exists";
45 skip "no dynamic loading", 5
46 if !$b->have_compiler || !$Config{usedl};
47 my $module = 'XSTest';
48 $lib_file = $b->link( objects => $obj_file, module_name => $module );
50 ok -e $lib_file, "Make sure $lib_file exists";
52 eval {require XSTest};
54 ok XSTest::is_even(8);
55 ok !XSTest::is_even(9);
57 # Win32 needs to close the DLL before it can unlink it, but unfortunately
58 # dl_unload_file was missing on Win32 prior to perl change #24679!
59 if ($^O eq 'MSWin32' and defined &DynaLoader::dl_unload_file) {
60 for (my $i = 0; $i < @DynaLoader::dl_modules; $i++) {
61 if ($DynaLoader::dl_modules[$i] eq $module) {
62 DynaLoader::dl_unload_file($DynaLoader::dl_librefs[$i]);
69 unless ($ENV{PERL_NO_CLEANUP}) {
70 for ( $obj_file, $lib_file, $source_file) {
71 next unless defined $_;
76 #####################################################################
78 sub Foo::TIEHANDLE { bless {}, 'Foo' }
79 sub Foo::PRINT { shift->{buf} .= join '', @_ }
80 sub Foo::content { shift->{buf} }