Skip to content

Commit

Permalink
runtest.py: decode using latin1. Use regex whitespace match.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kanaka committed Aug 5, 2024
1 parent f09e16d commit 85ff716
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions runtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def read_to_prompt(self, prompts, timeout):
[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
Expand All @@ -140,7 +140,7 @@ def read_to_prompt(self, prompts, timeout):

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))

Expand Down Expand Up @@ -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))
Expand All @@ -256,7 +256,7 @@ def assert_prompt(runner, prompts, timeout):
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
Expand Down Expand Up @@ -293,7 +293,7 @@ class TestTimeout(Exception):
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):
Expand Down

0 comments on commit 85ff716

Please sign in to comment.