##// END OF EJS Templates
run-tests: add --with-chg option to run tests using chg...
Yuya Nishihara -
r28142:85e28a46 default
parent child Browse files
Show More
@@ -249,6 +249,8 b' def getparser():'
249 249 metavar="HG",
250 250 help="test using specified hg script rather than a "
251 251 "temporary installation")
252 parser.add_option("--with-chg", metavar="CHG",
253 help="use specified chg wrapper in place of hg")
252 254 parser.add_option("-3", "--py3k-warnings", action="store_true",
253 255 help="enable Py3k warnings on Python 2.6+")
254 256 parser.add_option('--extra-config-opt', action="append",
@@ -292,6 +294,15 b' def parseargs(args, parser):'
292 294 % hgbin)
293 295 options.with_hg = hgbin
294 296
297 if options.with_chg:
298 if os.name == 'nt':
299 parser.error('chg does not work on %s' % os.name)
300 options.with_chg = os.path.realpath(
301 os.path.expanduser(_bytespath(options.with_chg)))
302 if not (os.path.isfile(options.with_chg) and
303 os.access(options.with_chg, os.X_OK)):
304 parser.error('--with-chg must specify a chg executable')
305
295 306 options.anycoverage = options.cover or options.annotate or options.htmlcov
296 307 if options.anycoverage:
297 308 try:
@@ -1811,6 +1822,7 b' class TestRunner(object):'
1811 1822 self._createdfiles = []
1812 1823 self._hgcommand = None
1813 1824 self._hgpath = None
1825 self._chgsockdir = None
1814 1826 self._portoffset = 0
1815 1827 self._ports = {}
1816 1828
@@ -1935,6 +1947,16 b' class TestRunner(object):'
1935 1947 self._tmpbindir = self._bindir
1936 1948 self._pythondir = os.path.join(self._installdir, b"lib", b"python")
1937 1949
1950 # set up crafted chg environment, then replace "hg" command by "chg"
1951 chgbindir = self._bindir
1952 if self.options.with_chg:
1953 self._chgsockdir = d = os.path.join(self._hgtmp, b'chgsock')
1954 os.mkdir(d)
1955 osenvironb[b'CHGSOCKNAME'] = os.path.join(d, b"server")
1956 osenvironb[b'CHGHG'] = os.path.join(self._bindir, self._hgcommand)
1957 chgbindir = os.path.dirname(os.path.realpath(self.options.with_chg))
1958 self._hgcommand = os.path.basename(self.options.with_chg)
1959
1938 1960 osenvironb[b"BINDIR"] = self._bindir
1939 1961 osenvironb[b"PYTHON"] = PYTHON
1940 1962
@@ -1951,6 +1973,8 b' class TestRunner(object):'
1951 1973 realfile = os.path.realpath(fileb)
1952 1974 realdir = os.path.abspath(os.path.dirname(realfile))
1953 1975 path.insert(2, realdir)
1976 if chgbindir != self._bindir:
1977 path.insert(1, chgbindir)
1954 1978 if self._testdir != runtestdir:
1955 1979 path = [self._testdir] + path
1956 1980 if self._tmpbindir != self._bindir:
@@ -2119,6 +2143,8 b' class TestRunner(object):'
2119 2143
2120 2144 def _cleanup(self):
2121 2145 """Clean up state from this test invocation."""
2146 if self._chgsockdir:
2147 self._killchgdaemons()
2122 2148
2123 2149 if self.options.keep_tmpdir:
2124 2150 return
@@ -2318,6 +2344,13 b' class TestRunner(object):'
2318 2344
2319 2345 return self._hgpath
2320 2346
2347 def _killchgdaemons(self):
2348 """Kill all background chg command servers spawned by tests"""
2349 for f in os.listdir(self._chgsockdir):
2350 if not f.endswith(b'.pid'):
2351 continue
2352 killdaemons(os.path.join(self._chgsockdir, f))
2353
2321 2354 def _outputcoverage(self):
2322 2355 """Produce code coverage output."""
2323 2356 from coverage import coverage
General Comments 0
You need to be logged in to leave comments. Login now