Bug 1559975 - convert testing/tps to python3 r=ahal
authorEdwin Gao <egao@mozilla.com>
Tue, 02 Jul 2019 18:04:40 +0000
changeset 480979 6822d5123b3c395d54acecbde8411726dc5de642
parent 480978 9ab904b7a8a6afa8e19be2b8637f1b5fb70a8a70
child 480980 69150f66631941dba8e44904e809f2b3f6d29deb
push id36230
push useraciure@mozilla.com
push dateWed, 03 Jul 2019 04:09:04 +0000
treeherdermozilla-central@42a9ef2a777f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs1559975
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1559975 - convert testing/tps to python3 r=ahal Differential Revision: https://phabricator.services.mozilla.com/D35328
testing/tps/create_venv.py
testing/tps/tps/cli.py
testing/tps/tps/firefoxrunner.py
testing/tps/tps/testrunner.py
tools/lint/py3.yml
--- a/testing/tps/create_venv.py
+++ b/testing/tps/create_venv.py
@@ -59,25 +59,25 @@ def download(url, target):
 
     return target
 
 
 def setup_virtualenv(target, python_bin=None):
     script_path = os.path.join(here, 'virtualenv-%s' % VERSION_VIRTUALENV,
                                'virtualenv.py')
 
-    print 'Downloading virtualenv %s' % VERSION_VIRTUALENV
+    print('Downloading virtualenv {}'.format(VERSION_VIRTUALENV))
     zip_path = download(URL_VIRTUALENV + VERSION_VIRTUALENV,
                         os.path.join(here, 'virtualenv.zip'))
 
     try:
         with zipfile.ZipFile(zip_path, 'r') as f:
             f.extractall(here)
 
-        print 'Creating new virtual environment'
+        print('Creating new virtual environment')
         cmd_args = [sys.executable, script_path, target]
 
         if python_bin:
             cmd_args.extend(['-p', python_bin])
 
         subprocess.check_call(cmd_args)
     finally:
         try:
@@ -182,19 +182,19 @@ def main():
                           '__EXTENSIONDIR__': extdir.replace('\\', '/'),
                           '__FX_ACCOUNT_USERNAME__': options.username,
                           '__FX_ACCOUNT_PASSWORD__': options.password,
                           '__SYNC_ACCOUNT_USERNAME__': options.sync_username,
                           '__SYNC_ACCOUNT_PASSWORD__': options.sync_password,
                           '__SYNC_ACCOUNT_PASSPHRASE__': options.sync_passphrase})
 
         if not (options.username and options.password):
-            print '\nFirefox Account credentials not specified.'
+            print('\nFirefox Account credentials not specified.')
         if not (options.sync_username and options.sync_password and options.passphrase):
-            print '\nFirefox Sync account credentials not specified.'
+            print('\nFirefox Sync account credentials not specified.')
 
     # Print the user instructions
-    print usage_message.format(TARGET=target,
-                               BIN_NAME=bin_name)
+    print(usage_message.format(TARGET=target,
+                               BIN_NAME=bin_name))
 
 
 if __name__ == "__main__":
     main()
--- a/testing/tps/tps/cli.py
+++ b/testing/tps/tps/cli.py
@@ -88,17 +88,17 @@ def main():
     f = open(configfile, 'r')
     configcontent = f.read()
     f.close()
     config = json.loads(configcontent)
     testfile = os.path.join(config.get('testdir', ''), options.testfile)
 
     rlock = RLock()
 
-    print 'using result file', options.resultfile
+    print('using result file', options.resultfile)
 
     extensionDir = config.get('extensiondir')
     if not extensionDir or extensionDir == '__EXTENSIONDIR__':
         extensionDir = os.path.join(os.getcwd(), '..', '..',
                                     'services', 'sync', 'tps', 'extensions')
     else:
         if sys.platform == 'win32':
             # replace msys-style paths with proper Windows paths
--- a/testing/tps/tps/firefoxrunner.py
+++ b/testing/tps/tps/firefoxrunner.py
@@ -47,21 +47,21 @@ class TPSFirefoxRunner(object):
         pathToBuild = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                    buildName)
 
         # delete the build if it already exists
         if os.access(pathToBuild, os.F_OK):
             os.remove(pathToBuild)
 
         # download the build
-        print 'downloading build'
+        print('downloading build')
         self.download_url(self.url, pathToBuild)
 
         # install the build
-        print 'installing %s' % pathToBuild
+        print('installing {}'.format(pathToBuild))
         mozfile.remove(self.installdir, True)
         binary = mozinstall.install(src=pathToBuild, dest=self.installdir)
 
         # remove the downloaded archive
         os.remove(pathToBuild)
 
         return binary
 
--- a/testing/tps/tps/testrunner.py
+++ b/testing/tps/tps/testrunner.py
@@ -147,17 +147,17 @@ class TPSTestRunner(object):
 
     def log(self, msg, printToConsole=False):
         """Appends a string to the logfile"""
 
         f = open(self.logfile, 'a')
         f.write(msg)
         f.close()
         if printToConsole:
-            print msg
+            print(msg)
 
     def writeToResultFile(self, postdata, body=None,
                           sendTo=['crossweave@mozilla.com']):
         """Writes results to test file"""
 
         results = {'results': []}
 
         if os.access(self.resultfile, os.F_OK):
@@ -261,17 +261,17 @@ class TPSTestRunner(object):
         failed = False
         for phase in phaselist:
             phase.run()
             if phase.status != 'PASS':
                 failed = True
                 break
 
         for profilename in profiles:
-            print "### Cleanup Profile ", profilename
+            print("### Cleanup Profile ", profilename)
             cleanup_phase = TPSTestPhase(
                 'cleanup-' + profilename,
                 profiles[profilename], testname,
                 testpath,
                 self.logfile,
                 self.env,
                 self.firefoxRunner,
                 self.log)
@@ -335,17 +335,17 @@ class TPSTestRunner(object):
                        'name': testname,
                        'message': result[1],
                        'state': result[0],
                        'logdata': logdata
                        })
 
         self.log(logstr, True)
         for phase in phaselist:
-            print "\t%s: %s" % (phase.phase, phase.status)
+            print("\t{}: {}".format(phase.phase, phase.status))
 
         return resultdata
 
     def update_preferences(self):
         self.preferences = self.default_preferences.copy()
 
         if self.mobile:
             self.preferences.update({'services.sync.client.type': 'mobile'})
@@ -416,19 +416,19 @@ class TPSTestRunner(object):
                 except Exception:
                     traceback.print_exc()
 
         # release our lock
         if self.rlock:
             self.rlock.release()
 
         # dump out a summary of test results
-        print 'Test Summary\n'
+        print('Test Summary\n')
         for test in self.postdata.get('tests', {}):
-            print '%s | %s | %s' % (test['state'], test['name'], test['message'])
+            print('{} | {} | {}'.format(test['state'], test['name'], test['message']))
 
     def run_test_group(self):
         self.results = []
 
         # reset number of passed/failed tests
         self.numpassed = 0
         self.numfailed = 0
 
@@ -441,17 +441,17 @@ class TPSTestRunner(object):
             f = open(self.testfile)
             jsondata = f.read()
             f.close()
             testfiles = json.loads(jsondata)
             testlist = []
             for (filename, meta) in testfiles['tests'].items():
                 skip_reason = meta.get("disabled")
                 if skip_reason:
-                    print 'Skipping test %s - %s' % (filename, skip_reason)
+                    print('Skipping test {} - {}'.format(filename, skip_reason))
                 else:
                     testlist.append(filename)
         except ValueError:
             testlist = [os.path.basename(self.testfile)]
         testdir = os.path.dirname(self.testfile)
 
         self.mozhttpd = MozHttpd(port=4567, docroot=testdir)
         self.mozhttpd.start()
@@ -469,18 +469,18 @@ class TPSTestRunner(object):
                                  'name': result['name'],
                                  'message': result['message'],
                                  'logdata': result['logdata']})
             if result['state'] == 'TEST-PASS':
                 self.numpassed += 1
             else:
                 self.numfailed += 1
                 if self.stop_on_error:
-                    print '\nTest failed with --stop-on-error specified; ' \
-                          'not running any more tests.\n'
+                    print('\nTest failed with --stop-on-error specified; '
+                          'not running any more tests.\n')
                     break
 
         self.mozhttpd.stop()
 
         # generate the postdata we'll use to post the results to the db
         self.postdata = {'tests': self.results,
                          'os': '%s %sbit' % (mozinfo.version, mozinfo.bits),
                          'testtype': 'crossweave',
--- a/tools/lint/py3.yml
+++ b/tools/lint/py3.yml
@@ -18,17 +18,16 @@ py3:
         - layout/tools/reftest
         - media
         - modules/freetype2
         - security/manager/ssl
         - servo
         - testing/mochitest
         - testing/mozharness
         - testing/tools/iceserver
-        - testing/tps
         - testing/web-platform
         - toolkit
         - tools/jprof
         - tools/profiler
         - tools/rb
         - xpcom/idl-parser
     extensions: ['py']
     support-files: