blib/lib/Test/Unit/Runner/Terminal.pm untested

filter: Statementstmt 0.0% 0 / 40 Branchbran n/a Conditioncond 0.0% 0 / 4 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 10 totaltotal 0.0% 0 / 66 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
start_suite
2.0
end_suite
2.0
CRAP 2.0
1 package Test::Unit::Runner::Terminal;
2 BEGIN {
3 $Test::Unit::Runner::Terminal::VERSION = '0.25_1325'; # added by dist-tools/SetVersion.pl
4 }
5 use strict;
6  
7 use base qw(Test::Unit::TestRunner);
8  
9 sub start_suite {
10 my $self = shift;
11 $self->SUPER::start_suite(@_);
12 $self->_update_status;
13 }
14  
15 sub end_suite {
16 my $self = shift;
17 $self->SUPER::end_suite(@_);
18 $self->_update_status;
19 }
20  
21 sub start_test {
22 my $self = shift;
23 my ($test) = @_;
24 $self->{_last_test} = $test->name;
25 $self->_update_status;
26 }
27  
28 sub end_test {
29 my $self = shift;
30 my ($test) = @_;
31 $self->{_last_test} = '';
32 $self->_update_status;
33 }
34  
35 sub add_error {
36 my $self = shift;
37 my ($test, $exception) = @_;
38 $self->_update_status;
39 }
40
41 sub add_failure {
42 my $self = shift;
43 my ($test, $exception) = @_;
44 $self->_update_status;
45 }
46  
47 sub add_pass {
48 my $self = shift;
49 my ($test) = @_;
50 $self->_update_status;
51 }
52  
53 sub _update_status {
54 my $self = shift;
55 my $result = $self->result;
56  
57 # \e[2A goes two lines up
58 # \e[K clears to end of line
59 # \e[J clears below
60 # \e7 saves cursor position
61 # \e8 restores cursor position
62 my $template = <<STATUS;
63  
64  
65  
66  
67 \e[4A\e7Run: %d, Failures: %d, Errors: %d\e[K
68 Current suite: %s\e[K
69 Current test: %s\e[J\e8
70 STATUS
71 chomp $template;
72  
73 $self->_print(
74 sprintf $template,
75 $result->run_count,
76 $result->failure_count,
77 $result->error_count,
78 join(' -> ', map { $_->name || '?' } $self->suites_running),
79 $self->{_last_test} || '',
80 );
81 }
82  
83 sub print_result {
84 my $self = shift;
85 $self->_print("\e[J"); # clear status lines below
86 $self->SUPER::print_result(@_);
87 }
88  
89 1;
90 __END__