From 6f296e0b54e054c9f0099be3323abe197f81e5ce Mon Sep 17 00:00:00 2001 From: Ng Zhi An Date: Thu, 18 Jun 2020 20:38:38 -0700 Subject: [PATCH] [Py3] Get tools/testrunner/testproc closer to Py3 This modernizes python code without breaking Py2 compat. Ran with command: futurize --stage1 -w tools/testrunner/testpro Manual fixup to util_unittest to modify import paths and change to absolute imports. Bug: v8:9871 Change-Id: I2ac29622aff5daebc9dc42145c1d96dff8258546 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2252549 Reviewed-by: Tamer Tas Commit-Queue: Zhi An Ng Cr-Commit-Position: refs/heads/master@{#68492} --- tools/testrunner/testproc/progress.py | 3 ++- tools/testrunner/testproc/timeout.py | 1 + tools/testrunner/testproc/util_unittest.py | 11 ++++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tools/testrunner/testproc/progress.py b/tools/testrunner/testproc/progress.py index 0927c397d5..7a47c1b692 100644 --- a/tools/testrunner/testproc/progress.py +++ b/tools/testrunner/testproc/progress.py @@ -4,6 +4,7 @@ # for py2/py3 compatibility from __future__ import print_function +from __future__ import absolute_import import datetime import json @@ -12,7 +13,7 @@ import platform import subprocess import sys import time -import util +from . import util from . import base diff --git a/tools/testrunner/testproc/timeout.py b/tools/testrunner/testproc/timeout.py index 9a4e88c8f0..026ba02cd9 100644 --- a/tools/testrunner/testproc/timeout.py +++ b/tools/testrunner/testproc/timeout.py @@ -1,3 +1,4 @@ +from __future__ import print_function # 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. diff --git a/tools/testrunner/testproc/util_unittest.py b/tools/testrunner/testproc/util_unittest.py index 243bf9789a..5bf6a6e79a 100644 --- a/tools/testrunner/testproc/util_unittest.py +++ b/tools/testrunner/testproc/util_unittest.py @@ -3,9 +3,18 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -from util import FixedSizeTopList +from __future__ import absolute_import + +import os +import sys import unittest +TOOLS_PATH = os.path.dirname(os.path.dirname(os.path.dirname( + os.path.abspath(__file__)))) +sys.path.append(TOOLS_PATH) + +from testrunner.testproc.util import FixedSizeTopList + class TestOrderedFixedSizeList(unittest.TestCase): def test_empty(self): ofsl = FixedSizeTopList(3)