summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test
diff options
context:
space:
mode:
authorafresh1 <afresh1@openbsd.org>2019-02-13 21:15:00 +0000
committerafresh1 <afresh1@openbsd.org>2019-02-13 21:15:00 +0000
commit9f11ffb7133c203312a01e4b986886bc88c7d74b (patch)
tree6618511204c614b20256e4ef9dea39a7b311d638 /gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test
parentImport perl-5.28.1 (diff)
downloadwireguard-openbsd-9f11ffb7133c203312a01e4b986886bc88c7d74b.tar.xz
wireguard-openbsd-9f11ffb7133c203312a01e4b986886bc88c7d74b.zip
Fix merge issues, remove excess files - match perl-5.28.1 dist
looking good sthen@, Great! bluhm@
Diffstat (limited to 'gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test')
-rw-r--r--gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/MPV.pm67
-rw-r--r--gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/PL_FILES.pm119
-rw-r--r--gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/Problem.pm62
-rw-r--r--gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/Recurs.pm72
-rw-r--r--gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/SAS.pm67
-rw-r--r--gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/Unicode.pm90
-rw-r--r--gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/XS.pm459
-rw-r--r--gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Utils.pm114
8 files changed, 506 insertions, 544 deletions
diff --git a/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/MPV.pm b/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/MPV.pm
deleted file mode 100644
index f30d65f5676..00000000000
--- a/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/MPV.pm
+++ /dev/null
@@ -1,67 +0,0 @@
-package MakeMaker::Test::Setup::MPV;
-
-@ISA = qw(Exporter);
-require Exporter;
-@EXPORT = qw(setup_recurs teardown_recurs);
-
-use strict;
-use File::Path;
-use File::Basename;
-
-my %Files = (
- 'Min-PerlVers/Makefile.PL' => <<'END',
-use ExtUtils::MakeMaker;
-
-WriteMakefile(
- NAME => 'Min::PerlVers',
- AUTHOR => 'John Doe <jd@example.com>',
- VERSION_FROM => 'lib/Min/PerlVers.pm',
- PREREQ_PM => { strict => 0 },
- MIN_PERL_VERSION => '5.005',
-);
-END
-
- 'Min-PerlVers/lib/Min/PerlVers.pm' => <<'END',
-package Min::PerlVers;
-
-$VERSION = 0.05;
-
-=head1 NAME
-
-Min::PerlVers - being picky about perl versions
-
-=cut
-
-1;
-END
-
-);
-
-
-sub setup_recurs {
- while(my($file, $text) = each %Files) {
- # Convert to a relative, native file path.
- $file = File::Spec->catfile(File::Spec->curdir, split m{\/}, $file);
-
- my $dir = dirname($file);
- mkpath $dir;
- open(FILE, ">$file") || die "Can't create $file: $!";
- print FILE $text;
- close FILE;
- }
-
- return 1;
-}
-
-sub teardown_recurs {
- foreach my $file (keys %Files) {
- my $dir = dirname($file);
- if( -e $dir ) {
- rmtree($dir) || return;
- }
- }
- return 1;
-}
-
-
-1;
diff --git a/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/PL_FILES.pm b/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/PL_FILES.pm
deleted file mode 100644
index f412368317c..00000000000
--- a/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/PL_FILES.pm
+++ /dev/null
@@ -1,119 +0,0 @@
-package MakeMaker::Test::Setup::PL_FILES;
-
-@ISA = qw(Exporter);
-require Exporter;
-@EXPORT = qw(setup teardown);
-
-use strict;
-use File::Path;
-use File::Basename;
-use File::Spec;
-use MakeMaker::Test::Utils;
-
-my %Files = (
- 'PL_FILES-Module/Makefile.PL' => <<'END',
-use ExtUtils::MakeMaker;
-
-# A module for testing PL_FILES
-WriteMakefile(
- NAME => 'PL_FILES::Module',
- PL_FILES => { 'single.PL' => 'single.out',
- 'multi.PL' => [qw(1.out 2.out)],
- 'Bar_pm.PL' => '$(INST_LIB)/PL/Bar.pm',
- }
-);
-END
-
- 'PL_FILES-Module/single.PL' => _gen_pl_files(),
- 'PL_FILES-Module/multi.PL' => _gen_pl_files(),
- 'PL_FILES-Module/Bar_pm.PL' => _gen_pm_files(),
- 'PL_FILES-Module/lib/PL/Foo.pm' => <<'END',
-# Module to load to ensure PL_FILES have blib in @INC.
-package PL::Foo;
-sub bar { 42 }
-1;
-END
-
-);
-
-
-sub _gen_pl_files {
- my $test = <<'END';
-#!/usr/bin/perl -w
-
-# Ensure we have blib in @INC
-use PL::Foo;
-die unless PL::Foo::bar() == 42;
-
-# Had a bug where PL_FILES weren't sent the file to generate
-die "argv empty\n" unless @ARGV;
-die "too many in argv: @ARGV\n" unless @ARGV == 1;
-
-my $file = $ARGV[0];
-open OUT, ">$file" or die $!;
-
-print OUT "Testing\n";
-close OUT
-END
-
- $test =~ s/^\n//;
-
- return $test;
-}
-
-
-sub _gen_pm_files {
- my $test = <<'END';
-#!/usr/bin/perl -w
-
-# Ensure we do NOT have blib in @INC when building a module
-eval { require PL::Foo; };
-#die $@ unless $@ =~ m{^Can't locate PL/Foo.pm in \@INC };
-
-# Had a bug where PL_FILES weren't sent the file to generate
-die "argv empty\n" unless @ARGV;
-die "too many in argv: @ARGV\n" unless @ARGV == 1;
-
-my $file = $ARGV[0];
-open OUT, ">$file" or die $!;
-
-print OUT "Testing\n";
-close OUT
-END
-
- $test =~ s/^\n//;
-
- return $test;
-}
-
-
-sub setup {
-
- while(my($file, $text) = each %Files) {
- # Convert to a relative, native file path.
- $file = File::Spec->catfile(File::Spec->curdir, split m{\/}, $file);
-
- my $dir = dirname($file);
- mkpath $dir;
- open(FILE, ">$file") || die "Can't create $file: $!";
- print FILE $text;
- close FILE;
-
- # ensure file at least 1 second old for makes that assume
- # files with the same time are out of date.
- my $time = calibrate_mtime();
- utime $time, $time - 1, $file;
- }
-
- return 1;
-}
-
-sub teardown {
- foreach my $file (keys %Files) {
- my $dir = dirname($file);
- if( -e $dir ) {
- rmtree($dir) || return;
- }
- }
- return 1;
-}
diff --git a/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/Problem.pm b/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/Problem.pm
deleted file mode 100644
index 59ac1517a6e..00000000000
--- a/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/Problem.pm
+++ /dev/null
@@ -1,62 +0,0 @@
-package MakeMaker::Test::Setup::Problem;
-
-@ISA = qw(Exporter);
-require Exporter;
-@EXPORT = qw(setup_recurs teardown_recurs);
-
-use strict;
-use File::Path;
-use File::Basename;
-use MakeMaker::Test::Utils;
-
-my %Files = (
- 'Problem-Module/Makefile.PL' => <<'END',
-use ExtUtils::MakeMaker;
-
-WriteMakefile(
- NAME => 'Problem::Module',
-);
-END
-
- 'Problem-Module/subdir/Makefile.PL' => <<'END',
-printf "\@INC %s .\n", (grep { $_ eq '.' } @INC) ? "has" : "doesn't have";
-
-warn "I think I'm going to be sick\n";
-die "YYYAaaaakkk\n";
-END
-
-);
-
-
-sub setup_recurs {
- while(my($file, $text) = each %Files) {
- # Convert to a relative, native file path.
- $file = File::Spec->catfile(File::Spec->curdir, split m{\/}, $file);
-
- my $dir = dirname($file);
- mkpath $dir;
- open(FILE, ">$file") || die "Can't create $file: $!";
- print FILE $text;
- close FILE;
-
- # ensure file at least 1 second old for makes that assume
- # files with the same time are out of date.
- my $time = calibrate_mtime();
- utime $time, $time - 1, $file;
- }
-
- return 1;
-}
-
-sub teardown_recurs {
- foreach my $file (keys %Files) {
- my $dir = dirname($file);
- if( -e $dir ) {
- rmtree($dir) || return;
- }
- }
- return 1;
-}
-
-
-1;
diff --git a/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/Recurs.pm b/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/Recurs.pm
deleted file mode 100644
index 8694321358c..00000000000
--- a/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/Recurs.pm
+++ /dev/null
@@ -1,72 +0,0 @@
-package MakeMaker::Test::Setup::Recurs;
-
-@ISA = qw(Exporter);
-require Exporter;
-@EXPORT = qw(setup_recurs teardown_recurs);
-
-use strict;
-use File::Path;
-use File::Basename;
-use MakeMaker::Test::Utils;
-
-my %Files = (
- 'Recurs/Makefile.PL' => <<'END',
-use ExtUtils::MakeMaker;
-
-WriteMakefile(
- NAME => 'Recurs',
- VERSION => 1.00,
-);
-END
-
- 'Recurs/prj2/Makefile.PL' => <<'END',
-use ExtUtils::MakeMaker;
-
-WriteMakefile(
- NAME => 'Recurs::prj2',
- VERSION => 1.00,
-);
-END
-
- # Check if a test failure in a subdir causes make test to fail
- 'Recurs/prj2/t/fail.t' => <<'END',
-#!/usr/bin/perl -w
-
-print "1..1\n";
-print "not ok 1\n";
-END
- );
-
-sub setup_recurs {
-
- while(my($file, $text) = each %Files) {
- # Convert to a relative, native file path.
- $file = File::Spec->catfile(File::Spec->curdir, split m{\/}, $file);
-
- my $dir = dirname($file);
- mkpath $dir;
- open(FILE, ">$file") || die "Can't create $file: $!";
- print FILE $text;
- close FILE;
-
- # ensure file at least 1 second old for makes that assume
- # files with the same time are out of date.
- my $time = calibrate_mtime();
- utime $time, $time - 1, $file;
- }
-
- return 1;
-}
-
-sub teardown_recurs {
- foreach my $file (keys %Files) {
- my $dir = dirname($file);
- if( -e $dir ) {
- rmtree($dir) || return;
- }
- }
- return 1;
-}
-
-
-1;
diff --git a/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/SAS.pm b/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/SAS.pm
deleted file mode 100644
index 04d9bd3259a..00000000000
--- a/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/SAS.pm
+++ /dev/null
@@ -1,67 +0,0 @@
-package MakeMaker::Test::Setup::SAS;
-
-@ISA = qw(Exporter);
-require Exporter;
-@EXPORT = qw(setup_recurs teardown_recurs);
-
-use strict;
-use File::Path;
-use File::Basename;
-
-our $dirname='Multiple-Authors';
-my %Files = (
- $dirname.'/Makefile.PL' => <<'END',
-use ExtUtils::MakeMaker;
-
-WriteMakefile(
- NAME => 'Multiple::Authors',
- AUTHOR => ['John Doe <jd@example.com>', 'Jane Doe <jd@example.com>'],
- VERSION_FROM => 'lib/Multiple/Authors.pm',
- PREREQ_PM => { strict => 0 },
-);
-END
-
- $dirname.'/lib/Multiple/Authors.pm' => <<'END',
-package Multiple::Authors;
-
-$VERSION = 0.05;
-
-=head1 NAME
-
-Multiple::Authors - several authors
-
-=cut
-
-1;
-END
-
-);
-
-
-sub setup_recurs {
- while(my($file, $text) = each %Files) {
- # Convert to a relative, native file path.
- $file = File::Spec->catfile(File::Spec->curdir, split m{\/}, $file);
-
- my $dir = dirname($file);
- mkpath $dir;
- open(FILE, ">$file") || die "Can't create $file: $!";
- print FILE $text;
- close FILE;
- }
-
- return 1;
-}
-
-sub teardown_recurs {
- foreach my $file (keys %Files) {
- my $dir = dirname($file);
- if( -e $dir ) {
- rmtree($dir) || return;
- }
- }
- return 1;
-}
-
-
-1;
diff --git a/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/Unicode.pm b/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/Unicode.pm
deleted file mode 100644
index 76641f055cd..00000000000
--- a/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/Unicode.pm
+++ /dev/null
@@ -1,90 +0,0 @@
-package MakeMaker::Test::Setup::Unicode;
-
-@ISA = qw(Exporter);
-require Exporter;
-@EXPORT = qw(setup_recurs teardown_recurs);
-
-use strict;
-use File::Path;
-use File::Basename;
-use MakeMaker::Test::Utils;
-use utf8;
-use Config;
-
-my %Files = (
- 'Problem-Module/Makefile.PL' => <<'PL_END',
-use ExtUtils::MakeMaker;
-use utf8;
-
-WriteMakefile(
- NAME => 'Problem::Module',
- ABSTRACT_FROM => 'lib/Problem/Module.pm',
- AUTHOR => q{Danijel Tašov},
- EXE_FILES => [ qw(bin/probscript) ],
- INSTALLMAN1DIR => "some", # even if disabled in $Config{man1dir}
- MAN1EXT => 1, # set to 0 if man pages disabled
-);
-PL_END
-
- 'Problem-Module/lib/Problem/Module.pm' => <<'pm_END',
-use utf8;
-
-=pod
-
-=encoding utf8
-
-=head1 NAME
-
-Problem::Module - Danijel Tašov's great new module
-
-=cut
-
-1;
-pm_END
-
- 'Problem-Module/bin/probscript' => <<'pl_END',
-#!/usr/bin/perl
-use utf8;
-
-=encoding utf8
-
-=head1 NAME
-
-文档 - Problem script
-pl_END
-);
-
-
-sub setup_recurs {
- while(my($file, $text) = each %Files) {
- # Convert to a relative, native file path.
- $file = File::Spec->catfile(File::Spec->curdir, split m{\/}, $file);
-
- my $dir = dirname($file);
- mkpath $dir;
- my $utf8 = ($] < 5.008 or !$Config{useperlio}) ? "" : ":utf8";
- open(FILE, ">$utf8", $file) || die "Can't create $file: $!";
- print FILE $text;
- close FILE;
-
- # ensure file at least 1 second old for makes that assume
- # files with the same time are out of date.
- my $time = calibrate_mtime();
- utime $time, $time - 1, $file;
- }
-
- return 1;
-}
-
-sub teardown_recurs {
- foreach my $file (keys %Files) {
- my $dir = dirname($file);
- if( -e $dir ) {
- rmtree($dir) || return;
- }
- }
- return 1;
-}
-
-
-1;
diff --git a/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/XS.pm b/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/XS.pm
index 6ebca598342..3d1f57e6bd6 100644
--- a/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/XS.pm
+++ b/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/XS.pm
@@ -2,101 +2,472 @@ package MakeMaker::Test::Setup::XS;
@ISA = qw(Exporter);
require Exporter;
-@EXPORT = qw(setup_xs teardown_xs);
+@EXPORT = qw(run_tests list_dynamic list_static);
use strict;
use File::Path;
-use File::Basename;
use MakeMaker::Test::Utils;
use Config;
+use Carp qw(croak);
+use Test::More;
+use File::Spec;
+use File::Temp qw[tempdir];
+use Cwd;
use ExtUtils::MM;
+# this is to avoid MM->new overwriting _eumm in top dir
+my $tempdir = tempdir(DIR => getcwd, CLEANUP => 1);
+chdir $tempdir;
my $typemap = 'type map';
-$typemap =~ s/ //g unless MM->new({NAME=>'name'})->can_dep_space;
+my $MM = MM->new({NAME=>'name', NORECURS=>1});
+$typemap =~ s/ //g unless $MM->can_dep_space;
+chdir File::Spec->updir;
-my %Files = (
- 'XS-Test/lib/XS/Test.pm' => <<'END',
+my $PM_TEST = <<'END';
package XS::Test;
-
require Exporter;
require DynaLoader;
-
$VERSION = 1.01;
@ISA = qw(Exporter DynaLoader);
@EXPORT = qw(is_even);
-
bootstrap XS::Test $VERSION;
-
1;
END
- 'XS-Test/Makefile.PL' => <<END,
-use ExtUtils::MakeMaker;
+my $XS_TEST = <<'END';
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+MODULE = XS::Test PACKAGE = XS::Test
+PROTOTYPES: DISABLE
+int
+is_even(input)
+ int input
+ CODE:
+ RETVAL = (input % 2 == 0);
+ OUTPUT:
+ RETVAL
+END
+
+my $T_TEST = <<'END';
+#!/usr/bin/perl -w
+use Test::More tests => 3;
+use_ok "XS::Test";
+ok !is_even(1);
+ok is_even(2);
+END
+my $MAKEFILEPL = <<'END';
+use ExtUtils::MakeMaker;
WriteMakefile(
- NAME => 'XS::Test',
- VERSION_FROM => 'lib/XS/Test.pm',
- TYPEMAPS => [ '$typemap' ],
- PERL => "\$^X -w",
+ NAME => 'XS::%s',
+ VERSION_FROM => '%s',
+ TYPEMAPS => [ %s ],
+ PERL => "$^X -w",
+ %s
);
END
- "XS-Test/$typemap" => '',
+my $BS_TEST = '$DynaLoader::bscode = q(warn "BIG NOISE";)';
+
+my $T_BOOTSTRAP = <<'EOF';
+use Test::More tests => 1;
+my $w = '';
+$SIG{__WARN__} = sub { $w .= join '', @_; };
+require XS::Test;
+like $w, qr/NOISE/;
+EOF
- 'XS-Test/Test.xs' => <<'END',
+my $PM_OTHER = <<'END';
+package XS::Other;
+require Exporter;
+require DynaLoader;
+$VERSION = 1.20;
+@ISA = qw(Exporter DynaLoader);
+@EXPORT = qw(is_odd);
+bootstrap XS::Other $VERSION;
+1;
+END
+
+my $XS_OTHER = <<'END';
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
-
-MODULE = XS::Test PACKAGE = XS::Test
-
+MODULE = XS::Other PACKAGE = XS::Other
PROTOTYPES: DISABLE
-
int
-is_even(input)
+is_odd(input)
int input
CODE:
- RETVAL = (input % 2 == 0);
+ RETVAL = (INVAR % 2 == 1);
OUTPUT:
RETVAL
END
- 'XS-Test/t/is_even.t' => <<'END',
+my $T_OTHER = <<'END';
#!/usr/bin/perl -w
-
use Test::More tests => 3;
+use_ok "XS::Other";
+ok is_odd(1);
+ok !is_odd(2);
+END
+
+my $PLUS1_C = <<'EOF';
+#ifdef __cplusplus
+extern "C" {
+int plus1(int i)
+#else
+int plus1(i)
+int i;
+#endif
+{ return i + 1; }
+#ifdef __cplusplus
+}
+#endif
+EOF
+
+my %Files = (
+ 'lib/XS/Test.pm' => $PM_TEST,
+ $typemap => '',
+ 'Test.xs' => $XS_TEST,
+ 't/is_even.t' => $T_TEST,
+ 'Makefile.PL' => sprintf($MAKEFILEPL, 'Test', 'lib/XS/Test.pm', qq{'$typemap'}, ''),
+);
+
+my %label2files = (basic => \%Files);
+
+$label2files{bscode} = +{
+ %{ $label2files{'basic'} }, # make copy
+ 'Test_BS' => $BS_TEST,
+ 't/bs.t' => $T_BOOTSTRAP,
+};
+delete $label2files{bscode}->{'t/is_even.t'};
+
+$label2files{static} = +{
+ %{ $label2files{'basic'} }, # make copy
+ 'Makefile.PL' => sprintf(
+ $MAKEFILEPL, 'Test', 'lib/XS/Test.pm', qq{'$typemap'},
+ q{LINKTYPE => 'static'},
+ ),
+ "blib/arch/auto/share/dist/x-y/libwhatevs$MM->{LIB_EXT}" => 'hi there', # mimic what File::ShareDir can do
+ "blib/arch/auto/Alien/ROOT/root/lib/root/root$MM->{LIB_EXT}" => 'hi there', # mimic Alien::ROOT that installs a .a without extralibs.ld
+ # next two mimic dist that installs a .a WITH extralibs.ld but that is still not XS
+ "blib/arch/auto/Dist/File$MM->{LIB_EXT}" => 'hi there',
+ "blib/arch/auto/Dist/extralibs.ld" => '',
+};
+
+$label2files{subdirs} = +{
+ %{ $label2files{'basic'} }, # make copy
+ 'Makefile.PL' => sprintf(
+ $MAKEFILEPL, 'Test', 'Test.pm', qq{'$typemap'},
+ q{DEFINE => '-DINVAR=input', INC => "-Inewline\n", LIBS => "-Lnewline\n",},
+ ),
+ 'Other/Makefile.PL' => sprintf($MAKEFILEPL, 'Other', 'Other.pm', qq{}, ''),
+ 'Other/Other.pm' => $PM_OTHER,
+ 'Other/Other.xs' => $XS_OTHER,
+ 't/is_odd.t' => $T_OTHER,
+};
+virtual_rename('subdirs', 'lib/XS/Test.pm', 'Test.pm');
+# to mimic behaviour of Unicode-LineBreak version 2015.07.16
+$label2files{subdirscomplex} = +{
+ %{ $label2files{'subdirs'} }, # make copy
+ 'Other/Makefile.PL' => sprintf(
+ $MAKEFILEPL,
+ 'Other', 'Other.pm', qq{},
+ <<'EOF',
+C => [qw(lib$(DIRFILESEP)file.c)],
+OBJECT => 'lib$(DIRFILESEP)file$(OBJ_EXT)',
+EOF
+ ) . <<'EOF',
+sub MY::c_o {
+ package MY;
+ my $self = shift;
+ my $inherited = $self->SUPER::c_o(@_);
+ $inherited =~ s{(:\n\t)(.*(?:\n\t.*)*)}
+ { $1 . $self->cd('lib', split /(?<!\\)\n\t/, $2) }eg;
+ $inherited =~ s{(\s)(\$\*\.c\s)}
+ { "$1..\$(DIRFILESEP)$2" }eg;
+ $inherited;
+}
+
+sub MY::top_targets {
+ <<'SNIP';
+all :: lib$(DIRFILESEP)file$(OBJ_EXT)
+ $(NOECHO) $(NOOP)
+
+config ::
+ $(NOECHO) $(NOOP)
+
+pure_all ::
+ $(NOECHO) $(NOOP)
+SNIP
+}
+EOF
+ 'Other/lib/file.c' => $PLUS1_C,
+};
+delete $label2files{subdirscomplex}{'Other/Other.xs'};
+delete $label2files{subdirscomplex}{'t/is_odd.t'};
+
+$label2files{subdirsstatic} = +{
+ %{ $label2files{'subdirs'} }, # make copy
+ 'Makefile.PL' => sprintf(
+ $MAKEFILEPL, 'Test', 'Test.pm', qq{'$typemap'},
+ q{DEFINE => '-DINVAR=input', LINKTYPE => 'static',},
+ ),
+};
+
+# to mimic behaviour of CGI-Deurl-XS version 0.08
+my $OTHERMAKEFILE = File::Spec->catfile('Other', makefile_name());
+$label2files{subdirsskip} = +{
+ %{ $label2files{subdirscomplex} }, # make copy
+ 'Makefile.PL' => sprintf(
+ $MAKEFILEPL,
+ 'Test', 'Test.pm', qq{},
+ q[
+MYEXTLIB => '] . File::Spec->catfile('Other', 'libparser$(LIB_EXT)') . q[',
+ ]
+ )
+ . q[
+sub MY::postamble {
+ my ($self) = @_;
+ return '$(MYEXTLIB) : ] . $OTHERMAKEFILE . q['."\n\t".$self->cd('Other', '$(MAKE) $(PASSTHRU)')."\n";
+}
+ ],
+ 'Other/Makefile.PL' => sprintf(
+ $MAKEFILEPL,
+ 'Other', 'Other.pm', qq{},
+ <<'EOF',
+SKIP => [qw(all static dynamic )],
+clean => {'FILES' => 'libparser$(LIB_EXT)'},
+EOF
+ ) . <<'EOF',
+sub MY::top_targets {
+ my ($self) = @_;
+ my $static_lib_pure_cmd = $self->static_lib_pure_cmd('$(O_FILES)');
+ <<'SNIP' . $static_lib_pure_cmd;
+all :: static
+
+pure_all :: static
+
+static :: libparser$(LIB_EXT)
+
+libparser$(LIB_EXT): $(O_FILES)
+SNIP
+}
+EOF
+ 't/plus1.t' => <<'END',
+#!/usr/bin/perl -w
+use Test::More tests => 2;
use_ok "XS::Test";
-ok !is_even(1);
-ok is_even(2);
+is XS::Test::plus1(3), 4;
END
- );
+ 'Test.xs' => <<EOF,
+#ifdef __cplusplus
+extern "C" {
+#endif
+int plus1(int);
+#ifdef __cplusplus
+}
+#endif
+$XS_TEST
+int
+plus1(input)
+ int input
+ CODE:
+ RETVAL = plus1(input);
+ OUTPUT:
+ RETVAL
+EOF
+};
+virtual_rename('subdirsskip', 'Other/lib/file.c', 'Other/file.c');
+
+my $XS_MULTI = $XS_OTHER;
+# check compiling from top dir still can include local
+$XS_MULTI =~ s:(#include "XSUB.h"):$1\n#include "header.h":;
+$label2files{multi} = +{
+ %{ $label2files{'basic'} }, # make copy
+ 'Makefile.PL' => sprintf(
+ $MAKEFILEPL, 'Test', 'lib/XS/Test.pm', qq{'lib/XS/$typemap'},
+ q{XSMULTI => 1,},
+ ),
+ 'lib/XS/Other.pm' => $PM_OTHER,
+ 'lib/XS/Other.xs' => $XS_MULTI,
+ 't/is_odd.t' => $T_OTHER,
+ 'lib/XS/header.h' => "#define INVAR input\n",
+};
+virtual_rename('multi', $typemap, "lib/XS/$typemap");
+virtual_rename('multi', 'Test.xs', 'lib/XS/Test.xs');
+
+$label2files{bscodemulti} = +{
+ %{ $label2files{'multi'} }, # make copy
+ 'lib/XS/Test_BS' => $BS_TEST,
+ 't/bs.t' => $T_BOOTSTRAP,
+};
+delete $label2files{bscodemulti}->{'t/is_even.t'};
+delete $label2files{bscodemulti}->{'t/is_odd.t'};
+$label2files{staticmulti} = +{
+ %{ $label2files{'multi'} }, # make copy
+ 'Makefile.PL' => sprintf(
+ $MAKEFILEPL, 'Test', 'lib/XS/Test.pm', qq{'$typemap'},
+ q{LINKTYPE => 'static', XSMULTI => 1,},
+ ),
+};
+
+$label2files{xsbuild} = +{
+ %{ $label2files{'multi'} }, # make copy
+ 'Makefile.PL' => sprintf(
+ $MAKEFILEPL, 'Test', 'lib/XS/Test.pm', qq{'$typemap'},
+ q{
+ XSMULTI => 1,
+ XSBUILD => {
+ xs => {
+ 'lib/XS/Other' => {
+ DEFINE => '-DINVAR=input',
+ OBJECT => 'lib/XS/Other$(OBJ_EXT) lib/XS/plus1$(OBJ_EXT)'
+ }
+ },
+ },
+ },
+ ),
+
+ 'lib/XS/Other.xs' => <<EOF,
+#ifdef __cplusplus
+extern "C" {
+#endif
+int plus1(int);
+#ifdef __cplusplus
+}
+#endif
+$XS_OTHER
+int
+plus1(input)
+ int input
+ CODE:
+ RETVAL = plus1(INVAR);
+ OUTPUT:
+ RETVAL
+EOF
+
+ 'lib/XS/plus1.c' => $PLUS1_C,
+
+ 't/is_odd.t' => <<'END',
+#!/usr/bin/perl -w
+use Test::More tests => 4;
+use_ok "XS::Other";
+ok is_odd(1);
+ok !is_odd(2);
+is XS::Other::plus1(3), 4;
+END
+
+};
+
+sub virtual_rename {
+ my ($label, $oldfile, $newfile) = @_;
+ $label2files{$label}->{$newfile} = delete $label2files{$label}->{$oldfile};
+}
sub setup_xs {
+ my ($label, $sublabel) = @_;
+ croak "Must supply label" unless defined $label;
+ my $files = $label2files{$label};
+ croak "Must supply valid label" unless defined $files;
+ croak "Must supply sublabel" unless defined $sublabel;
+ my $prefix = "XS-Test$label$sublabel";
+ hash2files($prefix, $files);
+ return $prefix;
+}
- while(my($file, $text) = each %Files) {
- # Convert to a relative, native file path.
- $file = File::Spec->catfile(File::Spec->curdir, split m{\/}, $file);
+sub list_static {
+ (
+ ( !$Config{usedl} ? [ 'basic', '', '' ] : ()), # still needs testing on static perl
+ [ 'static', '', '' ],
+ [ 'basic', ' static', '_static' ],
+ [ 'multi', ' static', '_static' ],
+ [ 'subdirs', ' LINKTYPE=static', ' LINKTYPE=static' ],
+ [ 'subdirsstatic', '', '' ],
+ [ 'staticmulti', '', '' ],
+ );
+}
+
+sub list_dynamic {
+ (
+ [ 'basic', '', '' ],
+ $^O ne 'MSWin32' ? (
+ [ 'bscode', '', '' ],
+ [ 'bscodemulti', '', '' ],
+ $^O !~ m!^(VMS|aix)$! ? ([ 'subdirscomplex', '', '' ]) : (),
+ ) : (), # DynaLoader different
+ [ 'subdirs', '', '' ],
+ [ 'subdirsstatic', ' LINKTYPE=dynamic', ' LINKTYPE=dynamic' ],
+ [ 'subdirsstatic', ' dynamic', '_dynamic' ],
+ [ 'multi', '', '' ],
+ [ 'staticmulti', ' LINKTYPE=dynamic', ' LINKTYPE=dynamic' ],
+ [ 'staticmulti', ' dynamic', '_dynamic' ],
+ [ 'xsbuild', '', '' ],
+ [ 'subdirsskip', '', '' ],
+ );
+}
- my $dir = dirname($file);
- mkpath $dir;
- open(FILE, ">$file") || die "Can't create $file: $!";
- print FILE $text;
- close FILE;
+sub run_tests {
+ my ($perl, $label, $add_target, $add_testtarget) = @_;
+ my $sublabel = $add_target;
+ $sublabel =~ s#[\s=]##g;
+ ok( my $dir = setup_xs($label, $sublabel), "setup $label$sublabel" );
+
+ ok( chdir($dir), "chdir'd to $dir" ) || diag("chdir failed: $!");
+
+ my @mpl_out = run(qq{$perl Makefile.PL});
+ SKIP: {
+ unless (cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' )) {
+ diag(@mpl_out);
+ skip 'perl Makefile.PL failed', 2;
}
- return 1;
-}
+ my $make = make_run();
+ my $target = '';
+ my %macros = ();
+ if (defined($add_target)) {
+ if ($add_target =~ m/(\S+)=(\S+)/) {
+ $macros{$1} = $2;
+ }
+ else {
+ $target = $add_target;
+ }
+ }
+ my $make_cmd = make_macro($make, $target, %macros);
+ my $make_out = run($make_cmd);
+ unless (is( $?, 0, "$make_cmd exited normally" )) {
+ diag $make_out;
+ skip 'Make failed - skipping test', 1;
+ }
-sub teardown_xs {
- foreach my $file (keys %Files) {
- my $dir = dirname($file);
- if( -e $dir ) {
- rmtree($dir) || return;
+ $target = 'test';
+ %macros = ();
+ if (defined($add_testtarget) && length($add_testtarget)) {
+ if ($add_testtarget =~ m/(\S+)=(\S+)/) {
+ $macros{$1} = $2;
+ }
+ else {
+ # an underscore prefix means combine, e.g. 'test' + '_dynamic'
+ unless ($add_testtarget =~ m/^_/) {
+ $target .= ($make =~ m/^MM(K|S)/i) ? ',' : ' ';
+ }
+ $target .= $add_testtarget;
}
}
- return 1;
+ my $test_cmd = make_macro($make, $target, %macros);
+ my $test_out = run($test_cmd);
+ is( $?, 0, "$test_cmd exited normally" ) || diag "$make_out\n$test_out";
+ }
+
+ chdir File::Spec->updir or die;
+ if ($ENV{EUMM_KEEP_TESTDIRS}) {
+ ok 1, "don't teardown $dir";
+ } else {
+ ok rmtree($dir), "teardown $dir";
+ }
}
1;
diff --git a/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Utils.pm b/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Utils.pm
index 16d668895ee..ce73b30b777 100644
--- a/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Utils.pm
+++ b/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Utils.pm
@@ -3,6 +3,10 @@ package MakeMaker::Test::Utils;
use File::Spec;
use strict;
use Config;
+use Cwd qw(getcwd);
+use Carp qw(croak);
+use File::Path;
+use File::Basename;
require Exporter;
our @ISA = qw(Exporter);
@@ -16,6 +20,8 @@ our @EXPORT = qw(which_perl perl_lib makefile_name makefile_backup
have_compiler slurp
$Is_VMS $Is_MacOS
run_ok
+ hash2files
+ in_dir
);
@@ -155,6 +161,9 @@ Sets up environment variables so perl can find its libraries.
my $old5lib = $ENV{PERL5LIB};
my $had5lib = exists $ENV{PERL5LIB};
sub perl_lib {
+ my $basecwd = (File::Spec->splitdir(getcwd))[-1];
+ croak "Basename of cwd needs to be 't' but is '$basecwd'\n"
+ unless $basecwd eq 't';
# perl-src/t/
my $lib = $ENV{PERL_CORE} ? qq{../lib}
# ExtUtils-MakeMaker/t/
@@ -255,14 +264,18 @@ sub make_macro {
my $is_mms = $make =~ /^MM(K|S)/i;
- my $cmd = $make;
- my $macros = '';
+ my @macros;
while( my($key,$val) = splice(@_, 0, 2) ) {
- if( $is_mms ) {
- $macros .= qq{/macro="$key=$val"};
+ push @macros, qq{$key=$val};
+ }
+ my $macros = '';
+ if (scalar(@macros)) {
+ if ($is_mms) {
+ map { $_ = qq{"$_"} } @macros;
+ $macros = '/MACRO=(' . join(',', @macros) . ')';
}
else {
- $macros .= qq{ $key=$val};
+ $macros = join(' ', @macros);
}
}
@@ -280,11 +293,12 @@ touched.
=cut
sub calibrate_mtime {
- open(FILE, ">calibrate_mtime.tmp") || die $!;
+ my $file = "calibrate_mtime-$$.tmp";
+ open(FILE, ">$file") || die $!;
print FILE "foo";
close FILE;
- my($mtime) = (stat('calibrate_mtime.tmp'))[9];
- unlink 'calibrate_mtime.tmp';
+ my($mtime) = (stat($file))[9];
+ unlink $file;
return $mtime;
}
@@ -345,23 +359,11 @@ Returns true if there is a compiler available for XS builds.
sub have_compiler {
my $have_compiler = 0;
-
- # ExtUtils::CBuilder prints its compilation lines to the screen.
- # Shut it up.
- use TieOut;
- local *STDOUT = *STDOUT;
- local *STDERR = *STDERR;
-
- tie *STDOUT, 'TieOut';
- tie *STDERR, 'TieOut';
-
eval {
- require ExtUtils::CBuilder;
- my $cb = ExtUtils::CBuilder->new;
-
- $have_compiler = $cb->have_compiler;
+ require ExtUtils::CBuilder;
+ my $cb = ExtUtils::CBuilder->new(quiet=>1);
+ $have_compiler = $cb->have_compiler;
};
-
return $have_compiler;
}
@@ -386,6 +388,72 @@ sub slurp {
return $text;
}
+=item hash2files
+
+ hash2files('dirname', { 'filename' => 'some content' });
+
+Goes through given hash-ref, treating each key as a /-separated filename
+under the specified directory, and writing the value into it. Will create
+any necessary directories.
+
+Will die if errors occur.
+
+=cut
+
+sub hash2files {
+ my ($prefix, $hashref) = @_;
+ while(my ($file, $text) = each %$hashref) {
+ # Convert to a relative, native file path.
+ $file = File::Spec->catfile(File::Spec->curdir, $prefix, split m{\/}, $file);
+ my $dir = dirname($file);
+ mkpath $dir;
+ my $utf8 = ($] < 5.008 or !$Config{useperlio}) ? "" : ":utf8";
+ open(FILE, ">$utf8", $file) || die "Can't create $file: $!";
+ print FILE $text;
+ close FILE;
+ # ensure file at least 1 second old for makes that assume
+ # files with the same time are out of date.
+ my $time = calibrate_mtime();
+ utime $time, $time - 1, $file;
+ }
+}
+
+=item in_dir
+
+ $retval = in_dir(\&coderef);
+ $retval = in_dir(\&coderef, $specified_dir);
+ $retval = in_dir { somecode(); };
+ $retval = in_dir { somecode(); } $specified_dir;
+
+Does a C<chdir> to either a directory. If none is specified, one is
+created with L<File::Temp> and then automatically deleted after. It ends
+by C<chdir>ing back to where it started.
+
+If the given code throws an exception, it will be re-thrown after the
+re-C<chdir>.
+
+Returns the return value of the given code.
+
+=cut
+
+sub in_dir(&;$) {
+ my $code = shift;
+ require File::Temp;
+ my $dir = shift || File::Temp::tempdir(TMPDIR => 1, CLEANUP => 1);
+ # chdir to the new directory
+ my $orig_dir = getcwd();
+ chdir $dir or die "Can't chdir to $dir: $!";
+ # Run the code, but trap the error so we can chdir back
+ my $return;
+ my $ok = eval { $return = $code->(); 1; };
+ my $err = $@;
+ # chdir back
+ chdir $orig_dir or die "Can't chdir to $orig_dir: $!";
+ # rethrow if necessary
+ die $err unless $ok;
+ return $return;
+}
+
=back
=head1 AUTHOR