'Class::MethodMaker' => '1.02',
'Term::ReadKey' => '2.14',},
BUILD_REQUIRES => {
- 'Capture::Tiny' => '0.11',
+ 'Capture::Tiny' => '0.12',
'Test::More' => '0.80',
'Test::Exception' => '0.31',
'File::Temp' => 0,
use Test::More tests => 9;
use Test::Exception;
-use Capture::Tiny qw(capture);
+use Capture::Tiny qw(capture_stderr);
use Term::ProgressBar;
=cut
{
- my ($out, $err) = capture {
+ my $err = capture_stderr {
my $p;
lives_ok {
$p = Term::ProgressBar->new({count => 10, name => 'fred',
lives_ok { $p->message('Hello Mum!') } 'Count 1-10 (3)';
lives_ok { for (6..10) { $p->update($_); sleep 1 } } 'Count 1-10 (4)';
};
- print $out;
my @lines = grep $_ ne '', split /[\n\r]+/, $err;
diag explain \@lines
use Test::More tests => 20;
use Test::Exception;
-use Capture::Tiny qw(capture);
+use Capture::Tiny qw(capture_stderr);
my $MESSAGE1 = 'The Gospel of St. Jude';
my $NAME1 = 'Algenon';
{
my $p;
- my ($out, $err) = capture {
+ my $err = capture_stderr {
lives_ok {
$p = Term::ProgressBar->new({count => 10, name => $NAME1});
} 'Count 1-10 ( 1)';
lives_ok { $p->update($_) for 1..3 } 'Count 1-10 ( 2)';
};
- print $out;
$err =~ s!^.*\r!!gm;
diag "ERR (1) :\n$err\nlength: " . length($err)
cmp_ok length($bar), '<', $barexpect+1;
- ($out, $err) = capture {
+ $err = capture_stderr {
lives_ok { $p->message($MESSAGE1) } 'Count 1-10 ( 5)';
lives_ok { $p->update($_) for 6..10 } 'Count 1-10 ( 6)';
};
- print $out;
$err =~ s!^.*\r!!gm;
diag "ERR (2) :\n$err\nlength: " . length($err)
{
my $p;
- my ($out, $err) = capture {
+ my $err = capture_stderr {
lives_ok { $p = Term::ProgressBar->new($NAME2, 10); } 'Count 1-10 ( 1)';
lives_ok { $p->update($_) for 1..3 } 'Count 1-10 ( 2)';
};
- print $out;
$err =~ s!^.*\r!!gm;
diag "ERR (1) :\n$err\nlength: " . length($err)
cmp_ok length($bar), '>', $barexpect -1;
cmp_ok length($bar), '<', $barexpect+1;
- ($out, $err) = capture {
+ $err = capture_stderr {
lives_ok { $p->message($MESSAGE1) } 'Count 1-10 ( 5)';
lives_ok { $p->update($_) for 6..10 } 'Count 1-10 ( 6)';
};
- print $out;
$err =~ s!^.*\r!!gm;
diag "ERR (2) :\n$err\nlength: " . length($err)
use Test::More tests => 8;
use Test::Exception;
-use Capture::Tiny qw(capture);
+use Capture::Tiny qw(capture_stderr);
my $MESSAGE1 = 'Walking on the Milky Way';
=cut
{
- my ($out, $err) = capture {
+ my $err = capture_stderr {
my $p;
lives_ok { $p = Term::ProgressBar->new('bob', 10); } 'Count 1-10 (1)';
lives_ok { $p->update($_) for 1..5 } 'Count 1-10 (2)';
lives_ok { $p->message($MESSAGE1) } 'Count 1-10 (3)';
lives_ok { $p->update($_) for 6..10 } 'Count 1-10 (4)';
};
- print $out;
$err =~ s!^.*\r!!gm;
diag "ERR:\n$err\nlength: ", length($err)
use Test::More tests => 11;
use Test::Exception;
-use Capture::Tiny qw(capture);
+use Capture::Tiny qw(capture_stderr);
my $MESSAGE1 = 'Walking on the Milky Way';
=cut
{
- my ($out, $err) = capture {
+ my $err = capture_stderr {
my $p;
lives_ok { $p = Term::ProgressBar->new(10); } 'Count 1-10 (1)';
lives_ok { $p->update($_) for 1..5 } 'Count 1-10 (2)';
lives_ok { $p->message($MESSAGE1) } 'Count 1-10 (3)';
lives_ok { $p->update($_) for 6..10 } 'Count 1-10 (4)';
};
- print $out;
$err =~ s!^.*\r!!gm;
diag "ERR:\n$err\nlength: " . length($err)
=cut
{
- my ($out, $err) = capture {
+ my $err = capture_stderr {
my $p;
lives_ok { $p = Term::ProgressBar->new(100); } 'Message Check ( 1)';
lives_ok { for (0..100) { $p->update($_); $p->message("Hello") } } 'Message Check ( 2)';
};
- print $out;
my @err_lines = split /\n/, $err;
(my $last_line = $err_lines[-1]) =~ tr/\r//d;
use Test::More tests => 7;
use Test::Exception;
-use Capture::Tiny qw(capture);
+use Capture::Tiny qw(capture_stderr);
use_ok 'Term::ProgressBar';
=cut
-my ($out, $err) = capture {
+my $err = capture_stderr {
my $p;
lives_ok { $p = Term::ProgressBar->new(10); } 'Count 1-20 (1)';
lives_ok { $p->update($_) for 1..5 } 'Count 1-20 (2)';
lives_ok { $p->target(20) } 'Count 1-20 (3)';
lives_ok { $p->update($_) for 11..20 } 'Count 1-20 (4)';
};
-print $out;
$err =~ s!^.*\r!!gm;
diag "ERR:\n$err\nlength: " . length($err)
use Test::More tests => 31;
use Test::Exception;
-use Capture::Tiny qw(capture);
+use Capture::Tiny qw(capture_stderr);
use_ok 'Term::ProgressBar';
=cut
{
- my ($out, $err) = capture {
+ my $err = capture_stderr {
my $p;
lives_ok { $p = Term::ProgressBar->new(10); } 'Count 1-10 (1)';
lives_ok { $p->update($_) for 1..10 } 'Count 1-10 (2)';
};
- print $out;
my @lines = grep {$_ ne ''} split /\r/, $err;
diag explain \@lines
=cut
{
- my ($out, $err) = capture {
+ my $err = capture_stderr {
my $p;
lives_ok { $p = Term::ProgressBar->new(10); } 'Count 1-9 (1)';
lives_ok { $p->update($_) for 1..9 } 'Count 1-9 (2)';
};
- print $out;
my @lines = grep $_ ne '', split /\r/, $err;
diag explain \@lines
=cut
{
- my ($out, $err) = capture {
+ my $err = capture_stderr {
my $tp = Term::ProgressBar->new(1000000);
$tp->update($_) foreach (0, 1);
};
- #print $out;
my @lines = grep {$_ ne ''} split /\r/, $err;
diag explain \@lines
use Test::More tests => 9;
use Test::Exception;
-use Capture::Tiny qw(capture);
+use Capture::Tiny qw(capture_stderr);
use_ok 'Term::ProgressBar';
{
my $p;
my $name = 'doing nothing';
- my ($out, $err) = capture {
+ my $err = capture_stderr {
lives_ok { $p = Term::ProgressBar->new($name, 0); } 'V1 mode ( 1)';
lives_ok { $p->update($_) for 1..10 } 'V1 mode ( 2)';
};
- print $out;
my @lines = grep { $_ ne ''} split /\r/, $err;
diag explain @lines
{
my $p;
my $name = 'zero';
- my ($out, $err) = capture {
+ my $err = capture_stderr {
lives_ok { $p = Term::ProgressBar->new({ count => 0, name => $name }); } 'V2 mode ( 1)';
lives_ok { $p->update($_) for 1..10 } 'V2 mode ( 2)';
};
- print $out;
my @lines = grep {$_ ne ''} split /\r/, $err;
diag explain @lines