6 chdir '../lib/ExtUtils/ParseXS'
7 or die "Can't chdir to lib/ExtUtils/ParseXS: $!";
8 @INC = qw(../.. ../../.. .);
13 BEGIN { plan tests => 10 };
14 use ExtUtils::ParseXS qw(process_file);
15 use ExtUtils::CBuilder;
16 ok(1); # If we made it this far, we're loaded.
18 chdir 't' or die "Can't chdir to t/, $!";
20 use Carp; $SIG{__WARN__} = \&Carp::cluck;
22 #########################
24 # Try sending to filehandle
26 process_file( filename => 'XSTest.xs', output => \*FH, prototypes => 1 );
27 ok tied(*FH)->content, '/is_even/', "Test that output contains some text";
30 process_file( filename => 'XSTest.xs', output => 'XSTest.c', prototypes => 0 );
31 ok -e 'XSTest.c', 1, "Create an output file";
33 # TEST doesn't like extraneous output
34 my $quiet = $ENV{PERL_CORE} && !$ENV{HARNESS_ACTIVE};
36 # Try to compile the file! Don't get too fancy, though.
37 my $b = ExtUtils::CBuilder->new(quiet => $quiet);
38 if ($b->have_compiler) {
39 my $module = 'XSTest';
41 my $obj_file = $b->compile( source => "$module.c" );
43 ok -e $obj_file, 1, "Make sure $obj_file exists";
45 my $lib_file = $b->link( objects => $obj_file, module_name => $module );
47 ok -e $lib_file, 1, "Make sure $lib_file exists";
49 eval {require XSTest};
51 ok XSTest::is_even(8);
52 ok !XSTest::is_even(9);
55 skip "Skipped can't find a C compiler & linker", 1 for 1..6;
58 #####################################################################
60 sub Foo::TIEHANDLE { bless {}, 'Foo' }
61 sub Foo::PRINT { shift->{buf} .= join '', @_ }
62 sub Foo::content { shift->{buf} }