Merge pull request #28562 from yuwata/ukify-option-length

ukify: check option length
This commit is contained in:
Yu Watanabe 2023-07-29 21:41:27 +09:00 committed by GitHub
commit ae85704760
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -144,6 +144,11 @@ def test_apply_config(tmp_path):
assert ns.phase_path_groups == [['enter-initrd:leave-initrd:sysinit:ready:shutdown:final']]
def test_parse_args_minimal():
try:
ukify.parse_args([])
except ValueError as e:
print(f'expected failure: {e}')
opts = ukify.parse_args('arg1 arg2'.split())
assert opts.linux == pathlib.Path('arg1')
assert opts.initrd == [pathlib.Path('arg2')]

View file

@ -1484,7 +1484,7 @@ def finalize_options(opts):
# Figure out which syntax is being used, one of:
# ukify verb --arg --arg --arg
# ukify linux initrd…
if opts.positional[0] == 'inspect':
if len(opts.positional) >= 1 and opts.positional[0] == 'inspect':
opts.verb = opts.positional[0]
opts.files = opts.positional[1:]
if not opts.files: