test/tool-option-parsing: skip testing of disabled tools Signed-off-by: Ran Benita <ran@unusedvar.com>
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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
diff --git a/meson.build b/meson.build
index 1d0a161..c243ba2 100644
--- a/meson.build
+++ b/meson.build
@@ -499,6 +499,10 @@ test_env.set('XKB_LOG_LEVEL', 'debug')
test_env.set('XKB_LOG_VERBOSITY', '10')
test_env.set('top_srcdir', meson.source_root())
test_env.set('top_builddir', meson.build_root())
+test_env.set('HAVE_XKBCLI_INTERACTIVE_EVDEV', configh_data.get('HAVE_XKBCLI_INTERACTIVE_EVDEV', 0).to_string())
+test_env.set('HAVE_XKBCLI_INTERACTIVE_WAYLAND', configh_data.get('HAVE_XKBCLI_INTERACTIVE_WAYLAND', 0).to_string())
+test_env.set('HAVE_XKBCLI_INTERACTIVE_X11', configh_data.get('HAVE_XKBCLI_INTERACTIVE_X11', 0).to_string())
+test_env.set('HAVE_XKBCLI_LIST', configh_data.get('HAVE_XKBCLI_LIST', 0).to_string())
test_configh_data = configuration_data()
test_configh_data.set_quoted('TEST_XKB_CONFIG_ROOT', meson.source_root()/'test'/'data')
diff --git a/test/tool-option-parsing.py b/test/tool-option-parsing.py
index 1c092b2..a2072b3 100755
--- a/test/tool-option-parsing.py
+++ b/test/tool-option-parsing.py
@@ -65,11 +65,15 @@ class XkbcliTool:
xkbcli_tool = 'xkbcli'
subtool = None
- def __init__(self, subtool=None):
+ def __init__(self, subtool=None, skipIf=()):
self.tool_path = top_builddir
self.subtool = subtool
+ self.skipIf = skipIf
def run_command(self, args):
+ for condition, reason in self.skipIf:
+ if condition:
+ raise unittest.SkipTest(reason)
if self.subtool is not None:
tool = '{}-{}'.format(self.xkbcli_tool, self.subtool)
else:
@@ -104,20 +108,28 @@ class XkbcliTool:
return str(self.subtool)
-def get_tool(subtool=None):
- return XkbcliTool(subtool)
-
-
class TestXkbcli(unittest.TestCase):
@classmethod
def setUpClass(cls):
- cls.xkbcli = get_tool()
- cls.xkbcli_list = get_tool('list')
- cls.xkbcli_how_to_type = get_tool('how-to-type')
- cls.xkbcli_compile_keymap = get_tool('compile-keymap')
- cls.xkbcli_interactive_evdev = get_tool('interactive-evdev')
- cls.xkbcli_interactive_x11 = get_tool('interactive-x11')
- cls.xkbcli_interactive_wayland = get_tool('interactive-wayland')
+ cls.xkbcli = XkbcliTool()
+ cls.xkbcli_list = XkbcliTool('list', skipIf=(
+ (not int(os.getenv('HAVE_XKBCLI_LIST', '1')), 'xkbregistory not enabled'),
+ ))
+ cls.xkbcli_how_to_type = XkbcliTool('how-to-type')
+ cls.xkbcli_compile_keymap = XkbcliTool('compile-keymap')
+ cls.xkbcli_interactive_evdev = XkbcliTool('interactive-evdev', skipIf=(
+ (not int(os.getenv('HAVE_XKBCLI_INTERACTIVE_EVDEV', '1')), 'evdev not enabled'),
+ (not os.path.exists('/dev/input/event0'), 'event node required'),
+ (not os.access('/dev/input/event0', os.R_OK), 'insufficient permissions'),
+ ))
+ cls.xkbcli_interactive_x11 = XkbcliTool('interactive-x11', skipIf=(
+ (not int(os.getenv('HAVE_XKBCLI_INTERACTIVE_X11', '1')), 'x11 not enabled'),
+ (not os.getenv('DISPLAY'), 'DISPLAY not set'),
+ ))
+ cls.xkbcli_interactive_wayland = XkbcliTool('interactive-wayland', skipIf=(
+ (not int(os.getenv('HAVE_XKBCLI_INTERACTIVE_WAYLAND', '1')), 'wayland not enabled'),
+ (not os.getenv('WAYLAND_DISPLAY'), 'WAYLAND_DISPLAY not set'),
+ ))
cls.all_tools = [
cls.xkbcli,
cls.xkbcli_list,
@@ -236,21 +248,11 @@ class TestXkbcli(unittest.TestCase):
assert "Failed to parse XKB description" in stderr
def test_interactive_evdev_rmlvo(self):
- if not os.path.exists('/dev/input/event0'):
- self.skipTest('event node required')
- if not os.access('/dev/input/event0', os.R_OK):
- self.skipTest('insufficient permissions')
-
for rmlvo in rmlvos:
with self.subTest(rmlvo=rmlvo):
self.xkbcli_interactive_evdev.run_command_success(rmlvos)
def test_interactive_evdev(self):
- if not os.path.exists('/dev/input/event0'):
- self.skipTest('event node required')
- if not os.access('/dev/input/event0', os.R_OK):
- self.skipTest('insufficient permissions')
-
# Note: --enable-compose fails if $prefix doesn't have the compose tables
# installed
for args in (
@@ -264,16 +266,10 @@ class TestXkbcli(unittest.TestCase):
self.xkbcli_interactive_evdev.run_command_success(args)
def test_interactive_x11(self):
- if not os.getenv('DISPLAY'):
- self.skipTest('DISPLAY not set')
-
# To be filled in if we handle something other than --help
pass
def test_interactive_wayland(self):
- if not os.getenv('WAYLAND_DISPLAY'):
- self.skipTest('WAYLAND_DISPLAY not set')
-
# To be filled in if we handle something other than --help
pass