Skip to content
Permalink
Browse files

test: fix test runner for Python 3 on Windows

Explicitly open files with utf8 encoding, otherwise the system could use
another encoding such as latin1 by default.

PR-URL: #30023
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
targos committed Oct 18, 2019
1 parent 8df5bdb commit 2ebd1a0d3f22a3743f11f0d6bbc8b1177194c9b3
Showing with 5 additions and 3 deletions.
  1. +2 −1 test/testpy/__init__.py
  2. +3 −2 tools/test.py
@@ -29,6 +29,7 @@
import os
import re
from functools import reduce
from io import open


FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
@@ -56,7 +57,7 @@ def GetName(self):

def GetCommand(self):
result = [self.config.context.GetVm(self.arch, self.mode)]
source = open(self.file).read()
source = open(self.file, encoding='utf8').read()
flags_match = FLAGS_PATTERN.search(source)
if flags_match:
flags = flags_match.group(1).strip().split()
@@ -45,6 +45,7 @@
import errno
import copy

from io import open
from os.path import join, dirname, abspath, basename, isdir, exists
from datetime import datetime
try:
@@ -728,8 +729,8 @@ def disableCoreFiles():
)
os.close(fd_out)
os.close(fd_err)
output = open(outname).read()
errors = open(errname).read()
output = open(outname, encoding='utf8').read()
errors = open(errname, encoding='utf8').read()
CheckedUnlink(outname)
CheckedUnlink(errname)

0 comments on commit 2ebd1a0

Please sign in to comment.
You can’t perform that action at this time.