summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZubin Duggal <zubin.duggal@gmail.com>2021-11-23 13:47:58 +0530
committerZubin Duggal <zubin.duggal@gmail.com>2021-11-23 13:48:19 +0530
commit1e408323573af6653b67005e5fe94df2c1abc887 (patch)
tree440f471c0174ca496792c140cabf140d4e6b0852
parent742d8b6049c30f3b0cd1704d7a34d865bef41712 (diff)
downloadhaskell-wip/testsuite-title-debounce.tar.gz
testsuite: debounce title updateswip/testsuite-title-debounce
-rw-r--r--testsuite/driver/testlib.py25
1 files changed, 20 insertions, 5 deletions
diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py
index efeaa94b89..8b0ea53386 100644
--- a/testsuite/driver/testlib.py
+++ b/testsuite/driver/testlib.py
@@ -32,6 +32,8 @@ extra_src_files = {'T4198': ['exitminus1.c']} # TODO: See #12223
from my_typing import *
+from threading import Timer
+
global pool_sema
if config.use_threads:
import threading
@@ -40,6 +42,23 @@ if config.use_threads:
global wantToStop
wantToStop = False
+global title_update_timer
+title_update_timer = None
+
+# Update terminal title
+# useful progress indicator even when make test VERBOSE=1
+# Debounce the updates to avoid spamming them.
+def update_terminal_title(progress_args):
+ global title_update_timer
+ if config.supports_colors:
+ def worker():
+ print("\033]0;{0} {1} of {2} {3}\007".format(*progress_args), end="")
+ sys.stdout.flush()
+ if title_update_timer:
+ title_update_timer.cancel()
+ title_update_timer=Timer(0.05,worker)
+ title_update_timer.start()
+
# I have no idea what the type of this is
global thisdir_settings
thisdir_settings = None # type: ignore
@@ -1156,11 +1175,7 @@ def do_test(name: TestName,
else:
if_verbose(3, "=====> {0} {1} of {2} {3}".format(*progress_args))
- # Update terminal title
- # useful progress indicator even when make test VERBOSE=1
- if config.supports_colors:
- print("\033]0;{0} {1} of {2} {3}\007".format(*progress_args), end="")
- sys.stdout.flush()
+ update_terminal_title(progress_args)
# Clean up prior to the test, so that we can't spuriously conclude
# that it passed on the basis of old run outputs.