From 997253f28696ab14d9876469d0ac36c3b8b9f747 Mon Sep 17 00:00:00 2001 From: Justin Wood Date: Thu, 26 Dec 2019 21:17:55 +0000 Subject: [PATCH] Bug 1559975 - Make layout/tools/reftest lint with 'py2' and 'py3' r=catlee Depends on D36093 Differential Revision: https://phabricator.services.mozilla.com/D36094 --HG-- extra : moz-landing-system : lando --- layout/tools/reftest/mach_commands.py | 2 +- .../reftest/mach_test_package_commands.py | 2 +- layout/tools/reftest/output.py | 2 ++ layout/tools/reftest/reftest/__init__.py | 2 +- layout/tools/reftest/reftestcommandline.py | 2 ++ layout/tools/reftest/remotereftest.py | 2 +- layout/tools/reftest/runreftest.py | 21 ++++++++++++++++--- layout/tools/reftest/selftest/conftest.py | 2 ++ .../selftest/test_reftest_manifest_parser.py | 2 ++ .../reftest/selftest/test_reftest_output.py | 2 ++ tools/lint/py3.yml | 1 - 11 files changed, 32 insertions(+), 8 deletions(-) diff --git a/layout/tools/reftest/mach_commands.py b/layout/tools/reftest/mach_commands.py index 47af5a267a91..1ee40780af96 100644 --- a/layout/tools/reftest/mach_commands.py +++ b/layout/tools/reftest/mach_commands.py @@ -2,7 +2,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, unicode_literals, print_function import os import re diff --git a/layout/tools/reftest/mach_test_package_commands.py b/layout/tools/reftest/mach_test_package_commands.py index 7cf4d7c76952..c79874882f45 100644 --- a/layout/tools/reftest/mach_test_package_commands.py +++ b/layout/tools/reftest/mach_test_package_commands.py @@ -2,7 +2,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals, print_function import os from argparse import Namespace diff --git a/layout/tools/reftest/output.py b/layout/tools/reftest/output.py index aa74a2a5e6a6..811f9c3dd3e0 100644 --- a/layout/tools/reftest/output.py +++ b/layout/tools/reftest/output.py @@ -2,6 +2,8 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +from __future__ import absolute_import, print_function + import json import threading from collections import defaultdict diff --git a/layout/tools/reftest/reftest/__init__.py b/layout/tools/reftest/reftest/__init__.py index 61f8b271db4d..c712025433b4 100644 --- a/layout/tools/reftest/reftest/__init__.py +++ b/layout/tools/reftest/reftest/__init__.py @@ -2,7 +2,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from __future__ import unicode_literals +from __future__ import unicode_literals, absolute_import, print_function import os import re diff --git a/layout/tools/reftest/reftestcommandline.py b/layout/tools/reftest/reftestcommandline.py index 6854c8752aca..e64a5f63e7e9 100644 --- a/layout/tools/reftest/reftestcommandline.py +++ b/layout/tools/reftest/reftestcommandline.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import, print_function + import argparse import os from collections import OrderedDict diff --git a/layout/tools/reftest/remotereftest.py b/layout/tools/reftest/remotereftest.py index 480fc375defa..3e4a6a8d8d47 100644 --- a/layout/tools/reftest/remotereftest.py +++ b/layout/tools/reftest/remotereftest.py @@ -2,7 +2,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from __future__ import print_function +from __future__ import absolute_import, print_function import os import posixpath diff --git a/layout/tools/reftest/runreftest.py b/layout/tools/reftest/runreftest.py index fd94890c9cea..29e2b94645e7 100644 --- a/layout/tools/reftest/runreftest.py +++ b/layout/tools/reftest/runreftest.py @@ -7,6 +7,8 @@ Runs the reftest test harness. """ from __future__ import print_function +from __future__ import absolute_import, print_function + import copy import json import multiprocessing @@ -82,6 +84,18 @@ summaryLines = [('Successful', [('pass', 'pass'), ('loadOnly', 'load only')]), ('slow', 'slow')])] +if sys.version_info[0] == 3: + def reraise_(tp_, value_, tb_=None): + if value_ is None: + value_ = tp_() + if value_.__traceback__ is not tb_: + raise value_.with_traceback(tb_) + raise value_ + +else: + exec("def reraise_(tp_, value_, tb_=None):\n raise tp_, value_, tb_\n") + + def update_mozinfo(): """walk up directories to find mozinfo.json update the info""" # TODO: This should go in a more generic place, e.g. mozinfo @@ -116,7 +130,7 @@ class ReftestThread(threading.Thread): process = subprocess.Popen(self.cmdargs, stdout=subprocess.PIPE) for chunk in self.chunkForMergedOutput(process.stdout): with printLock: - print(chunk,) + print(chunk, end=' ') sys.stdout.flush() self.retcode = process.wait() @@ -671,8 +685,9 @@ class RefTest(object): for (summaryObj, (text, categories)) in zip(summaryObjects, summaryLines): details = ', '.join(["%d %s" % (summaryObj[attribute], description) for ( attribute, description) in categories]) - print('REFTEST INFO | ' + text + ': ' + str(summaryObj['total']) + - ' (' + details + ')') + print( + 'REFTEST INFO | ' + text + ': ' + str(summaryObj['total']) + ' (' + details + ')' + ) return int(any(t.retcode != 0 for t in threads)) diff --git a/layout/tools/reftest/selftest/conftest.py b/layout/tools/reftest/selftest/conftest.py index e146d4ae54e7..6649bef0bbc8 100644 --- a/layout/tools/reftest/selftest/conftest.py +++ b/layout/tools/reftest/selftest/conftest.py @@ -2,6 +2,8 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +from __future__ import absolute_import, print_function + import json import os from argparse import Namespace diff --git a/layout/tools/reftest/selftest/test_reftest_manifest_parser.py b/layout/tools/reftest/selftest/test_reftest_manifest_parser.py index a489de8137a4..c07a699566e4 100644 --- a/layout/tools/reftest/selftest/test_reftest_manifest_parser.py +++ b/layout/tools/reftest/selftest/test_reftest_manifest_parser.py @@ -2,6 +2,8 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +from __future__ import absolute_import, print_function + import mozunit import pytest diff --git a/layout/tools/reftest/selftest/test_reftest_output.py b/layout/tools/reftest/selftest/test_reftest_output.py index a6102f653a57..faddb0242978 100644 --- a/layout/tools/reftest/selftest/test_reftest_output.py +++ b/layout/tools/reftest/selftest/test_reftest_output.py @@ -2,6 +2,8 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +from __future__ import absolute_import, print_function + import os from cStringIO import StringIO from functools import partial diff --git a/tools/lint/py3.yml b/tools/lint/py3.yml index e121965fab95..58f6eee4e99f 100644 --- a/tools/lint/py3.yml +++ b/tools/lint/py3.yml @@ -10,7 +10,6 @@ py3: - ipc/ipdl - layout/reftests - layout/style/ServoCSSPropList.mako.py - - layout/tools/reftest - security/manager/ssl - testing/awsy - testing/condprofile/condprof/android.py