From 44e8d4b04484270df15c9615ceb1eb7451f6d0f7 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 15 Apr 2021 08:57:51 +1000 Subject: test: add proper --verbose handling to the xkeyboard-config tester Instead of defaulting to verbose on/off depending on isatty, make it an argument instead. Signed-off-by: Peter Hutterer --- test/xkeyboard-config-test.py.in | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/test/xkeyboard-config-test.py.in b/test/xkeyboard-config-test.py.in index 001f1b6..8c02125 100755 --- a/test/xkeyboard-config-test.py.in +++ b/test/xkeyboard-config-test.py.in @@ -8,7 +8,7 @@ import xml.etree.ElementTree as ET from multiprocessing import Pool -verbose = True +verbose = False DEFAULT_RULES_XML = '@XKB_CONFIG_ROOT@/rules/evdev.xml' @@ -17,20 +17,24 @@ EXTRA_PATH = '@MESON_BUILD_ROOT@' os.environ['PATH'] = ':'.join([EXTRA_PATH, os.getenv('PATH')]) -def noop_progress_bar(x, total): - return x +def escape(s): + return s.replace('"', '\\"') # The function generating the progress bar (if any). -progress_bar = noop_progress_bar -if os.isatty(sys.stdout.fileno()): - try: - from tqdm import tqdm - progress_bar = tqdm +def create_progress_bar(verbose): + def noop_progress_bar(x, total): + return x - verbose = False - except ImportError: - pass + progress_bar = noop_progress_bar + if not verbose and os.isatty(sys.stdout.fileno()): + try: + from tqdm import tqdm + progress_bar = tqdm + except ImportError: + pass + + return progress_bar def xkbcommontool(rmlvo): @@ -172,6 +176,9 @@ def run(combos, tool, njobs): def main(args): + global progress_bar + global verbose + tools = { 'libxkbcommon': xkbcommontool, 'xkbcomp': xkbcomp, @@ -190,8 +197,12 @@ def main(args): parser.add_argument('--jobs', '-j', type=int, default=os.cpu_count() * 4, help='number of processes to use') + parser.add_argument('--verbose', '-v', default=False, action="store_true") args = parser.parse_args() + verbose = args.verbose + progress_bar = create_progress_bar(verbose) + tool = tools[args.tool] combos = parse(args.path) -- cgit v1.2.3