X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F20-each.t;h=1c582464dcd9a9b566e66a2a0abd95b15b4ebf0a;hb=29a833290906751334d87b58cbdb8ede4134c6e1;hp=5e8c8fdf6fdd1608e189d4fe19cc2fb4b929960c;hpb=c344dbf4bc6a953dc52a08978bbba5be3fb3e8f9;p=perl%2Fmodules%2Frgit.git diff --git a/t/20-each.t b/t/20-each.t index 5e8c8fd..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 * 1; +use Test::More tests => 2 + 2 * 2 + 11 * (3 + 1); use App::Rgit; @@ -50,7 +50,7 @@ sub repo { my $tmpdir = tempdir(CLEANUP => 1); my $cwd = cwd; chdir $tmpdir or die "chdir($tmpdir): $!"; -my @expected = sort { $a->[0] cmp $b->[0] } build({ +my @expected = sort { $a->[1] cmp $b->[1] } build({ x => { a => { _ => repo('a', 0), @@ -58,7 +58,7 @@ my @expected = sort { $a->[0] cmp $b->[0] } build({ }, z => { '.git' => { - HEAD => 1 + refs => { dummy => 1 }, } } }, @@ -69,8 +69,8 @@ my @expected = sort { $a->[0] cmp $b->[0] } build({ }, 't' => { 't.git' => { - HEAD => 1, refs => { dummy => 1 }, + objects => { dummy => 1 }, } } }, @@ -91,7 +91,7 @@ is(grep({ ref eq 'ARRAY' } @expected), 3, 'all of them are array references'); '^n' ], @expected; -for my $cmd (qw/commit/) { +for my $cmd (qw/commit FAIL/) { my ($fh, $filename) = tempfile(UNLINK => 1); my $ar = App::Rgit->new( git => abs_path('t/bin/git'), @@ -101,9 +101,20 @@ for my $cmd (qw/commit/) { ); isnt($ar, undef, "each $cmd has a defined object"); my $exit = $ar->run; - is($exit, 0, "each $cmd returned 0"); - my @lines = sort split /\n/, do { local $/; <$fh> }; + my $fail = $cmd eq 'FAIL' ? 1 : 0; + is($exit, $fail << 8, "each $cmd returned $fail"); + my @lines = split /\n/, do { local $/; <$fh> }; my $res = [ map [ split /\|/, $_ ], @lines ]; - my $exp = [ map [ $cmd, @$_ ], @expected ]; - is_deeply($res, $exp, "each $cmd did the right thing"); + my $exp = [ map [ $cmd, @$_ ], $fail ? $expected[0] : @expected ]; + 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; + } + } }