Skip to content

Commit 3b06437

Browse files
blmorrisdpgeorge
authored andcommitted
Enable device keyword option when running pyboard.py --tests and run-tests --pyboard
1 parent 762d575 commit 3b06437

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

tests/run-tests

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ def run_tests(pyb, tests, args):
139139
def main():
140140
cmd_parser = argparse.ArgumentParser(description='Run tests for Micro Python.')
141141
cmd_parser.add_argument('--pyboard', action='store_true', help='run the tests on the pyboard')
142+
cmd_parser.add_argument('--device', default='/dev/ttyACM0', help='the serial device of the pyboard')
142143
cmd_parser.add_argument('-d', '--test-dirs', nargs='*', help='input test directories (if no files given)')
143144
cmd_parser.add_argument('--write-exp', action='store_true', help='save .exp files to run tests w/o CPython')
144145
cmd_parser.add_argument('--emit', default='bytecode', help='Micro Python emitter to use (bytecode or native)')
@@ -147,7 +148,7 @@ def main():
147148

148149
if args.pyboard:
149150
import pyboard
150-
pyb = pyboard.Pyboard('/dev/ttyACM0')
151+
pyb = pyboard.Pyboard(args.device)
151152
pyb.enter_raw_repl()
152153
else:
153154
pyb = None

tools/pyboard.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ def execfile(filename, device='/dev/ttyACM0'):
105105
pyb.exit_raw_repl()
106106
pyb.close()
107107

108-
def run_test():
109-
device = '/dev/ttyACM0'
108+
def run_test(device):
110109
pyb = Pyboard(device)
111110
pyb.enter_raw_repl()
112111
print('opened device {}'.format(device))
113112

113+
pyb.exec('import pyb') # module pyb no longer imported by default, required for pyboard tests
114114
print('seconds since boot:', pyb.get_time())
115115

116116
pyb.exec('def apply(l, f):\r\n for item in l:\r\n f(item)\r\n')
@@ -170,7 +170,7 @@ def main():
170170
args = cmd_parser.parse_args()
171171

172172
if args.test:
173-
run_test()
173+
run_test(device=args.device)
174174

175175
for file in args.files:
176176
execfile(file, device=args.device)

0 commit comments

Comments
 (0)