Mercurial > public > mercurial-scm > hg
comparison tests/run-tests.py @ 28143:c754996fd41f
run-tests: add --chg option to install and run tests using chg
Because the temporary installation directory is shared between hg and chg,
--chg is not allowed if --with-hg option is specified. Also, --chg option
does not work on FreeBSD because "make" command is hard-coded. These
limitations can be improved later.
Almost all tests will fail with chg right now.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 07 Feb 2016 18:08:59 +0900 |
parents | 85e28a46c7f1 |
children | 1b07331f5900 |
comparison
equal
deleted
inserted
replaced
28142:85e28a46c7f1 | 28143:c754996fd41f |
---|---|
247 help="external diff viewer") | 247 help="external diff viewer") |
248 parser.add_option("--with-hg", type="string", | 248 parser.add_option("--with-hg", type="string", |
249 metavar="HG", | 249 metavar="HG", |
250 help="test using specified hg script rather than a " | 250 help="test using specified hg script rather than a " |
251 "temporary installation") | 251 "temporary installation") |
252 parser.add_option("--chg", action="store_true", | |
253 help="install and use chg wrapper in place of hg") | |
252 parser.add_option("--with-chg", metavar="CHG", | 254 parser.add_option("--with-chg", metavar="CHG", |
253 help="use specified chg wrapper in place of hg") | 255 help="use specified chg wrapper in place of hg") |
254 parser.add_option("-3", "--py3k-warnings", action="store_true", | 256 parser.add_option("-3", "--py3k-warnings", action="store_true", |
255 help="enable Py3k warnings on Python 2.6+") | 257 help="enable Py3k warnings on Python 2.6+") |
256 parser.add_option('--extra-config-opt', action="append", | 258 parser.add_option('--extra-config-opt', action="append", |
292 if os.name != 'nt' and not os.access(hgbin, os.X_OK): | 294 if os.name != 'nt' and not os.access(hgbin, os.X_OK): |
293 parser.error('--local specified, but %r not found or not executable' | 295 parser.error('--local specified, but %r not found or not executable' |
294 % hgbin) | 296 % hgbin) |
295 options.with_hg = hgbin | 297 options.with_hg = hgbin |
296 | 298 |
299 if (options.chg or options.with_chg) and os.name == 'nt': | |
300 parser.error('chg does not work on %s' % os.name) | |
297 if options.with_chg: | 301 if options.with_chg: |
298 if os.name == 'nt': | 302 options.chg = False # no installation to temporary location |
299 parser.error('chg does not work on %s' % os.name) | |
300 options.with_chg = os.path.realpath( | 303 options.with_chg = os.path.realpath( |
301 os.path.expanduser(_bytespath(options.with_chg))) | 304 os.path.expanduser(_bytespath(options.with_chg))) |
302 if not (os.path.isfile(options.with_chg) and | 305 if not (os.path.isfile(options.with_chg) and |
303 os.access(options.with_chg, os.X_OK)): | 306 os.access(options.with_chg, os.X_OK)): |
304 parser.error('--with-chg must specify a chg executable') | 307 parser.error('--with-chg must specify a chg executable') |
308 if options.chg and options.with_hg: | |
309 # chg shares installation location with hg | |
310 parser.error('--chg does not work when --with-hg is specified ' | |
311 '(use --with-chg instead)') | |
305 | 312 |
306 options.anycoverage = options.cover or options.annotate or options.htmlcov | 313 options.anycoverage = options.cover or options.annotate or options.htmlcov |
307 if options.anycoverage: | 314 if options.anycoverage: |
308 try: | 315 try: |
309 import coverage | 316 import coverage |
1947 self._tmpbindir = self._bindir | 1954 self._tmpbindir = self._bindir |
1948 self._pythondir = os.path.join(self._installdir, b"lib", b"python") | 1955 self._pythondir = os.path.join(self._installdir, b"lib", b"python") |
1949 | 1956 |
1950 # set up crafted chg environment, then replace "hg" command by "chg" | 1957 # set up crafted chg environment, then replace "hg" command by "chg" |
1951 chgbindir = self._bindir | 1958 chgbindir = self._bindir |
1952 if self.options.with_chg: | 1959 if self.options.chg or self.options.with_chg: |
1953 self._chgsockdir = d = os.path.join(self._hgtmp, b'chgsock') | 1960 self._chgsockdir = d = os.path.join(self._hgtmp, b'chgsock') |
1954 os.mkdir(d) | 1961 os.mkdir(d) |
1955 osenvironb[b'CHGSOCKNAME'] = os.path.join(d, b"server") | 1962 osenvironb[b'CHGSOCKNAME'] = os.path.join(d, b"server") |
1956 osenvironb[b'CHGHG'] = os.path.join(self._bindir, self._hgcommand) | 1963 osenvironb[b'CHGHG'] = os.path.join(self._bindir, self._hgcommand) |
1964 if self.options.chg: | |
1965 self._hgcommand = b'chg' | |
1966 elif self.options.with_chg: | |
1957 chgbindir = os.path.dirname(os.path.realpath(self.options.with_chg)) | 1967 chgbindir = os.path.dirname(os.path.realpath(self.options.with_chg)) |
1958 self._hgcommand = os.path.basename(self.options.with_chg) | 1968 self._hgcommand = os.path.basename(self.options.with_chg) |
1959 | 1969 |
1960 osenvironb[b"BINDIR"] = self._bindir | 1970 osenvironb[b"BINDIR"] = self._bindir |
1961 osenvironb[b"PYTHON"] = PYTHON | 1971 osenvironb[b"PYTHON"] = PYTHON |
2041 if self._installdir: | 2051 if self._installdir: |
2042 self._installhg() | 2052 self._installhg() |
2043 self._checkhglib("Testing") | 2053 self._checkhglib("Testing") |
2044 else: | 2054 else: |
2045 self._usecorrectpython() | 2055 self._usecorrectpython() |
2056 if self.options.chg: | |
2057 assert self._installdir | |
2058 self._installchg() | |
2046 | 2059 |
2047 if self.options.restart: | 2060 if self.options.restart: |
2048 orig = list(tests) | 2061 orig = list(tests) |
2049 while tests: | 2062 while tests: |
2050 if os.path.exists(tests[0] + ".err"): | 2063 if os.path.exists(tests[0] + ".err"): |
2342 finally: | 2355 finally: |
2343 pipe.close() | 2356 pipe.close() |
2344 | 2357 |
2345 return self._hgpath | 2358 return self._hgpath |
2346 | 2359 |
2360 def _installchg(self): | |
2361 """Install chg into the test environment""" | |
2362 vlog('# Performing temporary installation of CHG') | |
2363 assert os.path.dirname(self._bindir) == self._installdir | |
2364 assert self._hgroot, 'must be called after _installhg()' | |
2365 cmd = (b'"%(make)s" clean install PREFIX="%(prefix)s"' | |
2366 % {b'make': 'make', # TODO: switch by option or environment? | |
2367 b'prefix': self._installdir}) | |
2368 cwd = os.path.join(self._hgroot, b'contrib', b'chg') | |
2369 vlog("# Running", cmd) | |
2370 proc = subprocess.Popen(cmd, shell=True, cwd=cwd, | |
2371 stdin=subprocess.PIPE, stdout=subprocess.PIPE, | |
2372 stderr=subprocess.STDOUT) | |
2373 out, _err = proc.communicate() | |
2374 if proc.returncode != 0: | |
2375 if PYTHON3: | |
2376 sys.stdout.buffer.write(out) | |
2377 else: | |
2378 sys.stdout.write(out) | |
2379 sys.exit(1) | |
2380 | |
2347 def _killchgdaemons(self): | 2381 def _killchgdaemons(self): |
2348 """Kill all background chg command servers spawned by tests""" | 2382 """Kill all background chg command servers spawned by tests""" |
2349 for f in os.listdir(self._chgsockdir): | 2383 for f in os.listdir(self._chgsockdir): |
2350 if not f.endswith(b'.pid'): | 2384 if not f.endswith(b'.pid'): |
2351 continue | 2385 continue |