Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

micropython: change approach to executing tests repl #335

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions micropython/micropython_repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

from trunner.types import Status, TestResult
from trunner.text import bold
from trunner.dut import Dut

import psh.tools.psh as psh

PROMPT = r"(\r*)\x1b\[0J" + r"\(psh\)% "
EOL = r"(?:\r+)\n"
Expand Down Expand Up @@ -46,12 +49,13 @@ def create_regex(text):
return text


def harness(dut):
@psh.run
def harness(dut: Dut, **kwargs):
"""Harness for testing MicroPython REPL"""

# At first echo prints path to the test
dut.expect(PROMPT)
test_path = dut.before.rstrip()
args = kwargs.get("args", "")
test_path = kwargs.get("path")
assert test_path is not None

# sending cat with path to the test to get commands to insert in micropython terminal
cmd = "cat " + test_path
Expand All @@ -71,12 +75,6 @@ def harness(dut):
# remove trailing characters
exp_output = dut.before[:-3]

# parse additional arguments for the interpreter
args = ""
for line in script:
if line.startswith("# cmdline: -"):
args = line[len("# cmdline:"):].strip()

# start micropython interpreter
dut.sendline(MICROPYTHON + args)
dut.expect(MICROPYTHON + standard_regex_escape(args) + EOL)
Expand Down
28 changes: 21 additions & 7 deletions micropython/test_repl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,32 @@ test:

tests:
- name: cmdline.repl_basic.py
execute: echo usr/test/micropython/cmdline/repl_basic.py
kwargs:
path: usr/test/micropython/cmdline/repl_basic.py

- name: cmdline.repl_emacs_keys.py
execute: echo usr/test/micropython/cmdline/repl_emacs_keys.py
kwargs:
path: usr/test/micropython/cmdline/repl_emacs_keys.py

- name: cmdline.repl_cont.py
execute: echo usr/test/micropython/cmdline/repl_cont.py
kwargs:
path: usr/test/micropython/cmdline/repl_cont.py

- name: cmdline.repl_micropyinspect.py
execute: echo usr/test/micropython/cmdline/repl_micropyinspect.py
kwargs:
path: usr/test/micropython/cmdline/repl_micropyinspect.py

- name: cmdline.repl_words_move.py
execute: echo usr/test/micropython/cmdline/repl_words_move.py
# Problem with Control Codes ?
ignore: True
kwargs:
path: usr/test/micropython/cmdline/repl_words_move.py

- name: cmdline.repl_inspect.py
execute: echo usr/test/micropython/cmdline/repl_inspect.py
kwargs:
path: usr/test/micropython/cmdline/repl_inspect.py
args: -i -c print("test")

- name: cmdline.repl_autocomplete.py
execute: echo usr/test/micropython/cmdline/repl_autocomplete.py
kwargs:
path: usr/test/micropython/cmdline/repl_autocomplete.py
Loading