Skip to content

Commit

Permalink
tests/run-tests: Fix newline handling on repl/pty tests.
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Leech <[email protected]>
  • Loading branch information
andrewleech committed Nov 16, 2023
1 parent a00c9d5 commit b78eb8c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/run-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ def run_micropython(pyb, args, test_file, is_special=False):
# Need to use a PTY to test command line editing
try:
import pty
import termios
except ImportError:
# in case pty module is not available, like on Windows
return b"SKIP\n"
Expand All @@ -232,6 +233,11 @@ def send_get(what):
with open(test_file, "rb") as f:
# instead of: output_mupy = subprocess.check_output(args, stdin=f)
master, slave = pty.openpty()
# disable auto newline conversion on the pty terminal.
attrs = termios.tcgetattr(slave)
attrs[1] = attrs[1] & (~termios.ONLCR) | termios.ONLRET
termios.tcsetattr(slave, termios.TCSANOW, attrs)

p = subprocess.Popen(
args, stdin=slave, stdout=slave, stderr=subprocess.STDOUT, bufsize=0
)
Expand Down

0 comments on commit b78eb8c

Please sign in to comment.