diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2021-04-15 08:57:51 +1000 |
---|---|---|
committer | Ran Benita <ran@unusedvar.com> | 2021-04-20 10:30:17 +0300 |
commit | 44e8d4b04484270df15c9615ceb1eb7451f6d0f7 (patch) | |
tree | 01618f9f3ec942309f55f3fb193390b6a0654919 | |
parent | f04c7e93ce37c733b23c88ffad78768986a6f231 (diff) | |
download | libxkbcommon-44e8d4b04484270df15c9615ceb1eb7451f6d0f7.tar.gz libxkbcommon-44e8d4b04484270df15c9615ceb1eb7451f6d0f7.tar.bz2 libxkbcommon-44e8d4b04484270df15c9615ceb1eb7451f6d0f7.zip |
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 <peter.hutterer@who-t.net>
-rwxr-xr-x | test/xkeyboard-config-test.py.in | 33 |
1 files 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) |