Commit e3f5789a authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

mysql-test-run.pl - show remaining test count and estimated time on Windows

Port this functionality from to Windows.
It requires Win32::Console module, which is already included into
Strawberry perl
parent 946c8795
...@@ -368,6 +368,30 @@ my $opt_stop_keep_alive= $ENV{MTR_STOP_KEEP_ALIVE}; ...@@ -368,6 +368,30 @@ my $opt_stop_keep_alive= $ENV{MTR_STOP_KEEP_ALIVE};
select(STDOUT); select(STDOUT);
$| = 1; # Automatically flush STDOUT $| = 1; # Automatically flush STDOUT
my $set_titlebar;
BEGIN {
if (IS_WINDOWS) {
my $have_win32_console= 0;
eval {
require Win32::Console;
Win32::Console->import();
$have_win32_console = 1;
};
eval 'sub HAVE_WIN32_CONSOLE { $have_win32_console }';
}
}
if (-t STDOUT) {
if (IS_WINDOWS and HAVE_WIN32_CONSOLE) {
$set_titlebar = sub {Win32::Console::Title $_[0];};
} elsif (defined $ENV{TERM} and $ENV{TERM} =~ /xterm/) {
$set_titlebar = sub { print "\e];$_[0]\a"; };
}
}
main(); main();
...@@ -865,7 +889,7 @@ sub run_test_server ($$$) { ...@@ -865,7 +889,7 @@ sub run_test_server ($$$) {
delete $next->{reserved}; delete $next->{reserved};
} }
xterm_stat(scalar(@$tests)); titlebar_stat(scalar(@$tests)) if $set_titlebar;
if ($next) { if ($next) {
# We don't need this any more # We don't need this any more
...@@ -6317,8 +6341,7 @@ sub time_format($) { ...@@ -6317,8 +6341,7 @@ sub time_format($) {
our $num_tests; our $num_tests;
sub xterm_stat { sub titlebar_stat {
if (-t STDOUT and defined $ENV{TERM} and $ENV{TERM} =~ /xterm/) {
my ($left) = @_; my ($left) = @_;
# 2.5 -> best by test # 2.5 -> best by test
...@@ -6327,9 +6350,7 @@ sub xterm_stat { ...@@ -6327,9 +6350,7 @@ sub xterm_stat {
my $done = $num_tests - $left; my $done = $num_tests - $left;
my $spent = time - $^T; my $spent = time - $^T;
syswrite STDOUT, sprintf &$set_titlebar(sprintf "mtr: spent %s on %d tests. %s (%d tests) left",
"\e];mtr: spent %s on %d tests. %s (%d tests) left\a",
time_format($spent), $done, time_format($spent), $done,
time_format($spent/$done * $left), $left; time_format($spent/$done * $left), $left);
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment