/usr/share/perl5/Test/Unit/Runner/Terminal.pm is in libtest-unit-perl 0.25-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | package Test::Unit::Runner::Terminal;
use strict;
use base qw(Test::Unit::TestRunner);
sub start_suite {
my $self = shift;
$self->SUPER::start_suite(@_);
$self->_update_status;
}
sub end_suite {
my $self = shift;
$self->SUPER::end_suite(@_);
$self->_update_status;
}
sub start_test {
my $self = shift;
my ($test) = @_;
$self->{_last_test} = $test->name;
$self->_update_status;
}
sub end_test {
my $self = shift;
my ($test) = @_;
$self->{_last_test} = '';
$self->_update_status;
}
sub add_error {
my $self = shift;
my ($test, $exception) = @_;
$self->_update_status;
}
sub add_failure {
my $self = shift;
my ($test, $exception) = @_;
$self->_update_status;
}
sub add_pass {
my $self = shift;
my ($test) = @_;
$self->_update_status;
}
sub _update_status {
my $self = shift;
my $result = $self->result;
# \e[2A goes two lines up
# \e[K clears to end of line
# \e[J clears below
# \e7 saves cursor position
# \e8 restores cursor position
my $template = <<STATUS;
\e[4A\e7Run: %d, Failures: %d, Errors: %d\e[K
Current suite: %s\e[K
Current test: %s\e[J\e8
STATUS
chomp $template;
$self->_print(
sprintf $template,
$result->run_count,
$result->failure_count,
$result->error_count,
join(' -> ', map { $_->name || '?' } $self->suites_running),
$self->{_last_test} || '',
);
}
sub print_result {
my $self = shift;
$self->_print("\e[J"); # clear status lines below
$self->SUPER::print_result(@_);
}
1;
__END__
=head1 NAME
Test::Unit::Runner::Terminal - unit testing framework helper class
=head1 SYNOPSIS
use Test::Unit::Runner::Terminal;
my $testrunner = Test::Unit::Runner::Terminal->new();
$testrunner->start($my_test_class);
=head1 DESCRIPTION
This class is a test runner for the command line style use
of the testing framework.
It is similar to its parent class, Test::Unit::TestRunner, but it uses
terminal escape sequences to continually update a more informative
status report as the runner progresses through the tests than just a
string of dots, E's and F's. The status report indicates the number
of tests run, the number of failures and errors encountered, which
test is currently being run, and where it lives in the suite
hierarchy.
The class needs one argument, which is the name of the class
encapsulating the tests to be run.
=head1 OPTIONS
=over 4
=item -wait
wait for user confirmation between tests
=item -v
version info
=back
=head1 AUTHOR
Copyright (c) 2000-2002, 2005 the PerlUnit Development Team
(see L<Test::Unit> or the F<AUTHORS> file included in this
distribution).
All rights reserved. This program is free software; you can
redistribute it and/or modify it under the same terms as Perl itself.
=head1 SEE ALSO
=over 4
=item *
L<Test::Unit::TestCase>
=item *
L<Test::Unit::Listener>
=item *
L<Test::Unit::TestSuite>
=item *
L<Test::Unit::Result>
=item *
L<Test::Unit::TkTestRunner>
=item *
For further examples, take a look at the framework self test
collection (t::tlib::AllTests).
=back
=cut
|