##// END OF EJS Templates
python3: update killdaemons and run-tests print and exception syntax...
Augie Fackler -
r25031:0adc22a0 default
parent child Browse files
Show More
@@ -64,7 +64,7 b' else:'
64 64 os.kill(pid, 0)
65 65 logfn('# Daemon process %d is stuck - really killing it' % pid)
66 66 os.kill(pid, signal.SIGKILL)
67 except OSError, err:
67 except OSError as err:
68 68 if err.errno != errno.ESRCH:
69 69 raise
70 70
@@ -41,6 +41,8 b''
41 41 # completes fairly quickly, includes both shell and Python scripts, and
42 42 # includes some scripts that run daemon processes.)
43 43
44 from __future__ import print_function
45
44 46 from distutils import version
45 47 import difflib
46 48 import errno
@@ -57,7 +59,10 b' import random'
57 59 import re
58 60 import threading
59 61 import killdaemons as killmod
60 import Queue as queue
62 try:
63 import Queue as queue
64 except ImportError:
65 import queue
61 66 from xml.dom import minidom
62 67 import unittest
63 68
@@ -86,7 +91,7 b' def checkportisavailable(port):'
86 91 s.bind(('localhost', port))
87 92 s.close()
88 93 return True
89 except socket.error, exc:
94 except socket.error as exc:
90 95 if not exc.errno == errno.EADDRINUSE:
91 96 raise
92 97 return False
@@ -135,11 +140,11 b' def parselistfiles(files, listtype, warn'
135 140 try:
136 141 path = os.path.expanduser(os.path.expandvars(filename))
137 142 f = open(path, "rb")
138 except IOError, err:
143 except IOError as err:
139 144 if err.errno != errno.ENOENT:
140 145 raise
141 146 if warn:
142 print "warning: no such %s file: %s" % (listtype, filename)
147 print("warning: no such %s file: %s" % (listtype, filename))
143 148 continue
144 149
145 150 for line in f.readlines():
@@ -358,10 +363,10 b' def log(*msg):'
358 363 """
359 364 iolock.acquire()
360 365 if verbose:
361 print verbose,
366 print(verbose, end=' ')
362 367 for m in msg:
363 print m,
364 print
368 print(m, end=' ')
369 print()
365 370 sys.stdout.flush()
366 371 iolock.release()
367 372
@@ -475,7 +480,7 b' class Test(unittest.TestCase):'
475 480
476 481 try:
477 482 os.mkdir(self._threadtmp)
478 except OSError, e:
483 except OSError as e:
479 484 if e.errno != errno.EEXIST:
480 485 raise
481 486
@@ -487,7 +492,7 b' class Test(unittest.TestCase):'
487 492 if os.path.exists(self.errpath):
488 493 try:
489 494 os.remove(self.errpath)
490 except OSError, e:
495 except OSError as e:
491 496 # We might have raced another test to clean up a .err
492 497 # file, so ignore ENOENT when removing a previous .err
493 498 # file.
@@ -517,20 +522,20 b' class Test(unittest.TestCase):'
517 522 except KeyboardInterrupt:
518 523 self._aborted = True
519 524 raise
520 except SkipTest, e:
525 except SkipTest as e:
521 526 result.addSkip(self, str(e))
522 527 # The base class will have already counted this as a
523 528 # test we "ran", but we want to exclude skipped tests
524 529 # from those we count towards those run.
525 530 result.testsRun -= 1
526 except IgnoreTest, e:
531 except IgnoreTest as e:
527 532 result.addIgnore(self, str(e))
528 533 # As with skips, ignores also should be excluded from
529 534 # the number of tests executed.
530 535 result.testsRun -= 1
531 except WarnTest, e:
536 except WarnTest as e:
532 537 result.addWarn(self, str(e))
533 except self.failureException, e:
538 except self.failureException as e:
534 539 # This differs from unittest in that we don't capture
535 540 # the stack trace. This is for historical reasons and
536 541 # this decision could be revisited in the future,
@@ -873,7 +878,7 b' class TTest(Test):'
873 878 if wifexited(ret):
874 879 ret = os.WEXITSTATUS(ret)
875 880 if ret == 2:
876 print stdout
881 print(stdout)
877 882 sys.exit(1)
878 883
879 884 return ret == 0
@@ -1621,7 +1626,7 b' class TestRunner(object):'
1621 1626
1622 1627 def run(self, args, parser=None):
1623 1628 """Run the test suite."""
1624 oldmask = os.umask(022)
1629 oldmask = os.umask(0o22)
1625 1630 try:
1626 1631 parser = parser or getparser()
1627 1632 options, args = parseargs(args, parser)
@@ -1643,7 +1648,7 b' class TestRunner(object):'
1643 1648 # run largest tests first, as they tend to take the longest
1644 1649 try:
1645 1650 val = -os.stat(f).st_size
1646 except OSError, e:
1651 except OSError as e:
1647 1652 if e.errno != errno.ENOENT:
1648 1653 raise
1649 1654 return -1e9 # file does not exist, tell early
@@ -1667,7 +1672,7 b' class TestRunner(object):'
1667 1672 # Meaning of tmpdir has changed since 1.3: we used to create
1668 1673 # HGTMP inside tmpdir; now HGTMP is tmpdir. So fail if
1669 1674 # tmpdir already exists.
1670 print "error: temp dir %r already exists" % tmpdir
1675 print("error: temp dir %r already exists" % tmpdir)
1671 1676 return 1
1672 1677
1673 1678 # Automatically removing tmpdir sounds convenient, but could
@@ -1783,7 +1788,7 b' class TestRunner(object):'
1783 1788 break
1784 1789 tests.pop(0)
1785 1790 if not tests:
1786 print "running all tests"
1791 print("running all tests")
1787 1792 tests = orig
1788 1793
1789 1794 tests = [self._gettest(t, i) for i, t in enumerate(tests)]
@@ -1815,7 +1820,7 b' class TestRunner(object):'
1815 1820 self._outputcoverage()
1816 1821 except KeyboardInterrupt:
1817 1822 failed = True
1818 print "\ninterrupted!"
1823 print("\ninterrupted!")
1819 1824
1820 1825 if failed:
1821 1826 return 1
@@ -1894,14 +1899,14 b' class TestRunner(object):'
1894 1899 if os.readlink(mypython) == sys.executable:
1895 1900 return
1896 1901 os.unlink(mypython)
1897 except OSError, err:
1902 except OSError as err:
1898 1903 if err.errno != errno.ENOENT:
1899 1904 raise
1900 1905 if self._findprogram(pyexename) != sys.executable:
1901 1906 try:
1902 1907 os.symlink(sys.executable, mypython)
1903 1908 self._createdfiles.append(mypython)
1904 except OSError, err:
1909 except OSError as err:
1905 1910 # child processes may race, which is harmless
1906 1911 if err.errno != errno.EEXIST:
1907 1912 raise
@@ -1914,7 +1919,7 b' class TestRunner(object):'
1914 1919 path.remove(exedir)
1915 1920 os.environ['PATH'] = os.pathsep.join([exedir] + path)
1916 1921 if not self._findprogram(pyexename):
1917 print "WARNING: Cannot find %s in search path" % pyexename
1922 print("WARNING: Cannot find %s in search path" % pyexename)
1918 1923
1919 1924 def _installhg(self):
1920 1925 """Install hg into the test environment.
@@ -1962,7 +1967,7 b' class TestRunner(object):'
1962 1967 def makedirs(p):
1963 1968 try:
1964 1969 os.makedirs(p)
1965 except OSError, e:
1970 except OSError as e:
1966 1971 if e.errno != errno.EEXIST:
1967 1972 raise
1968 1973 makedirs(self._pythondir)
@@ -2007,7 +2012,7 b' class TestRunner(object):'
2007 2012 f.write(data)
2008 2013 f.close()
2009 2014 else:
2010 print 'WARNING: cannot fix hg.bat reference to python.exe'
2015 print('WARNING: cannot fix hg.bat reference to python.exe')
2011 2016
2012 2017 if self.options.anycoverage:
2013 2018 custom = os.path.join(self._testdir, 'sitecustomize.py')
@@ -2020,7 +2025,7 b' class TestRunner(object):'
2020 2025 covdir = os.path.join(self._installdir, '..', 'coverage')
2021 2026 try:
2022 2027 os.mkdir(covdir)
2023 except OSError, e:
2028 except OSError as e:
2024 2029 if e.errno != errno.EEXIST:
2025 2030 raise
2026 2031
@@ -2100,7 +2105,7 b' class TestRunner(object):'
2100 2105 if found:
2101 2106 vlog("# Found prerequisite", p, "at", found)
2102 2107 else:
2103 print "WARNING: Did not find prerequisite tool: %s " % p
2108 print("WARNING: Did not find prerequisite tool: %s " % p)
2104 2109
2105 2110 if __name__ == '__main__':
2106 2111 runner = TestRunner()
General Comments 0
You need to be logged in to leave comments. Login now