]> git.vpit.fr Git - perl/modules/rgit.git/blob - t/21-once.t
Update VPIT::TestHelpers to 15e8aee3
[perl/modules/rgit.git] / t / 21-once.t
1 #!perl
2
3 use strict;
4 use warnings;
5
6 use Cwd        qw<abs_path>;
7 use File::Temp qw<tempfile>;
8
9 use Test::More;
10
11 use App::Rgit;
12
13 use lib 't/lib';
14 use App::Rgit::TestUtils qw<can_run_git>;
15
16 my ($can_run, $reason) = can_run_git;
17 if ($can_run) {
18  plan tests    => 9 * 5;
19 } else {
20  plan skip_all => "Can't run the mock git executable on this system: $reason";
21 }
22
23 my @expected = (
24  ([ [ qw<%n %g %w %b %%> ] ]) x 5
25 );
26
27 local $ENV{GIT_DIR}       = 't';
28 local $ENV{GIT_EXEC_PATH} = 't/bin/git';
29
30 for my $cmd (qw<daemon gui help init version>) {
31  my ($fh, $filename) = tempfile(UNLINK => 1);
32
33  my $ar = App::Rgit->new(
34   git  => $ENV{GIT_EXEC_PATH},
35   root => $ENV{GIT_DIR},
36   cmd  => $cmd,
37   args => [ abs_path($filename), $cmd, qw<%n %g %w %b %%> ],
38  );
39  isa_ok $ar, 'App::Rgit', "once $cmd is an App::Rgit object";
40
41  my $exit = $ar->run;
42  is $exit, 0, "once $cmd returned 0";
43
44  my @lines = sort split /\n/, do { local $/; <$fh> };
45  is @lines, 1, "once $cmd visited only one repo";
46
47  my $r = [ split /\|/, defined $lines[0] ? $lines[0] : '' ];
48  my $e = [ $cmd, qw<%n %g %w %b %%> ];
49  s/[\r\n]*$// for @$r;
50  for (0 .. 5) {
51   is $r->[$_], $e->[$_], "once $cmd argument $_ is ok";
52  }
53 }