tests: Allow to run tests on pyboard.

To run the tests on the pyboard you need to set the "test_on_pyboard"
variable to "True", and also have tools/pyboard.py available for import
(easiest is to symlink to it).
This commit is contained in:
Damien George 2014-04-03 22:44:51 +01:00
parent d71fc37af7
commit 2309369291
1 changed files with 11 additions and 1 deletions

View File

@ -27,12 +27,22 @@ if not sys.argv[1:]:
else: else:
tests = sys.argv[1:] tests = sys.argv[1:]
test_on_pyboard = False
if test_on_pyboard:
import pyboard
pyb = pyboard.Pyboard('/dev/ttyACM0')
pyb.enter_raw_repl()
for test_file in tests: for test_file in tests:
test_name = os.path.splitext(os.path.basename(test_file))[0] test_name = os.path.splitext(os.path.basename(test_file))[0]
output_expected = subprocess.check_output([CPYTHON3, '-B', test_file]) output_expected = subprocess.check_output([CPYTHON3, '-B', test_file])
try: try:
output_mupy = subprocess.check_output([MP_PY, test_file]) if test_on_pyboard:
pyb.enter_raw_repl()
output_mupy = pyb.execfile(test_file).replace(b'\r\n', b'\n')
else:
output_mupy = subprocess.check_output([MP_PY, test_file])
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
output_mupy = b'CRASH' output_mupy = b'CRASH'