Bug 1397855 - Enable py2 and py3 linter on testing/xpcshell. r=ahal

MozReview-Commit-ID: CsfIcI1ma7J

--HG--
extra : rebase_source : 53658c33432927f72ddce0999f18c2b7df261f6d
This commit is contained in:
Steve Armand 2017-09-07 21:15:35 -04:00
Родитель c3c1749786
Коммит 5934392346
6 изменённых файлов: 25 добавлений и 18 удалений

Просмотреть файл

@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # 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/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import unicode_literals from __future__ import absolute_import, unicode_literals
import os import os
import sys import sys

Просмотреть файл

@ -4,6 +4,8 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # 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/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function
import logging import logging
import posixpath import posixpath
import sys, os import sys, os
@ -168,7 +170,7 @@ class RemoteXPCShellTestThread(xpcshell.XPCShellTestThread):
# The minidumps directory is automatically created when Fennec # The minidumps directory is automatically created when Fennec
# (first) starts, so its lack of presence is a hint that # (first) starts, so its lack of presence is a hint that
# something went wrong. # something went wrong.
print "Automation Error: No crash directory (%s) found on remote device" % self.remoteMinidumpDir print("Automation Error: No crash directory (%s) found on remote device" % self.remoteMinidumpDir)
# Whilst no crash was found, the run should still display as a failure # Whilst no crash was found, the run should still display as a failure
return True return True
with mozfile.TemporaryDirectory() as dumpDir: with mozfile.TemporaryDirectory() as dumpDir:
@ -275,7 +277,7 @@ class XPCShellRemote(xpcshell.XPCShellTests, object):
elif os.path.isdir(os.path.join(here, 'tests')): elif os.path.isdir(os.path.join(here, 'tests')):
self.xpcDir = os.path.join(here, 'tests') self.xpcDir = os.path.join(here, 'tests')
else: else:
print >> sys.stderr, "Couldn't find local xpcshell test directory" print("Couldn't find local xpcshell test directory", file=sys.stderr)
sys.exit(1) sys.exit(1)
if options['localAPK']: if options['localAPK']:
@ -375,7 +377,7 @@ class XPCShellRemote(xpcshell.XPCShellTests, object):
if packageName: if packageName:
self.appRoot = self.device.getAppRoot(packageName.strip()) self.appRoot = self.device.getAppRoot(packageName.strip())
except Exception as detail: except Exception as detail:
print "unable to determine app root: " + str(detail) print("unable to determine app root: " + str(detail))
pass pass
return None return None
@ -417,11 +419,11 @@ class XPCShellRemote(xpcshell.XPCShellTests, object):
for fname in binaries: for fname in binaries:
local = os.path.join(self.localBin, fname) local = os.path.join(self.localBin, fname)
if os.path.isfile(local): if os.path.isfile(local):
print >> sys.stderr, "Pushing %s.." % fname print("Pushing %s.." % fname, file=sys.stderr)
remoteFile = remoteJoin(self.remoteBinDir, fname) remoteFile = remoteJoin(self.remoteBinDir, fname)
self.device.pushFile(local, remoteFile) self.device.pushFile(local, remoteFile)
else: else:
print >> sys.stderr, "*** Expected binary %s not found in %s!" % (fname, self.localBin) print("*** Expected binary %s not found in %s!" % (fname, self.localBin), file=sys.stderr)
local = os.path.join(self.localBin, "components/httpd.js") local = os.path.join(self.localBin, "components/httpd.js")
remoteFile = remoteJoin(self.remoteComponentsDir, "httpd.js") remoteFile = remoteJoin(self.remoteComponentsDir, "httpd.js")
@ -448,7 +450,7 @@ class XPCShellRemote(xpcshell.XPCShellTests, object):
dir = tempfile.mkdtemp() dir = tempfile.mkdtemp()
for info in self.localAPKContents.infolist(): for info in self.localAPKContents.infolist():
if info.filename.endswith(".so"): if info.filename.endswith(".so"):
print >> sys.stderr, "Pushing %s.." % info.filename print("Pushing %s.." % info.filename, file=sys.stderr)
remoteFile = remoteJoin(self.remoteBinDir, os.path.basename(info.filename)) remoteFile = remoteJoin(self.remoteBinDir, os.path.basename(info.filename))
self.localAPKContents.extract(info, dir) self.localAPKContents.extract(info, dir)
localFile = os.path.join(dir, info.filename) localFile = os.path.join(dir, info.filename)
@ -467,9 +469,9 @@ class XPCShellRemote(xpcshell.XPCShellTests, object):
for file in os.listdir(self.localLib): for file in os.listdir(self.localLib):
if (file.endswith(".so")): if (file.endswith(".so")):
print >> sys.stderr, "Pushing %s.." % file print("Pushing %s.." % file, file=sys.stderr)
if 'libxul' in file: if 'libxul' in file:
print >> sys.stderr, "This is a big file, it could take a while." print("This is a big file, it could take a while.", file=sys.stderr)
localFile = os.path.join(self.localLib, file) localFile = os.path.join(self.localLib, file)
remoteFile = remoteJoin(self.remoteBinDir, file) remoteFile = remoteJoin(self.remoteBinDir, file)
self.device.pushFile(localFile, remoteFile) self.device.pushFile(localFile, remoteFile)
@ -481,7 +483,7 @@ class XPCShellRemote(xpcshell.XPCShellTests, object):
for root, dirs, files in os.walk(localArmLib): for root, dirs, files in os.walk(localArmLib):
for file in files: for file in files:
if (file.endswith(".so")): if (file.endswith(".so")):
print >> sys.stderr, "Pushing %s.." % file print("Pushing %s.." % file, file=sys.stderr)
localFile = os.path.join(root, file) localFile = os.path.join(root, file)
remoteFile = remoteJoin(self.remoteBinDir, file) remoteFile = remoteJoin(self.remoteBinDir, file)
self.device.pushFile(localFile, remoteFile) self.device.pushFile(localFile, remoteFile)
@ -494,7 +496,7 @@ class XPCShellRemote(xpcshell.XPCShellTests, object):
self.device.pushDir(self.testingModulesDir, self.remoteModulesDir) self.device.pushDir(self.testingModulesDir, self.remoteModulesDir)
def setupTestDir(self): def setupTestDir(self):
print 'pushing %s' % self.xpcDir print('pushing %s' % self.xpcDir)
try: try:
# The tests directory can be quite large: 5000 files and growing! # The tests directory can be quite large: 5000 files and growing!
# Sometimes - like on a low-end aws instance running an emulator - the push # Sometimes - like on a low-end aws instance running an emulator - the push
@ -562,7 +564,7 @@ class PathMapping:
def main(): def main():
if sys.version_info < (2,7): if sys.version_info < (2,7):
print >>sys.stderr, "Error: You must use python version 2.7 or newer but less than 3.0" print("Error: You must use python version 2.7 or newer but less than 3.0", file=sys.stderr)
sys.exit(1) sys.exit(1)
parser = parser_remote() parser = parser_remote()
@ -572,10 +574,10 @@ def main():
if (file.endswith(".apk") and file.startswith("fennec")): if (file.endswith(".apk") and file.startswith("fennec")):
options.localAPK = os.path.join(options.objdir, "dist") options.localAPK = os.path.join(options.objdir, "dist")
options.localAPK = os.path.join(options.localAPK, file) options.localAPK = os.path.join(options.localAPK, file)
print >>sys.stderr, "using APK: " + options.localAPK print("using APK: " + options.localAPK, file=sys.stderr)
break break
else: else:
print >>sys.stderr, "Error: please specify an APK" print("Error: please specify an APK", file=sys.stderr)
sys.exit(1) sys.exit(1)
options = verifyRemoteOptions(parser, options) options = verifyRemoteOptions(parser, options)
@ -592,7 +594,7 @@ def main():
dm = mozdevice.DroidADB(**dm_args) dm = mozdevice.DroidADB(**dm_args)
if options['interactive'] and not options['testPath']: if options['interactive'] and not options['testPath']:
print >>sys.stderr, "Error: You must specify a test filename in interactive mode!" print("Error: You must specify a test filename in interactive mode!", file=sys.stderr)
sys.exit(1) sys.exit(1)
if options['xpcshell'] is None: if options['xpcshell'] is None:

Просмотреть файл

@ -4,6 +4,8 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # 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/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function
import copy import copy
import importlib import importlib
import json import json
@ -1068,7 +1070,7 @@ class XPCShellTests(object):
searchObj = re.search( r'HTTP2 server listening on port (.*)', msg, 0) searchObj = re.search( r'HTTP2 server listening on port (.*)', msg, 0)
if searchObj: if searchObj:
self.env["MOZHTTP2_PORT"] = searchObj.group(1) self.env["MOZHTTP2_PORT"] = searchObj.group(1)
except OSError, e: except OSError as e:
# This occurs if the subprocess couldn't be started # This occurs if the subprocess couldn't be started
self.log.error('Could not run %s server: %s' % (name, str(e))) self.log.error('Could not run %s server: %s' % (name, str(e)))
raise raise

Просмотреть файл

@ -4,6 +4,8 @@
# http://creativecommons.org/publicdomain/zero/1.0/ # http://creativecommons.org/publicdomain/zero/1.0/
# #
from __future__ import absolute_import
import mozinfo import mozinfo
import mozunit import mozunit
import os import os
@ -1084,7 +1086,7 @@ add_test({
try: try:
# The actual return value is never checked because we raise. # The actual return value is never checked because we raise.
self.assertTestResult(True) self.assertTestResult(True)
except Exception, ex: except Exception as ex:
raised = True raised = True
self.assertEquals(ex.message[0:9], "head file") self.assertEquals(ex.message[0:9], "head file")

Просмотреть файл

@ -1,3 +1,5 @@
from __future__ import absolute_import
import argparse import argparse
from mozlog import commandline from mozlog import commandline

Просмотреть файл

@ -50,7 +50,6 @@ py2:
- testing/tools - testing/tools
- testing/tps - testing/tps
- testing/web-platform - testing/web-platform
- testing/xpcshell
- third_party - third_party
- toolkit - toolkit
- tools/docs - tools/docs