From 79293ea4562ad55bf0703d39fc91493f6dd8cb5b Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 28 Mar 2019 15:25:13 +1000 Subject: [PATCH] tools: fix the tool option parse test to handle unittest arguments Pass arguments we don't handle directly through to the unittest module. This way we can filter tests with -k testname etc. Signed-off-by: Peter Hutterer --- meson.build | 2 +- tools/test-tool-option-parsing.py | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index becb2d87..94468e10 100644 --- a/meson.build +++ b/meson.build @@ -605,7 +605,7 @@ executable('ptraccel-debug', if get_option('buildtype') == 'debug' or get_option('buildtype') == 'debugoptimized' test('tool-option-parsing', find_program('tools/test-tool-option-parsing.py'), - args : [libinput_tool.full_path()], + args : ['--tool-path', libinput_tool.full_path()], timeout : 120) endif diff --git a/tools/test-tool-option-parsing.py b/tools/test-tool-option-parsing.py index 498b80c2..c68992e0 100755 --- a/tools/test-tool-option-parsing.py +++ b/tools/test-tool-option-parsing.py @@ -210,15 +210,16 @@ if __name__ == '__main__': sys.exit(77) parser = argparse.ArgumentParser(description='Verify a libinput tool\'s option parsing') - parser.add_argument('tool_path', metavar='/path/to/builddir/libinput', - type=str, nargs='?', + parser.add_argument('--tool-path', metavar='/path/to/builddir/libinput', + type=str, help='Path to the libinput tool in the builddir') parser.add_argument('--verbose', action='store_true') - args = parser.parse_args() + args, remainder = parser.parse_known_args() if args.tool_path is not None: TestLibinputTool.libinput_tool = args.tool_path verbosity = 1 if args.verbose: verbosity = 3 - del sys.argv[1:] - unittest.main(verbosity=verbosity) + + argv = [sys.argv[0], *remainder] + unittest.main(verbosity=verbosity, argv=argv)