Commit 9dd0d714 authored by Alexander Schulze's avatar Alexander Schulze Committed by V8 LUCI CQ

[py3] Bump tools/unittests/*

Bug: v8:12581
Change-Id: Iea05e0171ad6edbda569c443c0db97e5c0bfc9ad
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3569222Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Commit-Queue: Alexander Schulze <alexschulze@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79769}
parent 0432334b
#!/usr/bin/env python3
# Copyright 2014 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
......@@ -102,11 +103,9 @@ Path pieces are concatenated. D8 is always run with the suite's path as cwd.
The test flags are passed to the js test file after '--'.
"""
# for py2/py3 compatibility
from __future__ import print_function
from functools import reduce
from collections import OrderedDict
from math import sqrt
from statistics import mean, stdev
import copy
import json
import logging
......@@ -124,21 +123,6 @@ from testrunner.local import command
from testrunner.local import utils
from testrunner.objects.output import Output, NULL_OUTPUT
from math import sqrt
# NOTE: added import here to prevent breakages during the py2/3 migration,
# once we enable python3 only, we can move the import up
try:
from numpy import mean
from numpy import std as stdev
except ImportError:
from statistics import mean, stdev
# for py2/py3 compatibility
try:
basestring # Python 2
except NameError: # Python 3
basestring = str
SUPPORTED_ARCHS = ['arm',
'ia32',
......@@ -276,7 +260,8 @@ class ResultTracker(object):
avg = mean(results)
avg_stderr = stdev(results) / sqrt(len(results))
logging.debug(' Mean: %.2f, mean_stderr: %.2f', avg, avg_stderr)
logging.info('>>> Confidence level is %.2f', avg / (1000.0 * avg_stderr))
logging.info('>>> Confidence level is %.2f',
avg / max(1000.0 * avg_stderr, .1))
return confidence_level * avg_stderr < avg / 1000.0
def __str__(self): # pragma: no cover
......@@ -349,7 +334,7 @@ class GraphConfig(Node):
assert isinstance(suite.get('path', []), list)
assert isinstance(suite.get('owners', []), list)
assert isinstance(suite['name'], basestring)
assert isinstance(suite['name'], str)
assert isinstance(suite.get('flags', []), list)
assert isinstance(suite.get('test_flags', []), list)
assert isinstance(suite.get('resources', []), list)
......
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright 2018 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright 2014 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# for py2/py3 compatibility
from __future__ import print_function
from collections import namedtuple
import json
import os
......@@ -103,8 +100,8 @@ class UnitTest(unittest.TestCase):
def testBuildDirectory(self):
base_path = os.path.join(TEST_DATA, 'builddirs', 'dir1', 'out')
expected_path = os.path.join(base_path, 'build')
self.assertEquals(
expected_path, run_perf.find_build_directory(base_path, 'x64'))
self.assertEqual(expected_path,
run_perf.find_build_directory(base_path, 'x64'))
class PerfTest(unittest.TestCase):
......@@ -383,7 +380,7 @@ class PerfTest(unittest.TestCase):
def testOneRunStdDevRegExp(self):
test_input = dict(V8_JSON)
test_input['stddev_regexp'] = '^%s\-stddev: (.+)$'
test_input['stddev_regexp'] = r'^%s-stddev: (.+)$'
self._WriteTestInput(test_input)
self._MockCommand(['.'], ['Richards: 1.234\nRichards-stddev: 0.23\n'
'DeltaBlue: 10657567\nDeltaBlue-stddev: 106\n'])
......@@ -398,7 +395,7 @@ class PerfTest(unittest.TestCase):
def testTwoRunsStdDevRegExp(self):
test_input = dict(V8_JSON)
test_input['stddev_regexp'] = '^%s\-stddev: (.+)$'
test_input['stddev_regexp'] = r'^%s-stddev: (.+)$'
test_input['run_count'] = 2
self._WriteTestInput(test_input)
self._MockCommand(['.'], ['Richards: 3\nRichards-stddev: 0.7\n'
......@@ -410,13 +407,14 @@ class PerfTest(unittest.TestCase):
{'name': 'Richards', 'results': [2.0, 3.0], 'stddev': '0.7'},
{'name': 'DeltaBlue', 'results': [5.0, 6.0], 'stddev': '0.8'},
])
self._VerifyErrors(
['Test test/Richards should only run once since a stddev is provided '
'by the test.',
'Test test/DeltaBlue should only run once since a stddev is provided '
'by the test.',
'Regexp "^DeltaBlue\-stddev: (.+)$" did not match for test '
'test/DeltaBlue.'])
self._VerifyErrors([
'Test test/Richards should only run once since a stddev is provided '
'by the test.',
'Test test/DeltaBlue should only run once since a stddev is provided '
'by the test.',
r'Regexp "^DeltaBlue-stddev: (.+)$" did not match for test '
r'test/DeltaBlue.'
])
self._VerifyMock(
os.path.join('out', 'x64.release', 'd7'), '--flag', 'run.js')
......
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright 2018 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
......
......@@ -49,9 +49,6 @@ from testrunner.local import utils
def decode(arg, encoding="utf-8"):
return arg.decode(encoding)
def encode(arg, encoding="utf-8"):
return arg.encode(encoding)
# Special LINT rules diverging from default and reason.
# build/header_guard: Our guards have the form "V8_FOO_H_", not "SRC_FOO_H_".
# We now run our own header guard check in PRESUBMIT.py.
......@@ -178,7 +175,7 @@ class FileContentsCache(object):
try:
sums_file = None
try:
sums_file = open(self.sums_file_name, 'r')
sums_file = open(self.sums_file_name, 'rb')
self.sums = pickle.load(sums_file)
except:
# Cannot parse pickle for any reason. Not much we can do about it.
......@@ -189,7 +186,7 @@ class FileContentsCache(object):
def Save(self):
try:
sums_file = open(self.sums_file_name, 'w')
sums_file = open(self.sums_file_name, 'wb')
pickle.dump(self.sums, sums_file)
except:
# Failed to write pickle. Try to clean-up behind us.
......@@ -206,8 +203,8 @@ class FileContentsCache(object):
changed_or_new = []
for file in files:
try:
handle = open(file, "r")
file_sum = md5er(encode(handle.read())).digest()
handle = open(file, "rb")
file_sum = md5er(handle.read()).digest()
if not file in self.sums or self.sums[file] != file_sum:
changed_or_new.append(file)
self.sums[file] = file_sum
......@@ -736,7 +733,6 @@ def FindTests(workspace):
# TODO(almuthanna): unskip valid tests when they are properly migrated
exclude = [
'tools/clang',
'tools/unittests/v8_presubmit_test.py',
'tools/mb/mb_test.py',
'tools/cppgc/gen_cmake_test.py',
'tools/ignition/linux_perf_report_test.py',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment