File: 01-basic.t

package info (click to toggle)
libprogress-any-output-termprogressbarcolor-perl 0.249-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 176 kB
  • sloc: perl: 309; makefile: 2
file content (48 lines) | stat: -rw-r--r-- 1,295 bytes parent folder | download
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;