summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2020-04-29 22:39:44 +0200
committerVladislav Vaintroub <wlad@mariadb.com>2020-04-29 22:39:44 +0200
commite3f5789ac0b23a16bb71e06b05dec9cfec3161f0 (patch)
tree2bda154e4766bf427de00a5ee493f9aa240f22ae
parent946c879521e864baec356a7f6d890aeb6c3487d9 (diff)
downloadmariadb-git-e3f5789ac0b23a16bb71e06b05dec9cfec3161f0.tar.gz
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
-rwxr-xr-xmysql-test/mysql-test-run.pl45
1 files changed, 33 insertions, 12 deletions
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index 80abc0fbb82..aa23d697944 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -368,6 +368,30 @@ my $opt_stop_keep_alive= $ENV{MTR_STOP_KEEP_ALIVE};
select(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();
@@ -865,7 +889,7 @@ sub run_test_server ($$$) {
delete $next->{reserved};
}
- xterm_stat(scalar(@$tests));
+ titlebar_stat(scalar(@$tests)) if $set_titlebar;
if ($next) {
# We don't need this any more
@@ -6317,19 +6341,16 @@ sub time_format($) {
our $num_tests;
-sub xterm_stat {
- if (-t STDOUT and defined $ENV{TERM} and $ENV{TERM} =~ /xterm/) {
- my ($left) = @_;
+sub titlebar_stat {
+ my ($left) = @_;
- # 2.5 -> best by test
- $num_tests = $left + 2.5 unless $num_tests;
+ # 2.5 -> best by test
+ $num_tests = $left + 2.5 unless $num_tests;
- my $done = $num_tests - $left;
- my $spent = time - $^T;
+ my $done = $num_tests - $left;
+ my $spent = time - $^T;
- syswrite STDOUT, sprintf
- "\e];mtr: spent %s on %d tests. %s (%d tests) left\a",
+ &$set_titlebar(sprintf "mtr: spent %s on %d tests. %s (%d tests) left",
time_format($spent), $done,
- time_format($spent/$done * $left), $left;
- }
+ time_format($spent/$done * $left), $left);
}