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 <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2019-03-28 15:25:13 +10:00
parent 5d7c93a3d1
commit 79293ea456
2 changed files with 7 additions and 6 deletions

View file

@ -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

View file

@ -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)