Commit b6461aa9 authored by Andrew Halberstadt's avatar Andrew Halberstadt
Browse files

Bug 1567642 - [reftest] Fix flake8 under Python 3 lint issues r=gbrown

Depends on D45415

Differential Revision: https://phabricator.services.mozilla.com/D45416

--HG--
extra : moz-landing-system : lando
parent 1e231d1b
Loading
Loading
Loading
Loading
+22 −19
Original line number Diff line number Diff line
@@ -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 print_function

import os
import posixpath
import psutil
@@ -34,7 +36,7 @@ class RemoteReftestResolver(ReftestResolver):
        elif os.path.exists(os.path.abspath(path)):
            rv = os.path.abspath(path)
        else:
            print >> sys.stderr, "Could not find manifest %s" % script_abs_path
            print("Could not find manifest %s" % script_abs_path, file=sys.stderr)
            sys.exit(1)
        return os.path.normpath(rv)

@@ -99,7 +101,7 @@ class ReftestServer:
        self._process = self.automation.Process([xpcshell] + args, env=env)
        pid = self._process.pid
        if pid < 0:
            print "TEST-UNEXPECTED-FAIL | remotereftests.py | Error starting server."
            print("TEST-UNEXPECTED-FAIL | remotereftests.py | Error starting server.")
            return 2
        self.automation.log.info("INFO | remotereftests.py | Server pid: %d", pid)

@@ -148,7 +150,7 @@ class RemoteReftest(RefTest):
        verbose = False
        if options.log_tbpl_level == 'debug' or options.log_mach_level == 'debug':
            verbose = True
            print "set verbose!"
            print("set verbose!")
        self.device = ADBDevice(adb=options.adb_path or 'adb',
                                device=options.deviceSerial,
                                test_root=options.remoteTestRoot,
@@ -316,7 +318,7 @@ class RemoteReftest(RefTest):
            self.device.push(profileDir, options.remoteProfile)
            self.device.chmod(options.remoteProfile, recursive=True, root=True)
        except Exception:
            print "Automation Error: Failed to copy profiledir to device"
            print("Automation Error: Failed to copy profiledir to device")
            raise

        return profile
@@ -328,21 +330,21 @@ class RemoteReftest(RefTest):
                for l in logcat:
                    ul = l.decode('utf-8', errors='replace')
                    sl = ul.encode('iso8859-1', errors='replace')
                    print "%s\n" % sl
            print "Device info:"
                    print("%s\n" % sl)
            print("Device info:")
            devinfo = self.device.get_info()
            for category in devinfo:
                if type(devinfo[category]) is list:
                    print "  %s:" % category
                    print("  %s:" % category)
                    for item in devinfo[category]:
                        print "     %s" % item
                        print("     %s" % item)
                else:
                    print "  %s: %s" % (category, devinfo[category])
            print "Test root: %s" % self.device.test_root
                    print("  %s: %s" % (category, devinfo[category]))
            print("Test root: %s" % self.device.test_root)
        except ADBTimeoutError:
            raise
        except Exception as e:
            print "WARNING: Error getting device information: %s" % str(e)
            print("WARNING: Error getting device information: %s" % str(e))

    def environment(self, **kwargs):
        return self.automation.environment(**kwargs)
@@ -396,7 +398,8 @@ def run_test_harness(parser, options):
    parser.validate(options, reftest)

    if mozinfo.info['debug']:
        print "changing timeout for remote debug reftests from %s to 600 seconds" % options.timeout
        print("changing timeout for remote debug reftests from %s to 600 seconds"
              % options.timeout)
        options.timeout = 600

    # Hack in a symbolic link for jsreftest
@@ -425,7 +428,7 @@ def run_test_harness(parser, options):
        else:
            retVal = reftest.runTests(options.tests, options)
    except Exception:
        print "Automation Error: Exception caught while running tests"
        print("Automation Error: Exception caught while running tests")
        traceback.print_exc()
        retVal = 1

+16 −12
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
"""
Runs the reftest test harness.
"""
from __future__ import print_function

import copy
import json
@@ -39,14 +40,16 @@ import mozrunner
from manifestparser import TestManifest, filters as mpf
from mozrunner.utils import get_stack_fixer_function, test_environment
from mozscreenshot import printstatus, dump_screen
from six import reraise, string_types
from six.moves import range

try:
    from marionette_driver.addons import Addons
    from marionette_harness import Marionette
except ImportError, e:
except ImportError as e:  # noqa
    # Defer ImportError until attempt to use Marionette
    def reraise(*args, **kwargs):
        raise(e)
        raise(e)  # noqa
    Marionette = reraise

from output import OutputHandler, ReftestFormatter
@@ -108,12 +111,12 @@ class ReftestThread(threading.Thread):

    def run(self):
        with printLock:
            print "Starting thread with", self.cmdargs
            print("Starting thread with", self.cmdargs)
            sys.stdout.flush()
        process = subprocess.Popen(self.cmdargs, stdout=subprocess.PIPE)
        for chunk in self.chunkForMergedOutput(process.stdout):
            with printLock:
                print chunk,
                print(chunk,)
                sys.stdout.flush()
        self.retcode = process.wait()

@@ -405,7 +408,7 @@ class RefTest(object):
        for v in options.extraPrefs:
            thispref = v.split('=')
            if len(thispref) < 2:
                print "Error: syntax error in --setpref=" + v
                print("Error: syntax error in --setpref=" + v)
                sys.exit(1)
            prefs[thispref[0]] = thispref[1].strip()

@@ -448,7 +451,7 @@ class RefTest(object):
        for v in options.environment:
            ix = v.find("=")
            if ix <= 0:
                print "Error: syntax error in --setenv=" + v
                print("Error: syntax error in --setenv=" + v)
                return None
            browserEnv[v[:ix]] = v[ix + 1:]

@@ -497,7 +500,7 @@ class RefTest(object):

        def step2():
            stepOptions = copy.deepcopy(options)
            for i in xrange(VERIFY_REPEAT_SINGLE_BROWSER):
            for i in range(VERIFY_REPEAT_SINGLE_BROWSER):
                result = self.runTests(tests, stepOptions)
                if result != 0:
                    break
@@ -514,7 +517,7 @@ class RefTest(object):
        def step4():
            stepOptions = copy.deepcopy(options)
            stepOptions.environment.append("MOZ_CHAOSMODE=3")
            for i in xrange(VERIFY_REPEAT_SINGLE_BROWSER):
            for i in range(VERIFY_REPEAT_SINGLE_BROWSER):
                result = self.runTests(tests, stepOptions)
                if result != 0:
                    break
@@ -656,11 +659,12 @@ class RefTest(object):
                    threadMatches.group('total') if threadMatches else 0)
                summaryObj['total'] += amount

        print 'REFTEST INFO | Result summary:'
        print('REFTEST INFO | Result summary:')
        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))

@@ -843,7 +847,7 @@ class RefTest(object):

        if marionette_exception is not None:
            exc, value, tb = marionette_exception
            raise exc, value, tb
            raise reraise(exc, value, tb)

        self.log.info("Process mode: {}".format('e10s' if options.e10s else 'non-e10s'))
        return status
@@ -887,7 +891,7 @@ class RefTest(object):
        def run(**kwargs):
            if kwargs.get('tests'):
                self.lastTest = kwargs['tests'][-1]['identifier']
                if not isinstance(self.lastTest, basestring):
                if not isinstance(self.lastTest, string_types):
                    self.lastTest = ' '.join(self.lastTest)

            status = self.runApp(