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>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
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)