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.
This commit is contained in:
stijn 2015-03-24 11:55:26 +01:00 committed by Paul Sokolovsky
parent ce2703599f
commit c6fd9ba4f3

View File

@ -23,7 +23,6 @@ MPYCROSS = os.getenv('MICROPY_MPYCROSS', '../mpy-cross/mpy-cross')
# Set PYTHONIOENCODING so that CPython will use utf-8 on systems which set another encoding in the locale
os.environ['PYTHONIOENCODING'] = 'utf-8'
os.environ['MICROPYPATH'] = ''
def rm_f(fname):
if os.path.exists(fname):
@ -400,6 +399,7 @@ def main():
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')
cmd_parser.add_argument('--keep-path', action='store_true', help='do not clear MICROPYPATH when running tests')
cmd_parser.add_argument('files', nargs='*', help='input test files')
args = cmd_parser.parse_args()
@ -434,6 +434,10 @@ def main():
# tests explicitly given
tests = args.files
if not args.keep_path:
# clear search path to make sure tests use only builtin modules
os.environ['MICROPYPATH'] = ''
if not run_tests(pyb, tests, args):
sys.exit(1)