From: Vincent Pit Date: Tue, 7 Oct 2008 14:39:47 +0000 (+0200) Subject: Improve tests granularity X-Git-Tag: v0.04~16 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Frgit.git;a=commitdiff_plain;h=29a833290906751334d87b58cbdb8ede4134c6e1 Improve tests granularity --- diff --git a/t/20-each.t b/t/20-each.t index 4180a93..1c58246 100644 --- a/t/20-each.t +++ b/t/20-each.t @@ -7,7 +7,7 @@ use Cwd qw/cwd abs_path/; use File::Spec::Functions qw/catdir catfile/; use File::Temp qw/tempfile tempdir/; -use Test::More tests => 2 + 3 * 2; +use Test::More tests => 2 + 2 * 2 + 11 * (3 + 1); use App::Rgit; @@ -106,5 +106,15 @@ for my $cmd (qw/commit FAIL/) { my @lines = split /\n/, do { local $/; <$fh> }; my $res = [ map [ split /\|/, $_ ], @lines ]; my $exp = [ map [ $cmd, @$_ ], $fail ? $expected[0] : @expected ]; - is_deeply($res, $exp, "each $cmd did the right thing"); + for my $i (0 .. $#$exp) { + my $e = $exp->[$i]; + my $r = shift @$res; + isnt($r, undef, "each $cmd visited repository $i"); +SKIP: + { + skip 'didn\'t visited that repo' => 10 unless defined $r; + is($r->[$_], $e->[$_], "each $cmd argument $_ for repository $i is ok") + for 0 .. 9; + } + } } diff --git a/t/21-once.t b/t/21-once.t index 1b0e88b..410496c 100644 --- a/t/21-once.t +++ b/t/21-once.t @@ -6,7 +6,7 @@ use warnings; use Cwd qw/abs_path/; use File::Temp qw/tempfile/; -use Test::More tests => 4 * 2; +use Test::More tests => 8 * 4; use App::Rgit; @@ -14,17 +14,19 @@ my @expected = ( ([ [ qw/^n ^g ^w ^b ^^/ ] ]) x 4 ); -for (qw/version help daemon init/) { +for my $cmd (qw/version help daemon init/) { my ($fh, $filename) = tempfile(UNLINK => 1); my $exit = App::Rgit->new( git => abs_path('t/bin/git'), root => 't', - cmd => $_, - args => [ abs_path($filename), $_, qw/^n ^g ^w ^b ^^/ ] + cmd => $cmd, + args => [ abs_path($filename), $cmd, qw/^n ^g ^w ^b ^^/ ] )->run; - is($exit, 0, "each $_ returned 0"); + is($exit, 0, "once $cmd returned 0"); my @lines = sort split /\n/, do { local $/; <$fh> }; - my $res = [ map [ split /\|/, $_ ], @lines ]; - my $exp = [ [ $_, qw/^n ^g ^w ^b ^^/ ] ]; - is_deeply($res, $exp, "each $_ did the right thing"); + is(@lines, 1, "once $cmd visited only one repo"); + my $r = [ split /\|/, defined $lines[0] ? $lines[0] : '' ]; + my $e = [ $cmd, qw/^n ^g ^w ^b ^^/ ]; + is($r->[$_], $e->[$_], "once $cmd argument $_ is ok") + for 0 .. 5; }