1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-20 10:07:45 +03:00

runtest.py: decode using latin1. Use regex whitespace match.

Some implementations send non-UTF-8 codes (i.e. es6 when showing
function representations). So use latin1 which is probably closer to
what most things are outputting to the terminal.
This commit is contained in:
Joel Martin 2024-08-05 16:43:59 -05:00
parent f09e16dd76
commit 85ff716e5a

View File

@ -122,7 +122,7 @@ class Runner():
[outs,_,_] = select([self.stdout], [], [], 1)
if self.stdout in outs:
new_data = self.stdout.read(1)
new_data = new_data.decode("utf-8") if IS_PY_3 else new_data
new_data = new_data.decode("latin1") if IS_PY_3 else new_data
#print("new_data: '%s'" % new_data)
debug(new_data)
# Perform newline cleanup
@ -140,7 +140,7 @@ class Runner():
def writeline(self, str):
def _to_bytes(s):
return bytes(s, "utf-8") if IS_PY_3 else s
return bytes(s, "latin1") if IS_PY_3 else s
self.stdin.write(_to_bytes(str.replace('\r', '\x16\r') + self.line_break))
@ -245,7 +245,7 @@ def assert_prompt(runner, prompts, timeout):
# Wait for the initial prompt
try:
assert_prompt(r, ['[^\s()<>]+> '], args.start_timeout)
assert_prompt(r, ['[^\\s()<>]+> '], args.start_timeout)
except:
_, exc, _ = sys.exc_info()
log("\nException: %s" % repr(exc))
@ -256,7 +256,7 @@ except:
if args.pre_eval:
sys.stdout.write("RUNNING pre-eval: %s" % args.pre_eval)
r.writeline(args.pre_eval)
assert_prompt(r, ['[^\s()<>]+> '], args.test_timeout)
assert_prompt(r, ['[^\\s()<>]+> '], args.test_timeout)
test_cnt = 0
pass_cnt = 0
@ -293,7 +293,7 @@ while t.next():
r.writeline(t.form)
try:
test_cnt += 1
res = r.read_to_prompt(['\r\n[^\s()<>]+> ', '\n[^\s()<>]+> '],
res = r.read_to_prompt(['\r\n[^\\s()<>]+> ', '\n[^\\s()<>]+> '],
timeout=args.test_timeout)
#print "%s,%s,%s" % (idx, repr(p.before), repr(p.after))
if (res == None):