7 use ExtUtils::CBuilder;
10 plan skip_all => "INTERFACE keyword support broken before 5.8";
16 my ($source_file, $obj_file, $lib_file, $module);
18 require_ok( 'ExtUtils::ParseXS' );
19 ExtUtils::ParseXS->import('process_file');
21 chdir 't' or die "Can't chdir to t/, $!";
23 use Carp; $SIG{__WARN__} = \&Carp::cluck;
25 #########################
27 $source_file = 'XSUsage.c';
30 process_file(filename => 'XSUsage.xs', output => $source_file);
31 ok -e $source_file, "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);
40 skip "no compiler available", 2
41 if ! $b->have_compiler;
44 $obj_file = $b->compile( source => $source_file );
46 ok -e $obj_file, "Make sure $obj_file exists";
49 skip "no dynamic loading", 20
50 if !$b->have_compiler || !$Config{usedl};
52 $lib_file = $b->link( objects => $obj_file, module_name => $module );
54 ok -e $lib_file, "Make sure $lib_file exists";
56 eval {require XSUsage};
59 # The real tests here - for each way of calling the functions, call with the
60 # wrong number of arguments and check the Usage line is what we expect
62 eval { XSUsage::one(1) };
64 ok $@ =~ /^Usage: XSUsage::one/;
66 eval { XSUsage::two(1) };
68 ok $@ =~ /^Usage: XSUsage::two/;
70 eval { XSUsage::two_x(1) };
72 ok $@ =~ /^Usage: XSUsage::two_x/;
76 ok $@ =~ /^Usage: FOO::two/;
78 eval { XSUsage::three(1) };
80 ok $@ =~ /^Usage: XSUsage::three/;
82 eval { XSUsage::four(1) };
85 eval { XSUsage::five() };
87 ok $@ =~ /^Usage: XSUsage::five/;
89 eval { XSUsage::six() };
92 eval { XSUsage::six(1) };
95 eval { XSUsage::six(1,2) };
97 ok $@ =~ /^Usage: XSUsage::six/;
99 # Win32 needs to close the DLL before it can unlink it, but unfortunately
100 # dl_unload_file was missing on Win32 prior to perl change #24679!
101 if ($^O eq 'MSWin32' and defined &DynaLoader::dl_unload_file) {
102 for (my $i = 0; $i < @DynaLoader::dl_modules; $i++) {
103 if ($DynaLoader::dl_modules[$i] eq $module) {
104 DynaLoader::dl_unload_file($DynaLoader::dl_librefs[$i]);
111 unless ($ENV{PERL_NO_CLEANUP}) {
112 for ( $obj_file, $lib_file, $source_file) {
113 next unless defined $_;