[infra] Testrunner fixes for Python3 compatibility

Using UTF-8 encoding couldn't properly read:
test/webkit/parser-high-byte-character.js

Fix itertools rename and one usage of map that's now an iterator.

Bug: chromium:1292016
Cq-Include-Trybots: luci.v8.try.triggered:v8_linux64_python3_rel_ng_triggered
Change-Id: I2b2ab72ce0eb355d1e70f247b5ea38d1d71c7845
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3439914
Reviewed-by: Liviu Rau <liviurau@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78957}
This commit is contained in:
Michael Achenbach 2022-02-04 18:18:11 +01:00 committed by V8 LUCI CQ
parent 40c4ed6f74
commit 9e9d9142d6
4 changed files with 20 additions and 11 deletions

View File

@ -72,11 +72,13 @@ class TestCase(testcase.D8TestCase):
return self._env
def _get_files_params(self):
files = map(lambda f: os.path.join(self.suite.root, f), [
files = [
os.path.join(self.suite.root, f) for f in [
'assert.js',
'utils.js',
self.path + self._get_suffix(),
])
]
]
if self._test_config.isolates:
files += ['--isolate'] + files

View File

@ -75,11 +75,11 @@ except NameError:
def cmp(x, y): # Python 3
return (x > y) - (x < y)
def read_file_utf8(file):
def read_file(file):
try: # Python 3
with open(file, encoding='utf-8') as f:
with open(file, encoding='ISO-8859-1') as f:
return f.read()
except TypeError: # Python 2
except TypeError: # Python 2 ..
with open(file) as f:
return f.read()
@ -414,7 +414,7 @@ class TestCase(object):
return self._get_source_path() is not None
def get_source(self):
return read_file_utf8(self._get_source_path())
return read_file(self._get_source_path())
def _get_source_path(self):
return None
@ -460,7 +460,7 @@ class D8TestCase(TestCase):
"""Returns for a given file a list of absolute paths of files needed by the
given file.
"""
source = read_file_utf8(file)
source = read_file(file)
result = []
def add_path(path):
result.append(os.path.abspath(path.replace('/', os.path.sep)))

View File

@ -2,7 +2,10 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import itertools
try: # Python3
from itertools import zip_longest
except ImportError: # Python2
from itertools import izip_longest as zip_longest
from ..testproc.base import (
DROP_RESULT, DROP_OUTPUT, DROP_PASS_OUTPUT, DROP_PASS_STDOUT)
@ -146,7 +149,7 @@ class ExpectedOutProc(OutProc):
expected_lines = f.readlines()
for act_iterator in self._act_block_iterator(output):
for expected, actual in itertools.izip_longest(
for expected, actual in zip_longest(
self._expected_iterator(expected_lines),
act_iterator,
fillvalue=''

View File

@ -2,10 +2,14 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import itertools
import os
import re
try: # Python3
from itertools import zip_longest
except ImportError: # Python2
from itertools import izip_longest as zip_longest
from . import base
@ -44,7 +48,7 @@ class OutProc(base.ExpectedOutProc):
env = {
'basename': os.path.basename(base_path),
}
for (expected, actual) in itertools.izip_longest(
for (expected, actual) in zip_longest(
expected_lines, actual_lines, fillvalue=''):
pattern = re.escape(expected.rstrip() % env)
pattern = pattern.replace('\\*', '.*')