Skip to content

Commit 334934e

Browse files
committed
tests/run-tests: Add --list-tests switch.
Lists tests to be executed, subject to all other filters requested. This options would be useful e.g. for scripts like tools/tinytest-codegen.py, which currently contains hardcoded filters for particular a particular target and can't work for multiple targets.
1 parent 1b223a4 commit 334934e

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

tests/run-tests

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,10 @@ def run_tests(pyb, tests, args, base_path="."):
380380
skipped_tests.append(test_name)
381381
continue
382382

383+
if args.list_tests:
384+
print(test_file)
385+
continue
386+
383387
# get expected output
384388
test_file_expected = test_file + '.exp'
385389
if os.path.isfile(test_file_expected):
@@ -430,6 +434,9 @@ def run_tests(pyb, tests, args, base_path="."):
430434

431435
test_count += 1
432436

437+
if args.list_tests:
438+
return True
439+
433440
print("{} tests performed ({} individual testcases)".format(test_count, testcase_count))
434441
print("{} tests passed".format(passed_count))
435442

@@ -451,6 +458,7 @@ def main():
451458
cmd_parser.add_argument('-p', '--password', default='python', help='the telnet login password')
452459
cmd_parser.add_argument('-d', '--test-dirs', nargs='*', help='input test directories (if no files given)')
453460
cmd_parser.add_argument('--write-exp', action='store_true', help='save .exp files to run tests w/o CPython')
461+
cmd_parser.add_argument('--list-tests', action='store_true', help='list tests instead of running them')
454462
cmd_parser.add_argument('--emit', default='bytecode', help='MicroPython emitter to use (bytecode or native)')
455463
cmd_parser.add_argument('--heapsize', help='heapsize to use (use default if not specified)')
456464
cmd_parser.add_argument('--via-mpy', action='store_true', help='compile .py files to .mpy first')
@@ -459,12 +467,12 @@ def main():
459467
args = cmd_parser.parse_args()
460468

461469
EXTERNAL_TARGETS = ('pyboard', 'wipy', 'esp8266', 'minimal')
462-
if args.target in EXTERNAL_TARGETS:
470+
if args.target == 'unix' or args.list_tests:
471+
pyb = None
472+
elif args.target in EXTERNAL_TARGETS:
463473
import pyboard
464474
pyb = pyboard.Pyboard(args.device, args.baudrate, args.user, args.password)
465475
pyb.enter_raw_repl()
466-
elif args.target == 'unix':
467-
pyb = None
468476
else:
469477
raise ValueError('target must be either %s or unix' % ", ".join(EXTERNAL_TARGETS))
470478

0 commit comments

Comments
 (0)