summaryrefslogtreecommitdiff
path: root/dist/ExtUtils-ParseXS
diff options
context:
space:
mode:
authorJames E Keenan <jkeenan@cpan.org>2013-08-17 01:59:23 +0200
committerJames E Keenan <jkeenan@cpan.org>2013-08-17 16:08:47 +0200
commit21ae0dea1efe484f558dae7c3e9b0afb133318a3 (patch)
treef555c1bb63db59e7f5e200e18a45531094662ce3 /dist/ExtUtils-ParseXS
parentc7996136baeaaa191957ae813685ec6a2b133bf9 (diff)
downloadperl-21ae0dea1efe484f558dae7c3e9b0afb133318a3.tar.gz
Avert crashes when testing in parallel.
Both t/001-basic.t and what was t/004-nolinenumbers.t were trying to write to a 't/XSTest.c' file. When run in parallel, this was causing problems when TEST_JOBS >= 1 (2 on some boxes, 4 on dromedary). Since all that t/004-nolinenumbers.t was ever trying to do was to run process_file() without line numbers -- a case not exercised prior to my 2009-11 refactoring/test additions -- the simplest way to avoid these problems is to stuff the tests from t/004 into t/001 and delete t/001. For: RT #119231
Diffstat (limited to 'dist/ExtUtils-ParseXS')
-rw-r--r--dist/ExtUtils-ParseXS/t/001-basic.t84
-rw-r--r--dist/ExtUtils-ParseXS/t/004-nolinenumbers.t100
2 files changed, 83 insertions, 101 deletions
diff --git a/dist/ExtUtils-ParseXS/t/001-basic.t b/dist/ExtUtils-ParseXS/t/001-basic.t
index a1b9f1d933..a2d3c6b0c1 100644
--- a/dist/ExtUtils-ParseXS/t/001-basic.t
+++ b/dist/ExtUtils-ParseXS/t/001-basic.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl
use strict;
-use Test::More tests => 14;
+use Test::More tests => 24;
use Config;
use DynaLoader;
use ExtUtils::CBuilder;
@@ -16,6 +16,7 @@ use Carp; $SIG{__WARN__} = \&Carp::cluck;
#########################
+{ # first block: try without linenumbers
my $pxs = ExtUtils::ParseXS->new;
# Try sending to filehandle
tie *FH, 'Foo';
@@ -121,7 +122,88 @@ unless ($ENV{PERL_NO_CLEANUP}) {
1 while unlink $_;
}
}
+}
+
+#####################################################################
+
+{ # second block: try with linenumbers
+my $pxs = ExtUtils::ParseXS->new;
+# Try sending to filehandle
+tie *FH, 'Foo';
+$pxs->process_file(
+ filename => 'XSTest.xs',
+ output => \*FH,
+ prototypes => 1,
+ linenumbers => 0,
+);
+like tied(*FH)->content, '/is_even/', "Test that output contains some text";
+
+$source_file = 'XSTest.c';
+
+# Try sending to file
+$pxs->process_file(
+ filename => 'XSTest.xs',
+ output => $source_file,
+ prototypes => 0,
+ linenumbers => 0,
+);
+ok -e $source_file, "Create an output file";
+
+my $quiet = $ENV{PERL_CORE} && !$ENV{HARNESS_ACTIVE};
+my $b = ExtUtils::CBuilder->new(quiet => $quiet);
+
+SKIP: {
+ skip "no compiler available", 2
+ if ! $b->have_compiler;
+ $obj_file = $b->compile( source => $source_file );
+ ok $obj_file, "ExtUtils::CBuilder::compile() returned true value";
+ ok -e $obj_file, "Make sure $obj_file exists";
+}
+SKIP: {
+ skip "no dynamic loading", 5
+ if !$b->have_compiler || !$Config{usedl};
+ my $module = 'XSTest';
+ $lib_file = $b->link( objects => $obj_file, module_name => $module );
+ ok $lib_file, "ExtUtils::CBuilder::link() returned true value";
+ ok -e $lib_file, "Make sure $lib_file exists";
+
+ eval {require XSTest};
+ is $@, '', "No error message recorded, as expected";
+ ok XSTest::is_even(8),
+ "Function created thru XS returned expected true value";
+ ok !XSTest::is_even(9),
+ "Function created thru XS returned expected false value";
+
+ # Win32 needs to close the DLL before it can unlink it, but unfortunately
+ # dl_unload_file was missing on Win32 prior to perl change #24679!
+ if ($^O eq 'MSWin32' and defined &DynaLoader::dl_unload_file) {
+ for (my $i = 0; $i < @DynaLoader::dl_modules; $i++) {
+ if ($DynaLoader::dl_modules[$i] eq $module) {
+ DynaLoader::dl_unload_file($DynaLoader::dl_librefs[$i]);
+ last;
+ }
+ }
+ }
+}
+
+my $seen = 0;
+open my $IN, '<', $source_file
+ or die "Unable to open $source_file: $!";
+while (my $l = <$IN>) {
+ $seen++ if $l =~ m/#line\s1\s/;
+}
+close $IN or die "Unable to close $source_file: $!";
+is( $seen, 0, "No linenumbers created in output file, as intended" );
+
+
+unless ($ENV{PERL_NO_CLEANUP}) {
+ for ( $obj_file, $lib_file, $source_file) {
+ next unless defined $_;
+ 1 while unlink $_;
+ }
+}
+}
#####################################################################
sub Foo::TIEHANDLE { bless {}, 'Foo' }
diff --git a/dist/ExtUtils-ParseXS/t/004-nolinenumbers.t b/dist/ExtUtils-ParseXS/t/004-nolinenumbers.t
deleted file mode 100644
index 7ecbd59344..0000000000
--- a/dist/ExtUtils-ParseXS/t/004-nolinenumbers.t
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use Test::More tests => 11;
-use Config;
-use DynaLoader;
-use ExtUtils::CBuilder;
-
-my ($source_file, $obj_file, $lib_file);
-
-require_ok( 'ExtUtils::ParseXS' );
-ExtUtils::ParseXS->import('process_file');
-
-chdir('t') if -d 't';
-
-use Carp; $SIG{__WARN__} = \&Carp::cluck;
-
-#########################
-
-# Try sending to filehandle
-tie *FH, 'Foo';
-process_file(
- filename => 'XSTest.xs',
- output => \*FH,
- prototypes => 1,
- linenumbers => 0,
-);
-like tied(*FH)->content, '/is_even/', "Test that output contains some text";
-
-$source_file = 'XSTest.c';
-
-# Try sending to file
-process_file(
- filename => 'XSTest.xs',
- output => $source_file,
- prototypes => 0,
- linenumbers => 0,
-);
-ok -e $source_file, "Create an output file";
-
-my $quiet = $ENV{PERL_CORE} && !$ENV{HARNESS_ACTIVE};
-my $b = ExtUtils::CBuilder->new(quiet => $quiet);
-
-SKIP: {
- skip "no compiler available", 2
- if ! $b->have_compiler;
- $obj_file = $b->compile( source => $source_file );
- ok $obj_file, "ExtUtils::CBuilder::compile() returned true value";
- ok -e $obj_file, "Make sure $obj_file exists";
-}
-
-SKIP: {
- skip "no dynamic loading", 5
- if !$b->have_compiler || !$Config{usedl};
- my $module = 'XSTest';
- $lib_file = $b->link( objects => $obj_file, module_name => $module );
- ok $lib_file, "ExtUtils::CBuilder::link() returned true value";
- ok -e $lib_file, "Make sure $lib_file exists";
-
- eval {require XSTest};
- is $@, '', "No error message recorded, as expected";
- ok XSTest::is_even(8),
- "Function created thru XS returned expected true value";
- ok !XSTest::is_even(9),
- "Function created thru XS returned expected false value";
-
- # Win32 needs to close the DLL before it can unlink it, but unfortunately
- # dl_unload_file was missing on Win32 prior to perl change #24679!
- if ($^O eq 'MSWin32' and defined &DynaLoader::dl_unload_file) {
- for (my $i = 0; $i < @DynaLoader::dl_modules; $i++) {
- if ($DynaLoader::dl_modules[$i] eq $module) {
- DynaLoader::dl_unload_file($DynaLoader::dl_librefs[$i]);
- last;
- }
- }
- }
-}
-
-my $seen = 0;
-open my $IN, '<', $source_file
- or die "Unable to open $source_file: $!";
-while (my $l = <$IN>) {
- $seen++ if $l =~ m/#line\s1\s/;
-}
-close $IN or die "Unable to close $source_file: $!";
-is( $seen, 0, "No linenumbers created in output file, as intended" );
-
-
-unless ($ENV{PERL_NO_CLEANUP}) {
- for ( $obj_file, $lib_file, $source_file) {
- next unless defined $_;
- 1 while unlink $_;
- }
-}
-
-#####################################################################
-
-sub Foo::TIEHANDLE { bless {}, 'Foo' }
-sub Foo::PRINT { shift->{buf} .= join '', @_ }
-sub Foo::content { shift->{buf} }