[Module-build-checkins] Module-Build/t basic.t,1.51,1.52 install.t,1.32,1.33 runthrough.t,1.63,1.64
Status: Beta
Brought to you by:
kwilliams
From: Ken W. <kwi...@us...> - 2006-01-09 03:58:13
|
Update of /cvsroot/module-build/Module-Build/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12912/t Modified Files: basic.t install.t runthrough.t Log Message: Use diag() and just good test names rather than print() Index: install.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/install.t,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- install.t 9 Jan 2006 01:18:15 -0000 1.32 +++ install.t 9 Jan 2006 03:58:01 -0000 1.33 @@ -69,8 +69,7 @@ my $libdir = strip_volume( $mb->install_destination('lib') ); my $install_to = File::Spec->catfile($destdir, $libdir, $dist->name ) . '.pm'; - print "Should have installed module as $install_to\n"; - ok -e $install_to; + file_exists($install_to); local @INC = (@INC, File::Spec->catdir($destdir, $libdir)); eval "require @{[$dist->name]}"; @@ -88,8 +87,7 @@ is $@, ''; my $libdir = strip_volume( $Config{installprivlib} ); my $install_to = File::Spec->catfile($destdir, $libdir, $dist->name ) . '.pm'; - print "Should have installed module as $install_to\n"; - ok -e $install_to; + file_exists($install_to); } { @@ -97,8 +95,7 @@ eval {$mb->dispatch('install', install_path => {lib => $libdir}, destdir => $destdir)}; is $@, ''; my $install_to = File::Spec->catfile($destdir, $libdir, $dist->name ) . '.pm'; - print "Should have installed module as $install_to\n"; - ok -e $install_to; + file_exists($install_to); } { @@ -106,8 +103,7 @@ eval {$mb->dispatch('install', install_base => $libdir, destdir => $destdir)}; is $@, ''; my $install_to = File::Spec->catfile($destdir, $libdir, 'lib', 'perl5', $dist->name ) . '.pm'; - print "Should have installed module as $install_to\n"; - ok -e $install_to; + file_exists($install_to); } { @@ -163,8 +159,7 @@ eval {$mb->run_perl_script('Build', [], ['install', '--destdir', $destdir])}; is $@, ''; my $install_to = File::Spec->catfile($destdir, $libdir, $dist->name ) . '.pm'; - print "# Should have installed module as $install_to\n"; - ok -e $install_to; + file_exists($install_to); my $basedir = File::Spec->catdir('', 'bar'); eval {$mb->run_perl_script('Build', [], ['install', '--destdir', $destdir, @@ -233,6 +228,11 @@ return $dir; } +sub file_exists { + my $file = shift; + ok -e $file or diag("Expected $file to exist, but it doesn't"); +} + # cleanup chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; Index: basic.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/basic.t,v retrieving revision 1.51 retrieving revision 1.52 diff -u -d -r1.51 -r1.52 --- basic.t 9 Jan 2006 01:18:15 -0000 1.51 +++ basic.t 9 Jan 2006 03:58:00 -0000 1.52 @@ -88,8 +88,7 @@ $Foo::Module::VERSION = '1.01_02'; $info = Module::Build->check_installed_status('Foo::Module', '1.01_02'); - ok $info->{ok}; - print "# $info->{message}\n" if $info->{message}; + ok $info->{ok} or diag($info->{message}); } { Index: runthrough.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/runthrough.t,v retrieving revision 1.63 retrieving revision 1.64 diff -u -d -r1.63 -r1.64 --- runthrough.t 9 Jan 2006 01:18:15 -0000 1.63 +++ runthrough.t 9 Jan 2006 03:58:01 -0000 1.64 @@ -94,21 +94,25 @@ ok grep {$_ eq 'before_script'} $mb->cleanup; ok grep {$_ eq 'save_out' } $mb->cleanup; -my $output = eval { - stdout_of( sub { $mb->dispatch('test', verbose => 1) } ) -}; -is $@, ''; -like $output, qr/all tests successful/i; - -# This is the output of lib/Simple/Script.PL -ok -e $mb->localize_file_path('lib/Simple/Script'); - +{ + # Make sure verbose=>1 works + my $all_ok = 1; + my $output = eval { + stdout_of( sub { $mb->dispatch('test', verbose => 1) } ) + }; + $all_ok &&= is($@, ''); + $all_ok &&= like($output, qr/all tests successful/i); + + # This is the output of lib/Simple/Script.PL + $all_ok &&= ok(-e $mb->localize_file_path('lib/Simple/Script')); -# We prefix all lines with "| " so Test::Harness doesn't get confused. -print "vvvvvvvvvvvvvvvvvvvvv Simple/test.pl output vvvvvvvvvvvvvvvvvvvvv\n"; -$output =~ s/^/| /mg; -print $output; -print "^^^^^^^^^^^^^^^^^^^^^ Simple/test.pl output ^^^^^^^^^^^^^^^^^^^^^\n"; + unless ($all_ok) { + # We use diag() so Test::Harness doesn't get confused. + diag("vvvvvvvvvvvvvvvvvvvvv Simple/test.pl output vvvvvvvvvvvvvvvvvvvvv"); + diag($output); + diag("^^^^^^^^^^^^^^^^^^^^^ Simple/test.pl output ^^^^^^^^^^^^^^^^^^^^^"); + } +} SKIP: { skip( 'YAML_support feature is not enabled', 7 ) unless $have_yaml; @@ -160,9 +164,7 @@ my $fh = IO::File->new($blib_script); my $first_line = <$fh>; - print "# rewritten shebang?\n$first_line"; - - isnt $first_line, "#!perl -w\n"; + isnt $first_line, "#!perl -w\n", "should rewrite the shebang line"; } { |