Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
3dd0b69e
Commit
3dd0b69e
authored
Jul 23, 2015
by
Tom Soulanille
Committed by
Damien George
Jul 26, 2015
Browse files
run-tests: Use PTY when running REPL tests.
parent
7d588b0c
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/cmdline/repl_cont.py.exp
View file @
3dd0b69e
Micro Python \.\+ linux version
>>> # check REPL allows to continue input
>>> 1 \
>>> 1 \
\\\
... + 2
3
>>> 'abc'
...
...
@@ -9,10 +9,10 @@ Micro Python \.\+ linux version
'abc'
>>> '''abc
... def'''
'abc\ndef'
'abc\
\\\
ndef'
>>> """ABC
... DEF"""
'ABC\nDEF'
'ABC\
\\\
nDEF'
>>> print(
... 1 + 2)
3
...
...
tests/run-tests
View file @
3dd0b69e
...
...
@@ -42,9 +42,33 @@ def run_micropython(pyb, args, test_file):
# run the test, possibly with redirected input
try
:
if
test_file
.
startswith
(
'cmdline/repl_'
):
f
=
open
(
test_file
,
'rb'
)
output_mupy
=
subprocess
.
check_output
(
args
,
stdin
=
f
)
f
.
close
()
# Need to use a PTY to test command line editing
import
pty
import
select
def
get
():
rv
=
b
''
while
True
:
ready
=
select
.
select
([
master
],
[],
[],
0.02
)
if
ready
[
0
]
==
[
master
]:
rv
+=
os
.
read
(
master
,
1024
)
else
:
return
rv
def
send_get
(
what
):
os
.
write
(
master
,
what
)
return
get
()
with
open
(
test_file
,
'rb'
)
as
f
:
# instead of: output_mupy = subprocess.check_output(args, stdin=f)
master
,
slave
=
pty
.
openpty
()
p
=
subprocess
.
Popen
(
args
,
stdin
=
slave
,
stdout
=
slave
,
stderr
=
subprocess
.
STDOUT
,
bufsize
=
0
)
banner
=
get
()
output_mupy
=
banner
+
b
''
.
join
(
send_get
(
line
)
for
line
in
f
)
p
.
kill
()
os
.
close
(
master
)
os
.
close
(
slave
)
else
:
output_mupy
=
subprocess
.
check_output
(
args
+
[
test_file
])
except
subprocess
.
CalledProcessError
:
...
...
@@ -64,6 +88,9 @@ def run_micropython(pyb, args, test_file):
cs
.
append
(
'
\\
'
+
c
)
else
:
cs
.
append
(
c
)
# accept carriage-return(s) before final newline
if
cs
[
-
1
]
==
'
\n
'
:
cs
[
-
1
]
=
'
\r
*
\n
'
return
bytes
(
''
.
join
(
cs
),
'utf8'
)
# convert parts of the output that are not stable across runs
...
...
@@ -96,6 +123,9 @@ def run_micropython(pyb, args, test_file):
# a regex
if
lines_exp
[
i
][
1
].
match
(
lines_mupy
[
i_mupy
]):
lines_mupy
[
i_mupy
]
=
lines_exp
[
i
][
0
]
else
:
#print("don't match: %r %s" % (lines_exp[i][1], lines_mupy[i_mupy])) # DEBUG
pass
i_mupy
+=
1
if
i_mupy
>=
len
(
lines_mupy
):
break
...
...
@@ -133,10 +163,6 @@ def run_tests(pyb, tests, args):
if
native
==
b
'CRASH'
:
skip_native
=
True
# These tests no longer work; TODO change them or remove them
skip_tests
.
add
(
'cmdline/repl_basic.py'
)
skip_tests
.
add
(
'cmdline/repl_cont.py'
)
# Some tests shouldn't be run under Travis CI
if
os
.
getenv
(
'TRAVIS'
)
==
'true'
:
skip_tests
.
add
(
'basics/memoryerror.py'
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment