6 chdir '../lib/ExtUtils/ParseXS'
7 or die "Can't chdir to lib/ExtUtils/ParseXS: $!";
8 @INC = qw(../.. ../../.. .);
13 BEGIN { plan tests => 10 };
15 use ExtUtils::ParseXS qw(process_file);
16 use ExtUtils::CBuilder;
17 ok(1); # If we made it this far, we're loaded.
19 chdir 't' or die "Can't chdir to t/, $!";
21 use Carp; $SIG{__WARN__} = \&Carp::cluck;
23 #########################
25 # Try sending to filehandle
27 process_file( filename => 'XSTest.xs', output => \*FH, prototypes => 1 );
28 ok tied(*FH)->content, '/is_even/', "Test that output contains some text";
30 my $source_file = 'XSTest.c';
33 process_file(filename => 'XSTest.xs', output => $source_file, prototypes => 0);
34 ok -e $source_file, 1, "Create an output file";
36 # TEST doesn't like extraneous output
37 my $quiet = $ENV{PERL_CORE} && !$ENV{HARNESS_ACTIVE};
39 # Try to compile the file! Don't get too fancy, though.
40 my $b = ExtUtils::CBuilder->new(quiet => $quiet);
41 if ($b->have_compiler) {
42 my $module = 'XSTest';
44 my $obj_file = $b->compile( source => $source_file );
46 ok -e $obj_file, 1, "Make sure $obj_file exists";
48 my $lib_file = $b->link( objects => $obj_file, module_name => $module );
50 ok -e $lib_file, 1, "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 skip "Skipped can't find a C compiler & linker", 1 for 1..7;
74 #####################################################################
76 sub Foo::TIEHANDLE { bless {}, 'Foo' }
77 sub Foo::PRINT { shift->{buf} .= join '', @_ }
78 sub Foo::content { shift->{buf} }