]> git.vpit.fr Git - perl/modules/rgit.git/blob - t/16-levels.t
Use @ as the escape character. ^ is actually an escape char of cmd.exe
[perl/modules/rgit.git] / t / 16-levels.t
1 #!perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 4;
7
8 use App::Rgit::Config;
9 use App::Rgit::Utils qw/:levels/;
10
11 local $SIG{__WARN__} = sub { diag @_ };
12 local $SIG{__DIE__} = sub { diag @_ };
13
14 my %levels = (
15  info => INFO,
16  warn => WARN,
17  err  => ERR,
18  crit => CRIT,
19 );
20 my @levels = sort { $levels{$b} <=> $levels{$a} } keys %levels;
21
22 my $olderr;
23 open $olderr, '>&', \*STDERR or die "Can't dup STDERR: $!";
24
25 for my $l (0 .. $#levels) {
26  my $arc = App::Rgit::Config->new(
27   root  => 't',
28   git   => 't/bin/git',
29   debug => $levels{$levels[$l]}
30  );
31  my $buf = '';
32  close STDERR;
33  open STDERR, '>', \$buf or die "open(STDERR, '>', \\\$buf): $!";
34  $arc->$_($_) for qw/info warn err crit/;
35  is($buf, join('', @levels[$l .. $#levels]), "level $l ok");
36 }
37
38 close STDERR;
39 open STDERR, '>&', $olderr or die "Can't dup \$olderr: $!";