Skip to content

Commit c6fd9ba

Browse files
stinospfalcon
authored andcommitted
tests: Add option to not clear MICROPYPATH when running tests
This allows using the test runner for other scenarios than just testing uPy itself. The principle of comparing either to CPython or else to a .exp file is really handy but to be able to test custom modules not built into micropython.exe one needs to be able to specify the module search path a.k.a MICROPYPATH.
1 parent ce27035 commit c6fd9ba

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

tests/run-tests

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ MPYCROSS = os.getenv('MICROPY_MPYCROSS', '../mpy-cross/mpy-cross')
2323

2424
# Set PYTHONIOENCODING so that CPython will use utf-8 on systems which set another encoding in the locale
2525
os.environ['PYTHONIOENCODING'] = 'utf-8'
26-
os.environ['MICROPYPATH'] = ''
2726

2827
def rm_f(fname):
2928
if os.path.exists(fname):
@@ -400,6 +399,7 @@ def main():
400399
cmd_parser.add_argument('--emit', default='bytecode', help='MicroPython emitter to use (bytecode or native)')
401400
cmd_parser.add_argument('--heapsize', help='heapsize to use (use default if not specified)')
402401
cmd_parser.add_argument('--via-mpy', action='store_true', help='compile .py files to .mpy first')
402+
cmd_parser.add_argument('--keep-path', action='store_true', help='do not clear MICROPYPATH when running tests')
403403
cmd_parser.add_argument('files', nargs='*', help='input test files')
404404
args = cmd_parser.parse_args()
405405

@@ -434,6 +434,10 @@ def main():
434434
# tests explicitly given
435435
tests = args.files
436436

437+
if not args.keep_path:
438+
# clear search path to make sure tests use only builtin modules
439+
os.environ['MICROPYPATH'] = ''
440+
437441
if not run_tests(pyb, tests, args):
438442
sys.exit(1)
439443

0 commit comments

Comments
 (0)