- my $exit = App::Rgit->new(
- git => abs_path('t/bin/git'),
- root => $repos[$_],
- cmd => 'commit',
- args => [ abs_path($filename), 'commit', qw/^n ^g ^w ^b ^G ^W ^B ^R ^^/ ]
- )->run;
- is($exit, 0, "each $_ returned 0");
- my @lines = sort split /\n/, do { local $/; <$fh> };
- my $res = [ map [ split /\|/, $_ ], @lines ];
- my $exp = [ map [ 'commit', @$_ ], @{$expected[$_]} ];
- is_deeply($res, $exp, "each $_ did the right thing");
+
+ my $policy = App::Rgit::Policy->new(
+ @_ > 2 ? (policy => 'Callback', callback => $_[2])
+ : (policy => 'Default')
+ );
+
+ my $ar = App::Rgit->new(
+ git => 't/bin/git',
+ root => $tmpdir,
+ cmd => $cmd,
+ args => [ abs_path($filename), $cmd, qw/%n %g %w %b %G %W %B %R %%n %x/ ],
+ policy => $policy,
+ );
+ isa_ok $ar, 'App::Rgit', "each $cmd is an App::Rgit object";
+
+ my $exit;
+ my $fail = $cmd eq 'FAIL' ? 1 : 0;
+ if ($fail) {
+ ($exit, undef) = $ar->run;
+ } else {
+ $exit = $ar->run;
+ }
+ is $exit, $fail, "each $cmd returned $fail";
+
+ my @lines = split /\n/, do { local $/; <$fh> };
+ my $res = [ map [ split /\|/, $_ ], @lines ];
+ $exp = [ map [ $cmd, @$_ ], @$exp ];
+
+ 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' => 11 unless defined $r;
+
+ s/[\r\n]*$// for @$r;
+ for (0 .. 10) {
+ is $r->[$_], $e->[$_], "each $cmd argument $_ for repository $i is ok";
+ }
+ }
+ }