mirror of
https://github.com/micropython/micropython.git
synced 2026-05-02 05:40:12 +02:00
tests/run-tests.py: Allow .native.exp files to contain regexs.
Signed-off-by: Dan Halbert <halbert@halwitz.org>
This commit is contained in:
committed by
Damien George
parent
9b36eedf36
commit
93a734020e
+11
-6
@@ -456,12 +456,12 @@ def run_micropython(pyb, args, test_file, test_file_abspath, is_special=False):
|
||||
|
||||
if is_special:
|
||||
# check for any cmdline options needed for this test
|
||||
args = [MICROPYTHON]
|
||||
cmdlist = [MICROPYTHON]
|
||||
with open(test_file, "rb") as f:
|
||||
line = f.readline()
|
||||
if line.startswith(b"# cmdline:"):
|
||||
# subprocess.check_output on Windows only accepts strings, not bytes
|
||||
args += [str(c, "utf-8") for c in line[10:].strip().split()]
|
||||
cmdlist += [str(c, "utf-8") for c in line[10:].strip().split()]
|
||||
|
||||
# run the test, possibly with redirected input
|
||||
try:
|
||||
@@ -497,10 +497,10 @@ def run_micropython(pyb, args, test_file, test_file_abspath, is_special=False):
|
||||
return get()
|
||||
|
||||
with open(test_file, "rb") as f:
|
||||
# instead of: output_mupy = subprocess.check_output(args, stdin=f)
|
||||
# instead of: output_mupy = subprocess.check_output(cmdlist, stdin=f)
|
||||
master, slave = pty.openpty()
|
||||
p = subprocess.Popen(
|
||||
args, stdin=slave, stdout=slave, stderr=subprocess.STDOUT, bufsize=0
|
||||
cmdlist, stdin=slave, stdout=slave, stderr=subprocess.STDOUT, bufsize=0
|
||||
)
|
||||
banner = get(True)
|
||||
output_mupy = banner + b"".join(send_get(line) for line in f)
|
||||
@@ -519,7 +519,7 @@ def run_micropython(pyb, args, test_file, test_file_abspath, is_special=False):
|
||||
os.close(slave)
|
||||
else:
|
||||
output_mupy = subprocess.check_output(
|
||||
args + [test_file], stderr=subprocess.STDOUT
|
||||
cmdlist + [test_file], stderr=subprocess.STDOUT
|
||||
)
|
||||
except subprocess.CalledProcessError:
|
||||
return b"CRASH"
|
||||
@@ -585,7 +585,12 @@ def run_micropython(pyb, args, test_file, test_file_abspath, is_special=False):
|
||||
|
||||
if is_special or test_file_abspath in tests_with_regex_output:
|
||||
# convert parts of the output that are not stable across runs
|
||||
with open(test_file + ".exp", "rb") as f:
|
||||
# Prefer emitter-specific expected output.
|
||||
exp_file = test_file + "." + args.emit + ".exp"
|
||||
if not os.path.isfile(exp_file):
|
||||
# Fall back to generic expected output.
|
||||
exp_file = test_file + ".exp"
|
||||
with open(exp_file, "rb") as f:
|
||||
lines_exp = []
|
||||
for line in f.readlines():
|
||||
if line == b"########\n":
|
||||
|
||||
Reference in New Issue
Block a user