Skip to content

Commit

Permalink
scripts/test.py: improved handling of incorrect args.
Browse files Browse the repository at this point in the history
We now check that specified commands are all in (build, buildtest, test), and
do so before creating/entering a venv and running the commands.
  • Loading branch information
julian-smith-artifex-com committed Jan 22, 2024
1 parent e8066d1 commit 5b9e2f1
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions scripts/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,16 @@ def main(argv):
log(f'No command specified.')
return

commands = list()
while 1:
assert arg in ('build', 'buildtest', 'test'), \
f'Unrecognised command: {arg=}.'
commands.append(arg)
try:
arg = next(args)
except StopIteration:
break

# We always want to run inside a venv.
if sys.prefix == sys.base_prefix:
# We are not running in a venv.
Expand All @@ -182,22 +192,19 @@ def do_test():
pytest_options=pytest_options,
timeout=timeout,
)
while 1:

for command in commands:
if 0:
pass
elif arg == 'build':
elif command == 'build':
do_build()
elif arg == 'test':
elif command == 'test':
do_test()
elif arg == 'buildtest':
elif command == 'buildtest':
do_build()
do_test()
else:
assert 0, f'Unrecognised command: {arg=}.'
try:
arg = next(args)
except StopIteration:
break
assert 0


def show_help():
Expand Down

0 comments on commit 5b9e2f1

Please sign in to comment.