From d8ed12f600bf9ca958cb9f285ceb10f5d8accbd3 Mon Sep 17 00:00:00 2001 From: Daniel Coonce Date: Mon, 16 Nov 2020 22:15:17 -0600 Subject: Make test harness more Windows compatible Windows doesn't seem to use UTF-8 by default, so we can specify encoding='utf-8'. Also, backslashes are confusing to regex parsers. --- test/RegressTests.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'test/RegressTests.py') diff --git a/test/RegressTests.py b/test/RegressTests.py index 9d8a7af9..7395a4c1 100755 --- a/test/RegressTests.py +++ b/test/RegressTests.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- from __future__ import print_function, unicode_literals +from io import open import sys import os @@ -40,11 +41,11 @@ if not os.path.isdir(tests) and not os.path.isfile(tests): class RegressFile(object): def __init__(self, filename): self.filename = filename - self.fd = open(self.filename) + self.fd = open(self.filename, encoding='utf-8') def transform_line(self, line): - line = re.sub('\$sourcepath', harness.sourcepath, line) - line = re.sub('\$FILE', os.path.abspath(self.filename), line) + line = line.replace('$sourcepath', harness.sourcepath) + line = line.replace('$FILE', os.path.abspath(self.filename)) return line def read_test(self): @@ -123,7 +124,7 @@ class RegressFile(object): columns=(not re.search('--columns', test['command']))) if use_stdin: - fd = open(self.filename) + fd = open(self.filename, encoding='utf-8') try: stdin = fd.read() if sys.version_info.major > 2: @@ -168,6 +169,7 @@ class RegressFile(object): if sys.platform == 'win32': process_error = [l.replace('\r\n', '\n').replace('\\', '/') for l in process_error] + test['error'] = [l.replace('\\', '/') for l in test['error']] for line in unified_diff(test['error'], process_error): index += 1 if index < 3: -- cgit v1.2.3