1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
#!perl
use 5.010001;
use strict;
use warnings;
use Test::More 0.98;
use Capture::Tiny qw(capture);
use Progress::Any;
use Progress::Any::Output;
subtest default => sub {
local $ENV{PROGRESS} = 1;
Progress::Any::Output->set('TermProgressBarColor');
my $progress = Progress::Any->get_indicator(task=>'', target=>10);
my ($out, $err, $exit) = capture {
$progress->update(message => "foo");
};
like($err, qr/foo/);
like($err, qr/10%/);
};
subtest "fh option" => sub {
local $ENV{PROGRESS} = 1;
Progress::Any::Output->set('TermProgressBarColor', fh=>\*STDOUT);
my $progress = Progress::Any->get_indicator(task=>'', target=>10);
my ($out, $err, $exit) = capture {
$progress->update(message => "foo");
};
like($out, qr/foo/);
like($out, qr/20%/);
};
subtest "default (wide)" => sub {
local $ENV{PROGRESS} = 1;
plan skip_all => 'Text::ANSI::WideUtil not available'
unless eval { require Text::ANSI::WideUtil; 1 };
Progress::Any::Output->set('TermProgressBarColor', wide=>1);
my $progress = Progress::Any->get_indicator(task=>'', target=>10);
my ($out, $err, $exit) = capture {
$progress->update(message => "foo");
};
like($err, qr/foo/);
like($err, qr/30%/);
};
done_testing;
|