summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Kosov <claprix@yandex.ru>2019-05-27 13:18:24 +0300
committerRobert Bindar <robert@mariadb.org>2019-06-19 09:58:30 +0300
commit15065a2398aa3ddc40625f150cf8646d505b692a (patch)
treeccf871607ffa2479f71ba6bb3ee7eaaa146185d2
parent167da05f554dbe27d16373f6f0b02408ee76dc94 (diff)
downloadmariadb-git-15065a2398aa3ddc40625f150cf8646d505b692a.tar.gz
MDEV-19531 Add colors to mtr
Colors possibility auto detected. [ such ] stuff is colored. Patch by Sergei Golubchik
-rw-r--r--mysql-test/lib/mtr_report.pm26
1 files changed, 25 insertions, 1 deletions
diff --git a/mysql-test/lib/mtr_report.pm b/mysql-test/lib/mtr_report.pm
index 9cc942e499f..5e42b342df1 100644
--- a/mysql-test/lib/mtr_report.pm
+++ b/mysql-test/lib/mtr_report.pm
@@ -36,6 +36,21 @@ use POSIX qw[ _exit ];
use IO::Handle qw[ flush ];
use mtr_results;
+use Term::ANSIColor;
+
+my %color_map = qw/pass green
+ retry-pass green
+ fail red
+ retry-fail red
+ disabled bright_black
+ skipped yellow
+ reset reset/;
+sub xterm_color {
+ if (-t STDOUT and defined $ENV{TERM} and $ENV{TERM} =~ /xterm/) {
+ syswrite STDOUT, color($color_map{$_[0]});
+ }
+}
+
my $tot_real_time= 0;
our $timestamp= 0;
@@ -494,7 +509,16 @@ sub mtr_print (@) {
sub mtr_report (@) {
if (defined $verbose)
{
- print _name(). join(" ", @_). "\n";
+ my @s = split /\[ (\S+) \]/, _name() . "@_\n";
+ if (@s > 1) {
+ print $s[0];
+ xterm_color($s[1]);
+ print "[ $s[1] ]";
+ xterm_color('reset');
+ print $s[2];
+ } else {
+ print $s[0];
+ }
}
}