[Module-build-checkins] Module-Build/t compat.t,1.25,1.26
Status: Beta
Brought to you by:
kwilliams
|
From: Randy W. S. <si...@us...> - 2005-06-28 02:56:06
|
Update of /cvsroot/module-build/Module-Build/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9505/t Modified Files: compat.t Log Message: use Test::More Index: compat.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/compat.t,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- compat.t 27 Jun 2005 18:51:38 -0000 1.25 +++ compat.t 28 Jun 2005 02:55:43 -0000 1.26 @@ -1,35 +1,50 @@ +#!/usr/bin/perl -w + +use lib 't/lib'; use strict; -use Test; + +use Test::More; + + +use File::Spec (); +my $common_pl = File::Spec->catfile( 't', 'common.pl' ); +require $common_pl; + + +use Cwd (); +my $cwd = Cwd::cwd; + use Module::Build; use Module::Build::Compat; -use File::Spec; + use File::Path; use Config; -my $common_pl = File::Spec->catfile('t', 'common.pl'); -require $common_pl; - use Carp; $SIG{__WARN__} = \&Carp::cluck; +######################### + # Don't let our own verbosity/test_file get mixed up with our subprocess's my @makefile_keys = qw(TEST_VERBOSE HARNESS_VERBOSE TEST_FILES MAKEFLAGS); local @ENV{@makefile_keys}; delete @ENV{@makefile_keys}; -skip_test("Don't know how to invoke 'make'") - unless $Config{make} and find_in_path($Config{make}); - my @makefile_types = qw(small passthrough traditional); my $tests_per_type = 10; -plan tests => 30 + @makefile_types*$tests_per_type; +if ( $Config{make} && find_in_path($Config{make}) ) { + plan tests => 30 + @makefile_types*$tests_per_type; +} else { + plan skip_all => "Don't know how to invoke 'make'"; +} ok(1); # Loaded -my @make = $Config{make} eq 'nmake' ? ('nmake', '-nologo') : ($Config{make}); +######################### -my $startdir = Module::Build->cwd; -my $goto = File::Spec->catdir( $startdir, 't', 'Sample' ); +my @make = $Config{make} eq 'nmake' ? ('nmake', '-nologo') : ($Config{make}); + +my $goto = File::Spec->catdir( $cwd, 't', 'Sample' ); chdir $goto or die "can't chdir to $goto: $!"; my $build = Module::Build->new_from_context; @@ -47,7 +62,7 @@ $success = $build->do_system(@make, 'test'); } ); ok $success; - ok uc $output, qr{DONE\.|SUCCESS}; + like uc $output, qr{DONE\.|SUCCESS}; ok $build->do_system(@make, 'realclean'); @@ -55,7 +70,7 @@ test_makefile_creation($build, [], 'INSTALLDIRS=vendor', 1); 1 while unlink 'Makefile.PL'; - ok (! -e 'Makefile.PL', 1); + ok ! -e 'Makefile.PL'; } { @@ -64,9 +79,9 @@ my $warning = ''; local $SIG{__WARN__} = sub { $warning = shift; }; my $maketext = eval { Module::Build::Compat->fake_makefile(makefile => 'Makefile') }; - ok $@, ''; - ok $maketext, qr/^realclean/m; - ok $warning, qr/build_class/; + ok ! $@; + like $maketext, qr/^realclean/m; + like $warning, qr/build_class/; } { @@ -82,9 +97,9 @@ my $warning = stderr_of (sub { my $result = $build->run_perl_script('Makefile.PL'); - ok !$result; + ok ! $result; }); - ok $warning, qr{Foo/Builder.pm}; + like $warning, qr{Foo/Builder.pm}; } # Now make sure it can actually work. @@ -100,7 +115,7 @@ # Make sure various Makefile.PL arguments are supported Module::Build::Compat->create_makefile_pl('passthrough', $build); - my $libdir = File::Spec->catdir( $startdir, 't', 'libdir' ); + my $libdir = File::Spec->catdir( $cwd, 't', 'libdir' ); my $result = $build->run_perl_script('Makefile.PL', [], [ 'SKIP_RCFILE=1', @@ -111,35 +126,35 @@ ] ); ok $result; - ok -e 'Build.PL', 1; + ok -e 'Build.PL'; my $new_build = Module::Build->resume(); - ok $new_build->installdirs, 'core'; - ok $new_build->verbose, 1; - ok $new_build->install_destination('lib'), $libdir; - ok $new_build->extra_compiler_flags->[0], '-DPERL_POLLUTE'; + is $new_build->installdirs, 'core'; + is $new_build->verbose, 1; + is $new_build->install_destination('lib'), $libdir; + is $new_build->extra_compiler_flags->[0], '-DPERL_POLLUTE'; # Make sure those switches actually had an effect my ($ran_ok, $output); $output = stdout_of( sub { $ran_ok = $new_build->do_system(@make, 'test') } ); ok $ran_ok; $output =~ s/^/# /gm; # Don't confuse our own test output - ok $output, qr/# ok 1\s+# ok 2\s+/, 'Should be verbose'; + like $output, qr/# ok 1\s+# ok 2\s+/, 'Should be verbose'; # Make sure various Makefile arguments are supported $output = stdout_of( sub { $ran_ok = $build->do_system(@make, 'test', 'TEST_VERBOSE=0') } ); ok $ran_ok; $output =~ s/^/# /gm; # Don't confuse our own test output - ok $output, qr/# test\.+ok\s+(?:[\d.]s\s*)?# All tests/, 'Should be non-verbose'; + like $output, qr/# test\.+ok\s+(?:[\d.]s\s*)?# All tests/, 'Should be non-verbose'; $build->delete_filetree($libdir); - ok (! -e $libdir, 1, "Sample installation directory should be cleaned up"); - + ok ! -e $libdir, "Sample installation directory should be cleaned up"; + $build->do_system(@make, 'realclean'); - ok (! -e 'Makefile', 1, "Makefile shouldn't exist"); + ok ! -e 'Makefile', "Makefile shouldn't exist"; 1 while unlink 'Makefile.PL'; - ok (! -e 'Makefile.PL', 1); + ok ! -e 'Makefile.PL'; } { # Make sure tilde-expansion works @@ -152,7 +167,7 @@ $build->run_perl_script('Makefile.PL', [], ['INSTALL_BASE=~/foo']); my $b2 = Module::Build->current; ok $b2->install_base; - ok $b2->install_base !~ /^~/, 1, "Tildes should be expanded"; + unlike $b2->install_base, qr/^~/, "Tildes should be expanded"; $build->do_system(@make, 'realclean'); 1 while unlink 'Makefile.PL'; @@ -164,10 +179,10 @@ my $result = $build->run_perl_script('Makefile.PL', $preargs, $postargs); ok $result; - ok -e 'Makefile', 1, "Makefile should exist"; + ok -e 'Makefile', "Makefile should exist"; if ($cleanup) { $build->do_system(@make, 'realclean'); - ok (! -e 'Makefile', 1, "Makefile shouldn't exist"); + ok ! -e 'Makefile', "Makefile shouldn't exist"; } } |