kopia lustrzana https://github.com/micropython/micropython
tests/run-tests: Fix newline handling on repl/pty tests.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>pull/12802/head
rodzic
35b2edfc24
commit
784aa4c568
|
@ -214,6 +214,7 @@ def run_micropython(pyb, args, test_file, test_file_abspath, is_special=False):
|
||||||
# Need to use a PTY to test command line editing
|
# Need to use a PTY to test command line editing
|
||||||
try:
|
try:
|
||||||
import pty
|
import pty
|
||||||
|
import termios
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# in case pty module is not available, like on Windows
|
# in case pty module is not available, like on Windows
|
||||||
return b"SKIP\n"
|
return b"SKIP\n"
|
||||||
|
@ -240,6 +241,11 @@ def run_micropython(pyb, args, test_file, test_file_abspath, is_special=False):
|
||||||
with open(test_file, "rb") as f:
|
with open(test_file, "rb") as f:
|
||||||
# instead of: output_mupy = subprocess.check_output(args, stdin=f)
|
# instead of: output_mupy = subprocess.check_output(args, stdin=f)
|
||||||
master, slave = pty.openpty()
|
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(
|
p = subprocess.Popen(
|
||||||
args, stdin=slave, stdout=slave, stderr=subprocess.STDOUT, bufsize=0
|
args, stdin=slave, stdout=slave, stderr=subprocess.STDOUT, bufsize=0
|
||||||
)
|
)
|
||||||
|
|
Ładowanie…
Reference in New Issue