6 chdir '../lib/ExtUtils/ParseXS'
7 or die "Can't chdir to lib/ExtUtils/ParseXS: $!";
8 @INC = qw(../.. ../../.. .);
15 use ExtUtils::CBuilder;
18 plan skip_all => "INTERFACE keyword support broken before 5.8";
24 my ($source_file, $obj_file, $lib_file, $module);
26 require_ok( 'ExtUtils::ParseXS' );
27 ExtUtils::ParseXS->import('process_file');
29 chdir 't' or die "Can't chdir to t/, $!";
31 use Carp; $SIG{__WARN__} = \&Carp::cluck;
33 #########################
35 $source_file = 'XSUsage.c';
38 process_file(filename => 'XSUsage.xs', output => $source_file);
39 ok -e $source_file, "Create an output file";
41 # TEST doesn't like extraneous output
42 my $quiet = $ENV{PERL_CORE} && !$ENV{HARNESS_ACTIVE};
44 # Try to compile the file! Don't get too fancy, though.
45 my $b = ExtUtils::CBuilder->new(quiet => $quiet);
48 skip "no compiler available", 2
49 if ! $b->have_compiler;
52 $obj_file = $b->compile( source => $source_file );
54 ok -e $obj_file, "Make sure $obj_file exists";
57 skip "no dynamic loading", 20
58 if !$b->have_compiler || !$Config{usedl};
60 $lib_file = $b->link( objects => $obj_file, module_name => $module );
62 ok -e $lib_file, "Make sure $lib_file exists";
64 eval {require XSUsage};
67 # The real tests here - for each way of calling the functions, call with the
68 # wrong number of arguments and check the Usage line is what we expect
70 eval { XSUsage::one(1) };
72 ok $@ =~ /^Usage: XSUsage::one/;
74 eval { XSUsage::two(1) };
76 ok $@ =~ /^Usage: XSUsage::two/;
78 eval { XSUsage::two_x(1) };
80 ok $@ =~ /^Usage: XSUsage::two_x/;
84 ok $@ =~ /^Usage: FOO::two/;
86 eval { XSUsage::three(1) };
88 ok $@ =~ /^Usage: XSUsage::three/;
90 eval { XSUsage::four(1) };
93 eval { XSUsage::five() };
95 ok $@ =~ /^Usage: XSUsage::five/;
97 eval { XSUsage::six() };
100 eval { XSUsage::six(1) };
103 eval { XSUsage::six(1,2) };
105 ok $@ =~ /^Usage: XSUsage::six/;
107 # Win32 needs to close the DLL before it can unlink it, but unfortunately
108 # dl_unload_file was missing on Win32 prior to perl change #24679!
109 if ($^O eq 'MSWin32' and defined &DynaLoader::dl_unload_file) {
110 for (my $i = 0; $i < @DynaLoader::dl_modules; $i++) {
111 if ($DynaLoader::dl_modules[$i] eq $module) {
112 DynaLoader::dl_unload_file($DynaLoader::dl_librefs[$i]);
119 unless ($ENV{PERL_NO_CLEANUP}) {
120 for ( $obj_file, $lib_file, $source_file) {
121 next unless defined $_;