[Module-build-checkins] Module-Build/t basic.t,1.37,1.38
Status: Beta
Brought to you by:
kwilliams
|
From: Randy W. S. <si...@us...> - 2005-06-27 23:24:41
|
Update of /cvsroot/module-build/Module-Build/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24195/t Modified Files: basic.t Log Message: use Test::More Index: basic.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/basic.t,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- basic.t 31 Mar 2005 09:40:14 -0000 1.37 +++ basic.t 27 Jun 2005 23:24:32 -0000 1.38 @@ -1,42 +1,47 @@ -######################### We start with some black magic to print on failure. +#!/usr/bin/perl -w +use lib 't/lib'; use strict; -use Test; -BEGIN { plan tests => 52 } -use Module::Build; -ok(1); -use File::Spec; -use Cwd; +use Test::More tests => 52; -my $common_pl = File::Spec->catfile('t', 'common.pl'); + +use File::Spec (); +my $common_pl = File::Spec->catfile( 't', 'common.pl' ); require $common_pl; -######################### End of black magic. -ok $INC{'Module/Build.pm'}, '/blib/', "Make sure Module::Build was loaded from blib/"; +use Cwd (); +my $cwd = Cwd::cwd; -chdir 't'; +######################### + + +use_ok 'Module::Build'; + +like $INC{'Module/Build.pm'}, qr|/blib/|, "Make sure Module::Build was loaded from blib/"; + +chdir( 't' ) or die "Can't chdir to 't': $!"; # Test object creation { my $build = new Module::Build( module_name => 'ModuleBuildOne' ); ok $build; - ok $build->module_name, 'ModuleBuildOne'; - ok $build->build_class, 'Module::Build'; - ok $build->dist_name, 'ModuleBuildOne'; + is $build->module_name, 'ModuleBuildOne'; + is $build->build_class, 'Module::Build'; + is $build->dist_name, 'ModuleBuildOne'; $build = Module::Build->new( dist_name => 'ModuleBuildOne', dist_version => 7 ); ok $build; - ok $build->module_name, ''; # Make sure it's defined - ok $build->dist_name, 'ModuleBuildOne'; + is $build->module_name, ''; # Make sure it's defined + is $build->dist_name, 'ModuleBuildOne'; } # Make sure actions are defined, and known_actions works as class method { my %actions = map {$_, 1} Module::Build->known_actions; - ok $actions{clean}, 1; - ok $actions{distdir}, 1; + ok $actions{clean}; + ok $actions{distdir}; } # Test prerequisite checking @@ -49,7 +54,7 @@ module_name => 'ModuleBuildOne', requires => {ModuleBuildOne => 0}, ); - ok $flagged, 0; + ok !$flagged; ok !$m->prereq_failures; $m->dispatch('realclean'); @@ -59,29 +64,29 @@ module_name => 'ModuleBuildOne', requires => {ModuleBuildOne => 3}, ); - ok $flagged, 1; + ok $flagged; ok $m->prereq_failures; ok $m->prereq_failures->{requires}{ModuleBuildOne}; - ok $m->prereq_failures->{requires}{ModuleBuildOne}{have}, 0.01; - ok $m->prereq_failures->{requires}{ModuleBuildOne}{need}, 3; + is $m->prereq_failures->{requires}{ModuleBuildOne}{have}, 0.01; + is $m->prereq_failures->{requires}{ModuleBuildOne}{need}, 3; $m->dispatch('realclean'); # Make sure check_installed_status() works as a class method my $info = Module::Build->check_installed_status('File::Spec', 0); - ok $info->{ok}, 1; - ok $info->{have}, $File::Spec::VERSION; + ok $info->{ok}; + is $info->{have}, $File::Spec::VERSION; # Make sure check_installed_status() works with an advanced spec $info = Module::Build->check_installed_status('File::Spec', '> 0'); - ok $info->{ok}, 1; + ok $info->{ok}; # Use 2 lines for this, to avoid a "used only once" warning local $Foo::Module::VERSION; $Foo::Module::VERSION = '1.01_02'; $info = Module::Build->check_installed_status('Foo::Module', '1.01_02'); - ok $info->{ok}, 1; + ok $info->{ok}; print "# $info->{message}\n" if $info->{message}; } @@ -109,8 +114,8 @@ $m->add_to_cleanup('save_out'); # Use uc() so we don't confuse the current test output - ok uc(stdout_of( sub {$m->dispatch('test', verbose => 1)} )), qr/^OK 2/m; - ok uc(stdout_of( sub {$m->dispatch('test', verbose => 0)} )), qr/\.\.OK/; + like uc(stdout_of( sub {$m->dispatch('test', verbose => 1)} )), qr/^OK 2/m; + like uc(stdout_of( sub {$m->dispatch('test', verbose => 0)} )), qr/\.\.OK/; $m->dispatch('realclean'); chdir $cwd or die "Can't change back to $cwd: $!"; @@ -125,35 +130,35 @@ chdir 'Sample'; eval {Module::Build->run_perl_script('Build.PL', [], ['skip_rcfile=1', '--config', "foocakes=barcakes", '--foo', '--bar', '--bar', '-bat=hello', 'gee=whiz', '--any', 'hey', '--destdir', 'yo', '--verbose', '1'])}; - ok $@, ''; + ok not $@; my $b = Module::Build->resume(); - ok $b->config->{cc}, $Config{cc}; - ok $b->config->{foocakes}, 'barcakes'; + is $b->config->{cc}, $Config{cc}; + is $b->config->{foocakes}, 'barcakes'; # Test args(). - ok $b->args('foo'), 1; - ok $b->args('bar'), 2, 'bar'; - ok $b->args('bat'), 'hello', 'bat'; - ok $b->args('gee'), 'whiz'; - ok $b->args('any'), 'hey'; - ok $b->args('dee'), 'goo'; - ok $b->destdir, 'yo'; - ok $b->runtime_params('destdir'), 'yo'; - ok $b->runtime_params('verbose'), '1'; - ok !$b->runtime_params('license'); + is $b->args('foo'), 1; + is $b->args('bar'), 2, 'bar'; + is $b->args('bat'), 'hello', 'bat'; + is $b->args('gee'), 'whiz'; + is $b->args('any'), 'hey'; + is $b->args('dee'), 'goo'; + is $b->destdir, 'yo'; + is $b->runtime_params('destdir'), 'yo'; + is $b->runtime_params('verbose'), '1'; + ok not $b->runtime_params('license'); ok my %runtime = $b->runtime_params; - ok scalar keys %runtime, 4; - ok $runtime{destdir}, 'yo'; - ok $runtime{verbose}, '1'; + is scalar keys %runtime, 4; + is $runtime{destdir}, 'yo'; + is $runtime{verbose}, '1'; ok $runtime{config}; ok my $argsref = $b->args; - ok $argsref->{foo}, 1; + is $argsref->{foo}, 1; $argsref->{doo} = 'hee'; - ok $b->args('doo'), 'hee'; + is $b->args('doo'), 'hee'; ok my %args = $b->args; - ok $args{foo}, 1; + is $args{foo}, 1; chdir $cwd or die "Can't change back to $cwd: $!"; } @@ -168,6 +173,6 @@ ); ok $build; ok ref($build->dist_author); - ok $build->dist_author->[0], 'Foo Meister <fo...@ex...>'; - ok $build->build_class, 'My::Big::Fat::Builder'; + is $build->dist_author->[0], 'Foo Meister <fo...@ex...>'; + is $build->build_class, 'My::Big::Fat::Builder'; } |