diff options
author | Steve Peters <steve@fisharerojo.org> | 2007-07-02 15:39:52 +0000 |
---|---|---|
committer | Steve Peters <steve@fisharerojo.org> | 2007-07-02 15:39:52 +0000 |
commit | 277189c8ad3fc0d1dcd4c757f62b0a7bf5bacaa0 (patch) | |
tree | 5c8f3e174b3714c1e7556d10e66d7b4f71402e27 /lib/ExtUtils/t | |
parent | 28f2d4d1a9ee0dc43de025aac86c30a6932449c8 (diff) | |
download | perl-277189c8ad3fc0d1dcd4c757f62b0a7bf5bacaa0.tar.gz |
Upgrade to ExtUtils-MakeMaker-6.35
p4raw-id: //depot/perl@31519
Diffstat (limited to 'lib/ExtUtils/t')
-rw-r--r-- | lib/ExtUtils/t/WriteEmptyMakefile.t | 40 | ||||
-rw-r--r-- | lib/ExtUtils/t/basic.t | 7 | ||||
-rw-r--r-- | lib/ExtUtils/t/cd.t | 67 | ||||
-rw-r--r-- | lib/ExtUtils/t/fixin.t | 45 | ||||
-rw-r--r-- | lib/ExtUtils/t/parse_version.t | 23 | ||||
-rw-r--r-- | lib/ExtUtils/t/prereq.t | 109 | ||||
-rw-r--r-- | lib/ExtUtils/t/recurs.t | 11 | ||||
-rw-r--r-- | lib/ExtUtils/t/writemakefile_args.t | 81 |
8 files changed, 374 insertions, 9 deletions
diff --git a/lib/ExtUtils/t/WriteEmptyMakefile.t b/lib/ExtUtils/t/WriteEmptyMakefile.t new file mode 100644 index 0000000000..e9db02b881 --- /dev/null +++ b/lib/ExtUtils/t/WriteEmptyMakefile.t @@ -0,0 +1,40 @@ +#!/usr/bin/perl -w + +# This is a test of WriteEmptyMakefile. + +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't' if -d 't'; + @INC = ('../lib', 'lib'); + } + else { + unshift @INC, 't/lib'; + } +} + +chdir 't'; + +use strict; +use Test::More 'no_plan'; + +use ExtUtils::MakeMaker qw(WriteEmptyMakefile); +use TieOut; + +can_ok __PACKAGE__, 'WriteEmptyMakefile'; + +eval { WriteEmptyMakefile("something"); }; +like $@, qr/Need an even number of args/; + + +{ + ok( my $stdout = tie *STDOUT, 'TieOut' ); + + ok !-e 'wibble'; + END { 1 while unlink 'wibble' } + + WriteEmptyMakefile( + NAME => "Foo", + FIRST_MAKEFILE => "wibble", + ); + ok -e 'wibble'; +} diff --git a/lib/ExtUtils/t/basic.t b/lib/ExtUtils/t/basic.t index ba5a7ba857..6b9002a5c1 100644 --- a/lib/ExtUtils/t/basic.t +++ b/lib/ExtUtils/t/basic.t @@ -16,7 +16,7 @@ BEGIN { use strict; use Config; -use Test::More tests => 80; +use Test::More tests => 83; use MakeMaker::Test::Utils; use MakeMaker::Test::Setup::BFD; use File::Find; @@ -249,6 +249,11 @@ ok( !-f 'META.yml', 'META.yml not written to source dir' ); ok( -f $meta_yml, 'META.yml written to dist dir' ); ok( !-e "META_new.yml", 'temp META.yml file not left around' ); +ok open META, $meta_yml or diag $!; +my @meta = <META>; +like $meta[-1], '/\n$/', "META.yml ends with a newline"; +ok close META; + my $manifest = maniread("$distdir/MANIFEST"); # VMS is non-case preserving, so we can't know what the MANIFEST will # look like. :( diff --git a/lib/ExtUtils/t/cd.t b/lib/ExtUtils/t/cd.t new file mode 100644 index 0000000000..1ae2132879 --- /dev/null +++ b/lib/ExtUtils/t/cd.t @@ -0,0 +1,67 @@ +#!/usr/bin/perl -w + +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = ('../lib', 'lib/'); + } + else { + unshift @INC, 't/lib/'; + } +} +chdir 't'; + +my $Is_VMS = $^O eq 'VMS'; + +use File::Spec; + +use Test::More tests => 4; + +my @cd_args = ("some/dir", "command1", "command2"); + +{ + package Test::MM_Win32; + use ExtUtils::MM_Win32; + @ISA = qw(ExtUtils::MM_Win32); + + my $mm = bless {}, 'Test::MM_Win32'; + + { + local *make = sub { "nmake" }; + + my @dirs = (File::Spec->updir) x 2; + my $expected_updir = File::Spec->catdir(@dirs); + + ::is $mm->cd(@cd_args), +qq{cd some/dir + command1 + command2 + cd $expected_updir}; + } + + { + local *make = sub { "dmake" }; + + ::is $mm->cd(@cd_args), +q{cd some/dir && command1 + cd some/dir && command2}; + } +} + +{ + is +ExtUtils::MM_Unix->cd(@cd_args), +q{cd some/dir && command1 + cd some/dir && command2}; +} + +SKIP: { + skip("VMS' cd requires vmspath which is only on VMS", 1) unless $Is_VMS; + + use ExtUtils::MM_VMS; + is +ExtUtils::MM_VMS->cd(@cd_args), +q{startdir = F$Environment("Default") + Set Default some/dir + command1 + command2 + Set Default 'startdir'}; +}
\ No newline at end of file diff --git a/lib/ExtUtils/t/fixin.t b/lib/ExtUtils/t/fixin.t new file mode 100644 index 0000000000..69c0ac722b --- /dev/null +++ b/lib/ExtUtils/t/fixin.t @@ -0,0 +1,45 @@ +#!/usr/bin/perl -w + +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = ('../lib', 'lib/'); + } + else { + unshift @INC, 't/lib/'; + } +} +chdir 't'; + +use File::Spec; + +use Test::More tests => 6; + +use TieOut; +use MakeMaker::Test::Utils; +use MakeMaker::Test::Setup::BFD; + +use ExtUtils::MakeMaker; + +chdir 't'; + +perl_lib(); + +ok( setup_recurs(), 'setup' ); +END { + ok( chdir File::Spec->updir ); + ok( teardown_recurs(), 'teardown' ); +} + +ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) || + diag("chdir failed: $!"); + +# [rt.cpan.org 26234] +{ + local $/ = "foo"; + local $\ = "bar"; + MY->fixin("bin/program"); + is $/, "foo", '$/ not clobbered'; + is $\, "bar", '$\ not clobbered'; +} + diff --git a/lib/ExtUtils/t/parse_version.t b/lib/ExtUtils/t/parse_version.t index 8d2a8d0c50..78ba52e3a8 100644 --- a/lib/ExtUtils/t/parse_version.t +++ b/lib/ExtUtils/t/parse_version.t @@ -11,16 +11,35 @@ BEGIN { } chdir 't'; -use Test::More tests => 10; +use Test::More; use ExtUtils::MakeMaker; -my %versions = ('$VERSION = 0.02' => 0.02, +my %versions = (q[$VERSION = '1.00'] => '1.00', + q[*VERSION = \'1.01'] => '1.01', + q[($VERSION) = q$Revision: 32208 $ =~ /(\d+)/g;] => 32208, + q[$FOO::VERSION = '1.10';] => '1.10', + q[*FOO::VERSION = \'1.11';] => '1.11', + '$VERSION = 0.02' => 0.02, '$VERSION = 0.0' => 0.0, '$VERSION = -1.0' => -1.0, '$VERSION = undef' => 'undef', '$wibble = 1.0' => 'undef', + q[my $VERSION = '1.01'] => 'undef', + q[local $VERISON = '1.02'] => 'undef', + q[local $FOO::VERSION = '1.30'] => 'undef', ); +if( eval 'our $foo' ) { + $versions{q[our $VERSION = '1.23';]} = '1.23', +} + +if( eval 'require version; "version"->import' ) { + $versions{q[use version; $VERSION = qv(1.2.3);]} = qv(1.2.3); + $versions{q[$VERSION = qv(1.2.3)]} = qv(1.2.3); +} + +plan tests => 2 * keys %versions; + while( my($code, $expect) = each %versions ) { open(FILE, ">VERSION.tmp") || die $!; print FILE "$code\n"; diff --git a/lib/ExtUtils/t/prereq.t b/lib/ExtUtils/t/prereq.t new file mode 100644 index 0000000000..ae6ac84b45 --- /dev/null +++ b/lib/ExtUtils/t/prereq.t @@ -0,0 +1,109 @@ +#!/usr/bin/perl -w + +# This is a test of the verification of the arguments to +# WriteMakefile. + +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't' if -d 't'; + @INC = ('../lib', 'lib'); + } + else { + unshift @INC, 't/lib'; + } +} + +use strict; +use Test::More 'no_plan'; + +use TieOut; +use MakeMaker::Test::Utils; +use MakeMaker::Test::Setup::BFD; + +use ExtUtils::MakeMaker; + +chdir 't'; + +perl_lib(); + +ok( setup_recurs(), 'setup' ); +END { + ok( chdir File::Spec->updir ); + ok( teardown_recurs(), 'teardown' ); +} + +ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) || + diag("chdir failed: $!"); + +{ + ok( my $stdout = tie *STDOUT, 'TieOut' ); + my $warnings = ''; + local $SIG{__WARN__} = sub { + $warnings .= join '', @_; + }; + + WriteMakefile( + NAME => 'Big::Dummy', + PREREQ_PM => { + strict => 0 + } + ); + is $warnings, ''; + + $warnings = ''; + WriteMakefile( + NAME => 'Big::Dummy', + PREREQ_PM => { + strict => 99999 + } + ); + is $warnings, + "Warning: prerequisite strict 99999 not found. We have $strict::VERSION.\n"; + + $warnings = ''; + WriteMakefile( + NAME => 'Big::Dummy', + PREREQ_PM => { + "I::Do::Not::Exist" => 0, + } + ); + is $warnings, + "Warning: prerequisite I::Do::Not::Exist 0 not found.\n"; + + $warnings = ''; + WriteMakefile( + NAME => 'Big::Dummy', + PREREQ_PM => { + "I::Do::Not::Exist" => 0, + "strict" => 99999, + } + ); + is $warnings, + "Warning: prerequisite I::Do::Not::Exist 0 not found.\n". + "Warning: prerequisite strict 99999 not found. We have $strict::VERSION.\n"; + + + $warnings = ''; + eval { + WriteMakefile( + NAME => 'Big::Dummy', + PREREQ_PM => { + "I::Do::Not::Exist" => 0, + "Nor::Do::I" => 0, + "strict" => 99999, + }, + PREREQ_FATAL => 1, + ); + }; + + is $warnings, ''; + is $@, <<'END', "PREREQ_FATAL"; +MakeMaker FATAL: prerequisites not found. + I::Do::Not::Exist not installed + Nor::Do::I not installed + strict 99999 + +Please install these modules first and rerun 'perl Makefile.PL'. +END + +} diff --git a/lib/ExtUtils/t/recurs.t b/lib/ExtUtils/t/recurs.t index 53bdf478dc..17da39ee39 100644 --- a/lib/ExtUtils/t/recurs.t +++ b/lib/ExtUtils/t/recurs.t @@ -15,7 +15,7 @@ BEGIN { use strict; use Config; -use Test::More tests => 25; +use Test::More tests => 26; use MakeMaker::Test::Utils; use MakeMaker::Test::Setup::Recurs; @@ -111,3 +111,12 @@ ok( open(MAKEFILE, $submakefile) ) || diag("Can't open $submakefile: $!"); 'prepend .. not stomping WriteMakefile args' ) } close MAKEFILE; + + +{ + # Quiet "make test" failure noise + close *STDERR; + + my $test_out = run("$make test"); + isnt $?, 0, 'test failure in a subdir causes make to fail'; +}
\ No newline at end of file diff --git a/lib/ExtUtils/t/writemakefile_args.t b/lib/ExtUtils/t/writemakefile_args.t index a19a5ee644..e7b2db5ec2 100644 --- a/lib/ExtUtils/t/writemakefile_args.t +++ b/lib/ExtUtils/t/writemakefile_args.t @@ -14,7 +14,7 @@ BEGIN { } use strict; -use Test::More tests => 16; +use Test::More 'no_plan'; use TieOut; use MakeMaker::Test::Utils; @@ -53,7 +53,7 @@ ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) || }; is( $warnings, <<VERIFY ); -WARNING: MAN3PODS takes a hash reference not a string/number. +WARNING: MAN3PODS takes a HASH reference not a string/number. Please inform the author. VERIFY @@ -67,7 +67,7 @@ VERIFY }; is( $warnings, <<VERIFY ); -WARNING: AUTHOR takes a string/number not a code reference. +WARNING: AUTHOR takes a string/number not a CODE reference. Please inform the author. VERIFY @@ -105,7 +105,7 @@ VERIFY }; # We'll get warnings about the bogus libs, that's ok. - like( $warnings, qr{^WARNING: LIBS takes a array reference or string/number not a hash reference}m ); + like( $warnings, qr{^WARNING: LIBS takes a ARRAY reference or string/number not a HASH reference}m ); $warnings = ''; @@ -120,4 +120,75 @@ VERIFY is( $mm->{WIBBLE}, 'something' ); is_deeply( $mm->{wump}, { foo => 42 } ); -} + + + # Test VERSION + $warnings = ''; + eval { + $mm = WriteMakefile( + NAME => 'Big::Dummy', + VERSION => [1,2,3], + ); + }; + like( $warnings, qr{^WARNING: VERSION takes a version object or string/number} ); + + $warnings = ''; + eval { + $mm = WriteMakefile( + NAME => 'Big::Dummy', + VERSION => 1.002_003, + ); + }; + is( $warnings, '' ); + is( $mm->{VERSION}, '1.002003' ); + + $warnings = ''; + eval { + $mm = WriteMakefile( + NAME => 'Big::Dummy', + VERSION => '1.002_003', + ); + }; + is( $warnings, '' ); + is( $mm->{VERSION}, '1.002_003' ); + + + $warnings = ''; + eval { + $mm = WriteMakefile( + NAME => 'Big::Dummy', + VERSION => bless {}, "Some::Class", + ); + }; + like( $warnings, '/^WARNING: VERSION takes a version object or string/number not a Some::Class object/' ); + + + SKIP: { + skip("Can't test version objects",2) unless eval { require version }; + version->import; + + my $version = version->new("1.2.3"); + $warnings = ''; + eval { + $mm = WriteMakefile( + NAME => 'Big::Dummy', + VERSION => $version, + ); + }; + is( $warnings, '' ); + isa_ok( $mm->{VERSION}, 'version' ); + is( $mm->{VERSION}, $version ); + + $warnings = ''; + $version = qv('1.2.3'); + eval { + $mm = WriteMakefile( + NAME => 'Big::Dummy', + VERSION => $version, + ); + }; + is( $warnings, '' ); + isa_ok( $mm->{VERSION}, 'version' ); + is( $mm->{VERSION}, $version ); + } +}
\ No newline at end of file |