2019-11-01 02:41:16 -06:00
|
|
|
#!/usr/bin/env python3
|
2019-10-29 19:15:49 -06:00
|
|
|
import argparse
|
test: rework the output for the xkeyboard-config layout tester
The previous output is largely unusable. The result in the CI test runs is a 6GB
file with every compiled keymap in it and while we can grep for ERROR, it's not
particularly useful.
Let's change this and print out YAML instead - that can be machine-processed.
This patch adds a new parent class that prints itself in YAML format,
the tool invocations are child classes of that class. The result looks like this:
Example output:
- rmlvo: ["evdev", "pc105", "us", "haw", "grp:rwin_switch"]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant haw --options grp:rwin_switch"
status: 0
- rmlvo: ["evdev", "pc105", "us", "foo", ""]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant foo"
status: 1
error: "failed to compile keymap"
Special status codes are: 99 for "unrecognized keysym" and 90 for "Cannot open
display" in the setxkbmap case.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-14 18:39:05 -06:00
|
|
|
import multiprocessing
|
2018-08-13 19:16:30 -06:00
|
|
|
import sys
|
|
|
|
import subprocess
|
|
|
|
import os
|
|
|
|
import xml.etree.ElementTree as ET
|
2021-04-14 19:07:33 -06:00
|
|
|
from pathlib import Path
|
2018-08-13 19:16:30 -06:00
|
|
|
|
|
|
|
|
2021-04-14 16:57:51 -06:00
|
|
|
verbose = False
|
2018-08-13 19:16:30 -06:00
|
|
|
|
2023-09-28 01:50:43 -06:00
|
|
|
DEFAULT_RULES_XML = "@XKB_CONFIG_ROOT@/rules/evdev.xml"
|
2018-08-13 19:16:30 -06:00
|
|
|
|
|
|
|
# Meson needs to fill this in so we can call the tool in the buildir.
|
2023-09-28 01:50:43 -06:00
|
|
|
EXTRA_PATH = "@MESON_BUILD_ROOT@"
|
|
|
|
os.environ["PATH"] = ":".join([EXTRA_PATH, os.getenv("PATH")])
|
2018-08-13 19:16:30 -06:00
|
|
|
|
|
|
|
|
2021-04-14 16:57:51 -06:00
|
|
|
def escape(s):
|
|
|
|
return s.replace('"', '\\"')
|
2019-10-29 20:03:48 -06:00
|
|
|
|
|
|
|
|
2018-08-13 19:16:30 -06:00
|
|
|
# The function generating the progress bar (if any).
|
2021-04-14 16:57:51 -06:00
|
|
|
def create_progress_bar(verbose):
|
2021-04-15 17:24:20 -06:00
|
|
|
def noop_progress_bar(x, total, file=None):
|
2021-04-14 16:57:51 -06:00
|
|
|
return x
|
2018-08-13 19:16:30 -06:00
|
|
|
|
2021-04-14 16:57:51 -06:00
|
|
|
progress_bar = noop_progress_bar
|
|
|
|
if not verbose and os.isatty(sys.stdout.fileno()):
|
|
|
|
try:
|
|
|
|
from tqdm import tqdm
|
2023-09-28 01:50:43 -06:00
|
|
|
|
2021-04-14 16:57:51 -06:00
|
|
|
progress_bar = tqdm
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
return progress_bar
|
2018-08-13 19:16:30 -06:00
|
|
|
|
|
|
|
|
test: rework the output for the xkeyboard-config layout tester
The previous output is largely unusable. The result in the CI test runs is a 6GB
file with every compiled keymap in it and while we can grep for ERROR, it's not
particularly useful.
Let's change this and print out YAML instead - that can be machine-processed.
This patch adds a new parent class that prints itself in YAML format,
the tool invocations are child classes of that class. The result looks like this:
Example output:
- rmlvo: ["evdev", "pc105", "us", "haw", "grp:rwin_switch"]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant haw --options grp:rwin_switch"
status: 0
- rmlvo: ["evdev", "pc105", "us", "foo", ""]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant foo"
status: 1
error: "failed to compile keymap"
Special status codes are: 99 for "unrecognized keysym" and 90 for "Cannot open
display" in the setxkbmap case.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-14 18:39:05 -06:00
|
|
|
class Invocation:
|
|
|
|
def __init__(self, r, m, l, v, o):
|
|
|
|
self.command = ""
|
|
|
|
self.rules = r
|
|
|
|
self.model = m
|
|
|
|
self.layout = l
|
|
|
|
self.variant = v
|
|
|
|
self.option = o
|
|
|
|
self.exitstatus = 77 # default to skipped
|
|
|
|
self.error = None
|
|
|
|
self.keymap = None # The fully compiled keymap
|
|
|
|
|
|
|
|
@property
|
|
|
|
def rmlvo(self):
|
|
|
|
return self.rules, self.model, self.layout, self.variant, self.option
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
s = []
|
|
|
|
rmlvo = [x or "" for x in self.rmlvo]
|
2023-09-28 01:50:43 -06:00
|
|
|
rmlvo = ", ".join([f'"{x}"' for x in rmlvo])
|
|
|
|
s.append(f"- rmlvo: [{rmlvo}]")
|
test: rework the output for the xkeyboard-config layout tester
The previous output is largely unusable. The result in the CI test runs is a 6GB
file with every compiled keymap in it and while we can grep for ERROR, it's not
particularly useful.
Let's change this and print out YAML instead - that can be machine-processed.
This patch adds a new parent class that prints itself in YAML format,
the tool invocations are child classes of that class. The result looks like this:
Example output:
- rmlvo: ["evdev", "pc105", "us", "haw", "grp:rwin_switch"]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant haw --options grp:rwin_switch"
status: 0
- rmlvo: ["evdev", "pc105", "us", "foo", ""]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant foo"
status: 1
error: "failed to compile keymap"
Special status codes are: 99 for "unrecognized keysym" and 90 for "Cannot open
display" in the setxkbmap case.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-14 18:39:05 -06:00
|
|
|
s.append(f' cmd: "{escape(self.command)}"')
|
2023-09-28 01:50:43 -06:00
|
|
|
s.append(f" status: {self.exitstatus}")
|
test: rework the output for the xkeyboard-config layout tester
The previous output is largely unusable. The result in the CI test runs is a 6GB
file with every compiled keymap in it and while we can grep for ERROR, it's not
particularly useful.
Let's change this and print out YAML instead - that can be machine-processed.
This patch adds a new parent class that prints itself in YAML format,
the tool invocations are child classes of that class. The result looks like this:
Example output:
- rmlvo: ["evdev", "pc105", "us", "haw", "grp:rwin_switch"]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant haw --options grp:rwin_switch"
status: 0
- rmlvo: ["evdev", "pc105", "us", "foo", ""]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant foo"
status: 1
error: "failed to compile keymap"
Special status codes are: 99 for "unrecognized keysym" and 90 for "Cannot open
display" in the setxkbmap case.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-14 18:39:05 -06:00
|
|
|
if self.error:
|
|
|
|
s.append(f' error: "{escape(self.error.strip())}"')
|
2023-09-28 01:50:43 -06:00
|
|
|
return "\n".join(s)
|
test: rework the output for the xkeyboard-config layout tester
The previous output is largely unusable. The result in the CI test runs is a 6GB
file with every compiled keymap in it and while we can grep for ERROR, it's not
particularly useful.
Let's change this and print out YAML instead - that can be machine-processed.
This patch adds a new parent class that prints itself in YAML format,
the tool invocations are child classes of that class. The result looks like this:
Example output:
- rmlvo: ["evdev", "pc105", "us", "haw", "grp:rwin_switch"]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant haw --options grp:rwin_switch"
status: 0
- rmlvo: ["evdev", "pc105", "us", "foo", ""]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant foo"
status: 1
error: "failed to compile keymap"
Special status codes are: 99 for "unrecognized keysym" and 90 for "Cannot open
display" in the setxkbmap case.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-14 18:39:05 -06:00
|
|
|
|
|
|
|
def run(self):
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
|
|
|
|
class XkbCompInvocation(Invocation):
|
|
|
|
def run(self):
|
|
|
|
r, m, l, v, o = self.rmlvo
|
2023-09-28 01:50:43 -06:00
|
|
|
args = ["setxkbmap", "-print"]
|
test: rework the output for the xkeyboard-config layout tester
The previous output is largely unusable. The result in the CI test runs is a 6GB
file with every compiled keymap in it and while we can grep for ERROR, it's not
particularly useful.
Let's change this and print out YAML instead - that can be machine-processed.
This patch adds a new parent class that prints itself in YAML format,
the tool invocations are child classes of that class. The result looks like this:
Example output:
- rmlvo: ["evdev", "pc105", "us", "haw", "grp:rwin_switch"]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant haw --options grp:rwin_switch"
status: 0
- rmlvo: ["evdev", "pc105", "us", "foo", ""]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant foo"
status: 1
error: "failed to compile keymap"
Special status codes are: 99 for "unrecognized keysym" and 90 for "Cannot open
display" in the setxkbmap case.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-14 18:39:05 -06:00
|
|
|
if r is not None:
|
2023-09-28 01:50:43 -06:00
|
|
|
args.append("-rules")
|
|
|
|
args.append("{}".format(r))
|
test: rework the output for the xkeyboard-config layout tester
The previous output is largely unusable. The result in the CI test runs is a 6GB
file with every compiled keymap in it and while we can grep for ERROR, it's not
particularly useful.
Let's change this and print out YAML instead - that can be machine-processed.
This patch adds a new parent class that prints itself in YAML format,
the tool invocations are child classes of that class. The result looks like this:
Example output:
- rmlvo: ["evdev", "pc105", "us", "haw", "grp:rwin_switch"]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant haw --options grp:rwin_switch"
status: 0
- rmlvo: ["evdev", "pc105", "us", "foo", ""]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant foo"
status: 1
error: "failed to compile keymap"
Special status codes are: 99 for "unrecognized keysym" and 90 for "Cannot open
display" in the setxkbmap case.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-14 18:39:05 -06:00
|
|
|
if m is not None:
|
2023-09-28 01:50:43 -06:00
|
|
|
args.append("-model")
|
|
|
|
args.append("{}".format(m))
|
test: rework the output for the xkeyboard-config layout tester
The previous output is largely unusable. The result in the CI test runs is a 6GB
file with every compiled keymap in it and while we can grep for ERROR, it's not
particularly useful.
Let's change this and print out YAML instead - that can be machine-processed.
This patch adds a new parent class that prints itself in YAML format,
the tool invocations are child classes of that class. The result looks like this:
Example output:
- rmlvo: ["evdev", "pc105", "us", "haw", "grp:rwin_switch"]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant haw --options grp:rwin_switch"
status: 0
- rmlvo: ["evdev", "pc105", "us", "foo", ""]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant foo"
status: 1
error: "failed to compile keymap"
Special status codes are: 99 for "unrecognized keysym" and 90 for "Cannot open
display" in the setxkbmap case.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-14 18:39:05 -06:00
|
|
|
if l is not None:
|
2023-09-28 01:50:43 -06:00
|
|
|
args.append("-layout")
|
|
|
|
args.append("{}".format(l))
|
test: rework the output for the xkeyboard-config layout tester
The previous output is largely unusable. The result in the CI test runs is a 6GB
file with every compiled keymap in it and while we can grep for ERROR, it's not
particularly useful.
Let's change this and print out YAML instead - that can be machine-processed.
This patch adds a new parent class that prints itself in YAML format,
the tool invocations are child classes of that class. The result looks like this:
Example output:
- rmlvo: ["evdev", "pc105", "us", "haw", "grp:rwin_switch"]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant haw --options grp:rwin_switch"
status: 0
- rmlvo: ["evdev", "pc105", "us", "foo", ""]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant foo"
status: 1
error: "failed to compile keymap"
Special status codes are: 99 for "unrecognized keysym" and 90 for "Cannot open
display" in the setxkbmap case.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-14 18:39:05 -06:00
|
|
|
if v is not None:
|
2023-09-28 01:50:43 -06:00
|
|
|
args.append("-variant")
|
|
|
|
args.append("{}".format(v))
|
test: rework the output for the xkeyboard-config layout tester
The previous output is largely unusable. The result in the CI test runs is a 6GB
file with every compiled keymap in it and while we can grep for ERROR, it's not
particularly useful.
Let's change this and print out YAML instead - that can be machine-processed.
This patch adds a new parent class that prints itself in YAML format,
the tool invocations are child classes of that class. The result looks like this:
Example output:
- rmlvo: ["evdev", "pc105", "us", "haw", "grp:rwin_switch"]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant haw --options grp:rwin_switch"
status: 0
- rmlvo: ["evdev", "pc105", "us", "foo", ""]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant foo"
status: 1
error: "failed to compile keymap"
Special status codes are: 99 for "unrecognized keysym" and 90 for "Cannot open
display" in the setxkbmap case.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-14 18:39:05 -06:00
|
|
|
if o is not None:
|
2023-09-28 01:50:43 -06:00
|
|
|
args.append("-option")
|
|
|
|
args.append("{}".format(o))
|
test: rework the output for the xkeyboard-config layout tester
The previous output is largely unusable. The result in the CI test runs is a 6GB
file with every compiled keymap in it and while we can grep for ERROR, it's not
particularly useful.
Let's change this and print out YAML instead - that can be machine-processed.
This patch adds a new parent class that prints itself in YAML format,
the tool invocations are child classes of that class. The result looks like this:
Example output:
- rmlvo: ["evdev", "pc105", "us", "haw", "grp:rwin_switch"]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant haw --options grp:rwin_switch"
status: 0
- rmlvo: ["evdev", "pc105", "us", "foo", ""]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant foo"
status: 1
error: "failed to compile keymap"
Special status codes are: 99 for "unrecognized keysym" and 90 for "Cannot open
display" in the setxkbmap case.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-14 18:39:05 -06:00
|
|
|
|
2023-09-28 01:50:43 -06:00
|
|
|
xkbcomp_args = ["xkbcomp", "-xkb", "-", "-"]
|
test: rework the output for the xkeyboard-config layout tester
The previous output is largely unusable. The result in the CI test runs is a 6GB
file with every compiled keymap in it and while we can grep for ERROR, it's not
particularly useful.
Let's change this and print out YAML instead - that can be machine-processed.
This patch adds a new parent class that prints itself in YAML format,
the tool invocations are child classes of that class. The result looks like this:
Example output:
- rmlvo: ["evdev", "pc105", "us", "haw", "grp:rwin_switch"]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant haw --options grp:rwin_switch"
status: 0
- rmlvo: ["evdev", "pc105", "us", "foo", ""]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant foo"
status: 1
error: "failed to compile keymap"
Special status codes are: 99 for "unrecognized keysym" and 90 for "Cannot open
display" in the setxkbmap case.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-14 18:39:05 -06:00
|
|
|
|
|
|
|
self.command = " ".join(args + ["|"] + xkbcomp_args)
|
|
|
|
|
2023-09-28 01:50:43 -06:00
|
|
|
setxkbmap = subprocess.Popen(
|
|
|
|
args,
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.PIPE,
|
|
|
|
universal_newlines=True,
|
|
|
|
)
|
test: rework the output for the xkeyboard-config layout tester
The previous output is largely unusable. The result in the CI test runs is a 6GB
file with every compiled keymap in it and while we can grep for ERROR, it's not
particularly useful.
Let's change this and print out YAML instead - that can be machine-processed.
This patch adds a new parent class that prints itself in YAML format,
the tool invocations are child classes of that class. The result looks like this:
Example output:
- rmlvo: ["evdev", "pc105", "us", "haw", "grp:rwin_switch"]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant haw --options grp:rwin_switch"
status: 0
- rmlvo: ["evdev", "pc105", "us", "foo", ""]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant foo"
status: 1
error: "failed to compile keymap"
Special status codes are: 99 for "unrecognized keysym" and 90 for "Cannot open
display" in the setxkbmap case.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-14 18:39:05 -06:00
|
|
|
stdout, stderr = setxkbmap.communicate()
|
|
|
|
if "Cannot open display" in stderr:
|
|
|
|
self.error = stderr
|
|
|
|
self.exitstatus = 90
|
|
|
|
else:
|
2023-09-28 01:50:43 -06:00
|
|
|
xkbcomp = subprocess.Popen(
|
|
|
|
xkbcomp_args,
|
|
|
|
stdin=subprocess.PIPE,
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.PIPE,
|
|
|
|
universal_newlines=True,
|
|
|
|
)
|
test: rework the output for the xkeyboard-config layout tester
The previous output is largely unusable. The result in the CI test runs is a 6GB
file with every compiled keymap in it and while we can grep for ERROR, it's not
particularly useful.
Let's change this and print out YAML instead - that can be machine-processed.
This patch adds a new parent class that prints itself in YAML format,
the tool invocations are child classes of that class. The result looks like this:
Example output:
- rmlvo: ["evdev", "pc105", "us", "haw", "grp:rwin_switch"]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant haw --options grp:rwin_switch"
status: 0
- rmlvo: ["evdev", "pc105", "us", "foo", ""]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant foo"
status: 1
error: "failed to compile keymap"
Special status codes are: 99 for "unrecognized keysym" and 90 for "Cannot open
display" in the setxkbmap case.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-14 18:39:05 -06:00
|
|
|
stdout, stderr = xkbcomp.communicate(stdout)
|
|
|
|
if xkbcomp.returncode != 0:
|
|
|
|
self.error = "failed to compile keymap"
|
|
|
|
self.exitstatus = xkbcomp.returncode
|
|
|
|
else:
|
|
|
|
self.keymap = stdout
|
|
|
|
self.exitstatus = 0
|
|
|
|
|
|
|
|
|
|
|
|
class XkbcommonInvocation(Invocation):
|
2023-09-18 10:17:39 -06:00
|
|
|
UNRECOGNIZED_KEYSYM_ERROR = "XKB-107"
|
|
|
|
|
test: rework the output for the xkeyboard-config layout tester
The previous output is largely unusable. The result in the CI test runs is a 6GB
file with every compiled keymap in it and while we can grep for ERROR, it's not
particularly useful.
Let's change this and print out YAML instead - that can be machine-processed.
This patch adds a new parent class that prints itself in YAML format,
the tool invocations are child classes of that class. The result looks like this:
Example output:
- rmlvo: ["evdev", "pc105", "us", "haw", "grp:rwin_switch"]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant haw --options grp:rwin_switch"
status: 0
- rmlvo: ["evdev", "pc105", "us", "foo", ""]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant foo"
status: 1
error: "failed to compile keymap"
Special status codes are: 99 for "unrecognized keysym" and 90 for "Cannot open
display" in the setxkbmap case.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-14 18:39:05 -06:00
|
|
|
def run(self):
|
|
|
|
r, m, l, v, o = self.rmlvo
|
2019-10-29 19:22:49 -06:00
|
|
|
args = [
|
2023-09-28 01:50:43 -06:00
|
|
|
"xkbcli-compile-keymap", # this is run in the builddir
|
|
|
|
"--verbose",
|
|
|
|
"--rules",
|
|
|
|
r,
|
|
|
|
"--model",
|
|
|
|
m,
|
|
|
|
"--layout",
|
|
|
|
l,
|
2019-10-29 19:22:49 -06:00
|
|
|
]
|
|
|
|
if v is not None:
|
2023-09-28 01:50:43 -06:00
|
|
|
args += ["--variant", v]
|
2019-10-29 19:22:49 -06:00
|
|
|
if o is not None:
|
2023-09-28 01:50:43 -06:00
|
|
|
args += ["--options", o]
|
2019-10-29 19:22:49 -06:00
|
|
|
|
test: rework the output for the xkeyboard-config layout tester
The previous output is largely unusable. The result in the CI test runs is a 6GB
file with every compiled keymap in it and while we can grep for ERROR, it's not
particularly useful.
Let's change this and print out YAML instead - that can be machine-processed.
This patch adds a new parent class that prints itself in YAML format,
the tool invocations are child classes of that class. The result looks like this:
Example output:
- rmlvo: ["evdev", "pc105", "us", "haw", "grp:rwin_switch"]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant haw --options grp:rwin_switch"
status: 0
- rmlvo: ["evdev", "pc105", "us", "foo", ""]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant foo"
status: 1
error: "failed to compile keymap"
Special status codes are: 99 for "unrecognized keysym" and 90 for "Cannot open
display" in the setxkbmap case.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-14 18:39:05 -06:00
|
|
|
self.command = " ".join(args)
|
2019-10-29 19:22:49 -06:00
|
|
|
try:
|
2023-09-28 01:50:43 -06:00
|
|
|
output = subprocess.check_output(
|
|
|
|
args, stderr=subprocess.STDOUT, universal_newlines=True
|
|
|
|
)
|
2023-09-18 10:17:39 -06:00
|
|
|
if self.UNRECOGNIZED_KEYSYM_ERROR in output:
|
2023-09-28 01:50:43 -06:00
|
|
|
for line in output.split("\n"):
|
2023-09-18 10:17:39 -06:00
|
|
|
if self.UNRECOGNIZED_KEYSYM_ERROR in line:
|
test: rework the output for the xkeyboard-config layout tester
The previous output is largely unusable. The result in the CI test runs is a 6GB
file with every compiled keymap in it and while we can grep for ERROR, it's not
particularly useful.
Let's change this and print out YAML instead - that can be machine-processed.
This patch adds a new parent class that prints itself in YAML format,
the tool invocations are child classes of that class. The result looks like this:
Example output:
- rmlvo: ["evdev", "pc105", "us", "haw", "grp:rwin_switch"]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant haw --options grp:rwin_switch"
status: 0
- rmlvo: ["evdev", "pc105", "us", "foo", ""]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant foo"
status: 1
error: "failed to compile keymap"
Special status codes are: 99 for "unrecognized keysym" and 90 for "Cannot open
display" in the setxkbmap case.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-14 18:39:05 -06:00
|
|
|
self.error = line
|
|
|
|
self.exitstatus = 99 # tool doesn't generate this one
|
|
|
|
else:
|
|
|
|
self.exitstatus = 0
|
|
|
|
self.keymap = output
|
2019-10-29 19:22:49 -06:00
|
|
|
except subprocess.CalledProcessError as err:
|
test: rework the output for the xkeyboard-config layout tester
The previous output is largely unusable. The result in the CI test runs is a 6GB
file with every compiled keymap in it and while we can grep for ERROR, it's not
particularly useful.
Let's change this and print out YAML instead - that can be machine-processed.
This patch adds a new parent class that prints itself in YAML format,
the tool invocations are child classes of that class. The result looks like this:
Example output:
- rmlvo: ["evdev", "pc105", "us", "haw", "grp:rwin_switch"]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant haw --options grp:rwin_switch"
status: 0
- rmlvo: ["evdev", "pc105", "us", "foo", ""]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant foo"
status: 1
error: "failed to compile keymap"
Special status codes are: 99 for "unrecognized keysym" and 90 for "Cannot open
display" in the setxkbmap case.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-14 18:39:05 -06:00
|
|
|
self.error = "failed to compile keymap"
|
|
|
|
self.exitstatus = err.returncode
|
2018-08-13 19:16:30 -06:00
|
|
|
|
test: rework the output for the xkeyboard-config layout tester
The previous output is largely unusable. The result in the CI test runs is a 6GB
file with every compiled keymap in it and while we can grep for ERROR, it's not
particularly useful.
Let's change this and print out YAML instead - that can be machine-processed.
This patch adds a new parent class that prints itself in YAML format,
the tool invocations are child classes of that class. The result looks like this:
Example output:
- rmlvo: ["evdev", "pc105", "us", "haw", "grp:rwin_switch"]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant haw --options grp:rwin_switch"
status: 0
- rmlvo: ["evdev", "pc105", "us", "foo", ""]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant foo"
status: 1
error: "failed to compile keymap"
Special status codes are: 99 for "unrecognized keysym" and 90 for "Cannot open
display" in the setxkbmap case.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-14 18:39:05 -06:00
|
|
|
|
|
|
|
def xkbcommontool(rmlvo):
|
|
|
|
try:
|
2023-09-28 01:50:43 -06:00
|
|
|
r = rmlvo.get("r", "evdev")
|
|
|
|
m = rmlvo.get("m", "pc105")
|
|
|
|
l = rmlvo.get("l", "us")
|
|
|
|
v = rmlvo.get("v", None)
|
|
|
|
o = rmlvo.get("o", None)
|
test: rework the output for the xkeyboard-config layout tester
The previous output is largely unusable. The result in the CI test runs is a 6GB
file with every compiled keymap in it and while we can grep for ERROR, it's not
particularly useful.
Let's change this and print out YAML instead - that can be machine-processed.
This patch adds a new parent class that prints itself in YAML format,
the tool invocations are child classes of that class. The result looks like this:
Example output:
- rmlvo: ["evdev", "pc105", "us", "haw", "grp:rwin_switch"]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant haw --options grp:rwin_switch"
status: 0
- rmlvo: ["evdev", "pc105", "us", "foo", ""]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant foo"
status: 1
error: "failed to compile keymap"
Special status codes are: 99 for "unrecognized keysym" and 90 for "Cannot open
display" in the setxkbmap case.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-14 18:39:05 -06:00
|
|
|
tool = XkbcommonInvocation(r, m, l, v, o)
|
|
|
|
tool.run()
|
|
|
|
return tool
|
2019-10-29 19:22:49 -06:00
|
|
|
except KeyboardInterrupt:
|
|
|
|
pass
|
2018-08-13 19:16:30 -06:00
|
|
|
|
2019-10-29 00:06:10 -06:00
|
|
|
|
|
|
|
def xkbcomp(rmlvo):
|
2018-08-13 19:16:30 -06:00
|
|
|
try:
|
2023-09-28 01:50:43 -06:00
|
|
|
r = rmlvo.get("r", "evdev")
|
|
|
|
m = rmlvo.get("m", "pc105")
|
|
|
|
l = rmlvo.get("l", "us")
|
|
|
|
v = rmlvo.get("v", None)
|
|
|
|
o = rmlvo.get("o", None)
|
test: rework the output for the xkeyboard-config layout tester
The previous output is largely unusable. The result in the CI test runs is a 6GB
file with every compiled keymap in it and while we can grep for ERROR, it's not
particularly useful.
Let's change this and print out YAML instead - that can be machine-processed.
This patch adds a new parent class that prints itself in YAML format,
the tool invocations are child classes of that class. The result looks like this:
Example output:
- rmlvo: ["evdev", "pc105", "us", "haw", "grp:rwin_switch"]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant haw --options grp:rwin_switch"
status: 0
- rmlvo: ["evdev", "pc105", "us", "foo", ""]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant foo"
status: 1
error: "failed to compile keymap"
Special status codes are: 99 for "unrecognized keysym" and 90 for "Cannot open
display" in the setxkbmap case.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-14 18:39:05 -06:00
|
|
|
tool = XkbCompInvocation(r, m, l, v, o)
|
|
|
|
tool.run()
|
|
|
|
return tool
|
2019-10-29 19:22:49 -06:00
|
|
|
except KeyboardInterrupt:
|
|
|
|
pass
|
2018-08-13 19:16:30 -06:00
|
|
|
|
|
|
|
|
2019-10-29 00:06:10 -06:00
|
|
|
def parse(path):
|
|
|
|
root = ET.fromstring(open(path).read())
|
2023-09-28 01:50:43 -06:00
|
|
|
layouts = root.findall("layoutList/layout")
|
2018-08-13 19:16:30 -06:00
|
|
|
|
2023-09-28 01:50:43 -06:00
|
|
|
options = [e.text for e in root.findall("optionList/group/option/configItem/name")]
|
2018-08-13 19:16:30 -06:00
|
|
|
|
2019-10-29 00:06:10 -06:00
|
|
|
combos = []
|
|
|
|
for l in layouts:
|
2023-09-28 01:50:43 -06:00
|
|
|
layout = l.find("configItem/name").text
|
|
|
|
combos.append({"l": layout})
|
2018-08-13 19:16:30 -06:00
|
|
|
|
2023-09-28 01:50:43 -06:00
|
|
|
variants = l.findall("variantList/variant")
|
2019-10-29 00:06:10 -06:00
|
|
|
for v in variants:
|
2023-09-28 01:50:43 -06:00
|
|
|
variant = v.find("configItem/name").text
|
2018-08-13 19:16:30 -06:00
|
|
|
|
2023-09-28 01:50:43 -06:00
|
|
|
combos.append({"l": layout, "v": variant})
|
2019-10-29 00:06:10 -06:00
|
|
|
for option in options:
|
2023-09-28 01:50:43 -06:00
|
|
|
combos.append({"l": layout, "v": variant, "o": option})
|
2019-10-29 00:06:10 -06:00
|
|
|
|
|
|
|
return combos
|
|
|
|
|
|
|
|
|
2021-04-14 19:07:33 -06:00
|
|
|
def run(combos, tool, njobs, keymap_output_dir):
|
|
|
|
if keymap_output_dir:
|
|
|
|
keymap_output_dir = Path(keymap_output_dir)
|
|
|
|
try:
|
|
|
|
keymap_output_dir.mkdir()
|
|
|
|
except FileExistsError as e:
|
|
|
|
print(e, file=sys.stderr)
|
|
|
|
return False
|
|
|
|
|
|
|
|
keymap_file = None
|
|
|
|
keymap_file_fd = None
|
|
|
|
|
2019-10-29 00:06:10 -06:00
|
|
|
failed = False
|
test: rework the output for the xkeyboard-config layout tester
The previous output is largely unusable. The result in the CI test runs is a 6GB
file with every compiled keymap in it and while we can grep for ERROR, it's not
particularly useful.
Let's change this and print out YAML instead - that can be machine-processed.
This patch adds a new parent class that prints itself in YAML format,
the tool invocations are child classes of that class. The result looks like this:
Example output:
- rmlvo: ["evdev", "pc105", "us", "haw", "grp:rwin_switch"]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant haw --options grp:rwin_switch"
status: 0
- rmlvo: ["evdev", "pc105", "us", "foo", ""]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant foo"
status: 1
error: "failed to compile keymap"
Special status codes are: 99 for "unrecognized keysym" and 90 for "Cannot open
display" in the setxkbmap case.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-14 18:39:05 -06:00
|
|
|
with multiprocessing.Pool(njobs) as p:
|
2019-10-29 00:06:10 -06:00
|
|
|
results = p.imap_unordered(tool, combos)
|
2021-04-15 17:24:20 -06:00
|
|
|
for invocation in progress_bar(results, total=len(combos), file=sys.stdout):
|
test: rework the output for the xkeyboard-config layout tester
The previous output is largely unusable. The result in the CI test runs is a 6GB
file with every compiled keymap in it and while we can grep for ERROR, it's not
particularly useful.
Let's change this and print out YAML instead - that can be machine-processed.
This patch adds a new parent class that prints itself in YAML format,
the tool invocations are child classes of that class. The result looks like this:
Example output:
- rmlvo: ["evdev", "pc105", "us", "haw", "grp:rwin_switch"]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant haw --options grp:rwin_switch"
status: 0
- rmlvo: ["evdev", "pc105", "us", "foo", ""]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant foo"
status: 1
error: "failed to compile keymap"
Special status codes are: 99 for "unrecognized keysym" and 90 for "Cannot open
display" in the setxkbmap case.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-14 18:39:05 -06:00
|
|
|
if invocation.exitstatus != 0:
|
2019-10-29 00:06:10 -06:00
|
|
|
failed = True
|
test: rework the output for the xkeyboard-config layout tester
The previous output is largely unusable. The result in the CI test runs is a 6GB
file with every compiled keymap in it and while we can grep for ERROR, it's not
particularly useful.
Let's change this and print out YAML instead - that can be machine-processed.
This patch adds a new parent class that prints itself in YAML format,
the tool invocations are child classes of that class. The result looks like this:
Example output:
- rmlvo: ["evdev", "pc105", "us", "haw", "grp:rwin_switch"]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant haw --options grp:rwin_switch"
status: 0
- rmlvo: ["evdev", "pc105", "us", "foo", ""]
cmd: "xkbcli-compile-keymap --verbose --rules evdev --model pc105 --layout us --variant foo"
status: 1
error: "failed to compile keymap"
Special status codes are: 99 for "unrecognized keysym" and 90 for "Cannot open
display" in the setxkbmap case.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-14 18:39:05 -06:00
|
|
|
target = sys.stderr
|
|
|
|
else:
|
|
|
|
target = sys.stdout if verbose else None
|
|
|
|
|
|
|
|
if target:
|
|
|
|
print(invocation, file=target)
|
|
|
|
|
2021-04-14 19:07:33 -06:00
|
|
|
if keymap_output_dir:
|
|
|
|
# we're running through the layouts in a somewhat sorted manner,
|
|
|
|
# so let's keep the fd open until we switch layouts
|
|
|
|
layout = invocation.layout
|
|
|
|
if invocation.variant:
|
|
|
|
layout += f"({invocation.variant})"
|
|
|
|
fname = keymap_output_dir / layout
|
|
|
|
if fname != keymap_file:
|
|
|
|
keymap_file = fname
|
|
|
|
if keymap_file_fd:
|
|
|
|
keymap_file_fd.close()
|
2023-09-28 01:50:43 -06:00
|
|
|
keymap_file_fd = open(keymap_file, "a")
|
2021-04-14 19:07:33 -06:00
|
|
|
|
2023-09-28 01:50:43 -06:00
|
|
|
rmlvo = ", ".join([x or "" for x in invocation.rmlvo])
|
2021-04-14 19:07:33 -06:00
|
|
|
print(f"// {rmlvo}", file=keymap_file_fd)
|
|
|
|
print(invocation.keymap, file=keymap_file_fd)
|
|
|
|
keymap_file_fd.flush()
|
|
|
|
|
2019-10-29 00:06:10 -06:00
|
|
|
return failed
|
2018-08-13 19:16:30 -06:00
|
|
|
|
|
|
|
|
|
|
|
def main(args):
|
2021-04-14 16:57:51 -06:00
|
|
|
global progress_bar
|
|
|
|
global verbose
|
|
|
|
|
2019-10-29 19:15:49 -06:00
|
|
|
tools = {
|
2023-09-28 01:50:43 -06:00
|
|
|
"libxkbcommon": xkbcommontool,
|
|
|
|
"xkbcomp": xkbcomp,
|
2019-10-29 19:15:49 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(
|
2023-09-28 01:50:43 -06:00
|
|
|
description="""
|
2021-04-19 20:21:28 -06:00
|
|
|
This tool compiles a keymap for each layout, variant and
|
|
|
|
options combination in the given rules XML file. The output
|
|
|
|
of this tool is YAML, use your favorite YAML parser to
|
|
|
|
extract error messages. Errors are printed to stderr.
|
2023-09-28 01:50:43 -06:00
|
|
|
"""
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"path",
|
|
|
|
metavar="/path/to/evdev.xml",
|
|
|
|
nargs="?",
|
|
|
|
type=str,
|
|
|
|
default=DEFAULT_RULES_XML,
|
|
|
|
help="Path to xkeyboard-config's evdev.xml",
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"--tool",
|
|
|
|
choices=tools.keys(),
|
|
|
|
type=str,
|
|
|
|
default="libxkbcommon",
|
|
|
|
help="parsing tool to use",
|
|
|
|
)
|
|
|
|
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")
|
|
|
|
parser.add_argument(
|
|
|
|
"--keymap-output-dir",
|
|
|
|
default=None,
|
|
|
|
type=str,
|
|
|
|
help="Directory to print compiled keymaps to",
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"--layout", default=None, type=str, help="Only test the given layout"
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"--variant", default=None, type=str, help="Only test the given variant"
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"--option", default=None, type=str, help="Only test the given option"
|
2019-10-29 19:15:49 -06:00
|
|
|
)
|
2021-04-15 15:42:27 -06:00
|
|
|
|
2019-10-29 19:15:49 -06:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
2021-04-14 16:57:51 -06:00
|
|
|
verbose = args.verbose
|
2021-04-14 19:07:33 -06:00
|
|
|
keymapdir = args.keymap_output_dir
|
2021-04-14 16:57:51 -06:00
|
|
|
progress_bar = create_progress_bar(verbose)
|
|
|
|
|
2019-10-29 19:15:49 -06:00
|
|
|
tool = tools[args.tool]
|
|
|
|
|
2021-04-15 15:42:27 -06:00
|
|
|
if any([args.layout, args.variant, args.option]):
|
2023-09-28 01:50:43 -06:00
|
|
|
combos = [
|
|
|
|
{
|
|
|
|
"l": args.layout,
|
|
|
|
"v": args.variant,
|
|
|
|
"o": args.option,
|
|
|
|
}
|
|
|
|
]
|
2021-04-15 15:42:27 -06:00
|
|
|
else:
|
|
|
|
combos = parse(args.path)
|
2021-04-14 19:07:33 -06:00
|
|
|
failed = run(combos, tool, args.jobs, keymapdir)
|
2019-10-29 00:06:10 -06:00
|
|
|
sys.exit(failed)
|
2018-08-13 19:16:30 -06:00
|
|
|
|
|
|
|
|
2023-09-28 01:50:43 -06:00
|
|
|
if __name__ == "__main__":
|
2019-10-29 19:22:49 -06:00
|
|
|
try:
|
|
|
|
main(sys.argv)
|
|
|
|
except KeyboardInterrupt:
|
2023-09-28 01:50:43 -06:00
|
|
|
print("# Exiting after Ctrl+C")
|