From 334934ee972537d9628b9cf4f53bec952c29dcdb Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky <pfalcon@users.sourceforge.net> Date: Wed, 13 Dec 2017 18:01:35 +0200 Subject: [PATCH] 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. --- tests/run-tests | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/run-tests b/tests/run-tests index 08a92a14f..45d988b25 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -380,6 +380,10 @@ def run_tests(pyb, tests, args, base_path="."): skipped_tests.append(test_name) continue + if args.list_tests: + print(test_file) + continue + # get expected output test_file_expected = test_file + '.exp' if os.path.isfile(test_file_expected): @@ -430,6 +434,9 @@ def run_tests(pyb, tests, args, base_path="."): test_count += 1 + if args.list_tests: + return True + print("{} tests performed ({} individual testcases)".format(test_count, testcase_count)) print("{} tests passed".format(passed_count)) @@ -451,6 +458,7 @@ def main(): cmd_parser.add_argument('-p', '--password', default='python', help='the telnet login password') cmd_parser.add_argument('-d', '--test-dirs', nargs='*', help='input test directories (if no files given)') cmd_parser.add_argument('--write-exp', action='store_true', help='save .exp files to run tests w/o CPython') + cmd_parser.add_argument('--list-tests', action='store_true', help='list tests instead of running them') cmd_parser.add_argument('--emit', default='bytecode', help='MicroPython emitter to use (bytecode or native)') cmd_parser.add_argument('--heapsize', help='heapsize to use (use default if not specified)') cmd_parser.add_argument('--via-mpy', action='store_true', help='compile .py files to .mpy first') @@ -459,12 +467,12 @@ def main(): args = cmd_parser.parse_args() EXTERNAL_TARGETS = ('pyboard', 'wipy', 'esp8266', 'minimal') - if args.target in EXTERNAL_TARGETS: + if args.target == 'unix' or args.list_tests: + pyb = None + elif args.target in EXTERNAL_TARGETS: import pyboard pyb = pyboard.Pyboard(args.device, args.baudrate, args.user, args.password) pyb.enter_raw_repl() - elif args.target == 'unix': - pyb = None else: raise ValueError('target must be either %s or unix' % ", ".join(EXTERNAL_TARGETS)) -- GitLab