Mercurial > hg
comparison tests/run-tests.py @ 32716:2146f01a2577
run-tests: allow specifying an output dir to write .errs to
I'm trying to use run-tests.py on a read-only file system. This series allows
that to happen.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Wed, 07 Jun 2017 20:30:08 -0700 |
parents | a4d0e816a672 |
children | e5680cb1414f |
comparison
equal
deleted
inserted
replaced
32715:a4d0e816a672 | 32716:2146f01a2577 |
---|---|
272 help="loop tests repeatedly") | 272 help="loop tests repeatedly") |
273 parser.add_option("--runs-per-test", type="int", dest="runs_per_test", | 273 parser.add_option("--runs-per-test", type="int", dest="runs_per_test", |
274 help="run each test N times (default=1)", default=1) | 274 help="run each test N times (default=1)", default=1) |
275 parser.add_option("-n", "--nodiff", action="store_true", | 275 parser.add_option("-n", "--nodiff", action="store_true", |
276 help="skip showing test changes") | 276 help="skip showing test changes") |
277 parser.add_option("--outputdir", type="string", | |
278 help="directory to write error logs to (default=test directory)") | |
277 parser.add_option("-p", "--port", type="int", | 279 parser.add_option("-p", "--port", type="int", |
278 help="port on which servers should listen" | 280 help="port on which servers should listen" |
279 " (default: $%s or %d)" % defaults['port']) | 281 " (default: $%s or %d)" % defaults['port']) |
280 parser.add_option("--compiler", type="string", | 282 parser.add_option("--compiler", type="string", |
281 help="compiler to build with") | 283 help="compiler to build with") |
562 """ | 564 """ |
563 | 565 |
564 # Status code reserved for skipped tests (used by hghave). | 566 # Status code reserved for skipped tests (used by hghave). |
565 SKIPPED_STATUS = 80 | 567 SKIPPED_STATUS = 80 |
566 | 568 |
567 def __init__(self, path, tmpdir, keeptmpdir=False, | 569 def __init__(self, path, outputdir, tmpdir, keeptmpdir=False, |
568 debug=False, | 570 debug=False, |
569 timeout=defaults['timeout'], | 571 timeout=defaults['timeout'], |
570 startport=defaults['port'], extraconfigopts=None, | 572 startport=defaults['port'], extraconfigopts=None, |
571 py3kwarnings=False, shell=None, hgcommand=None, | 573 py3kwarnings=False, shell=None, hgcommand=None, |
572 slowtimeout=defaults['slowtimeout'], usechg=False, | 574 slowtimeout=defaults['slowtimeout'], usechg=False, |
603 """ | 605 """ |
604 self.path = path | 606 self.path = path |
605 self.bname = os.path.basename(path) | 607 self.bname = os.path.basename(path) |
606 self.name = _strpath(self.bname) | 608 self.name = _strpath(self.bname) |
607 self._testdir = os.path.dirname(path) | 609 self._testdir = os.path.dirname(path) |
610 self._outputdir = outputdir | |
608 self._tmpname = os.path.basename(path) | 611 self._tmpname = os.path.basename(path) |
609 self.errpath = os.path.join(self._testdir, b'%s.err' % self.bname) | 612 self.errpath = os.path.join(self._outputdir, b'%s.err' % self.bname) |
610 | 613 |
611 self._threadtmp = tmpdir | 614 self._threadtmp = tmpdir |
612 self._keeptmpdir = keeptmpdir | 615 self._keeptmpdir = keeptmpdir |
613 self._debug = debug | 616 self._debug = debug |
614 self._timeout = timeout | 617 self._timeout = timeout |
2131 | 2134 |
2132 def __init__(self): | 2135 def __init__(self): |
2133 self.options = None | 2136 self.options = None |
2134 self._hgroot = None | 2137 self._hgroot = None |
2135 self._testdir = None | 2138 self._testdir = None |
2139 self._outputdir = None | |
2136 self._hgtmp = None | 2140 self._hgtmp = None |
2137 self._installdir = None | 2141 self._installdir = None |
2138 self._bindir = None | 2142 self._bindir = None |
2139 self._tmpbinddir = None | 2143 self._tmpbinddir = None |
2140 self._pythondir = None | 2144 self._pythondir = None |
2210 return perf[f] | 2214 return perf[f] |
2211 testdescs.sort(key=sortkey) | 2215 testdescs.sort(key=sortkey) |
2212 | 2216 |
2213 self._testdir = osenvironb[b'TESTDIR'] = getattr( | 2217 self._testdir = osenvironb[b'TESTDIR'] = getattr( |
2214 os, 'getcwdb', os.getcwd)() | 2218 os, 'getcwdb', os.getcwd)() |
2219 if self.options.outputdir: | |
2220 self._outputdir = canonpath(_bytespath(self.options.outputdir)) | |
2221 else: | |
2222 self._outputdir = self._testdir | |
2215 | 2223 |
2216 if 'PYTHONHASHSEED' not in os.environ: | 2224 if 'PYTHONHASHSEED' not in os.environ: |
2217 # use a random python hash seed all the time | 2225 # use a random python hash seed all the time |
2218 # we do the randomness ourself to know what seed is used | 2226 # we do the randomness ourself to know what seed is used |
2219 os.environ['PYTHONHASHSEED'] = str(random.getrandbits(32)) | 2227 os.environ['PYTHONHASHSEED'] = str(random.getrandbits(32)) |
2334 vlog("# Using TESTDIR", self._testdir) | 2342 vlog("# Using TESTDIR", self._testdir) |
2335 vlog("# Using RUNTESTDIR", osenvironb[b'RUNTESTDIR']) | 2343 vlog("# Using RUNTESTDIR", osenvironb[b'RUNTESTDIR']) |
2336 vlog("# Using HGTMP", self._hgtmp) | 2344 vlog("# Using HGTMP", self._hgtmp) |
2337 vlog("# Using PATH", os.environ["PATH"]) | 2345 vlog("# Using PATH", os.environ["PATH"]) |
2338 vlog("# Using", IMPL_PATH, osenvironb[IMPL_PATH]) | 2346 vlog("# Using", IMPL_PATH, osenvironb[IMPL_PATH]) |
2347 vlog("# Writing to directory", self._outputdir) | |
2339 | 2348 |
2340 try: | 2349 try: |
2341 return self._runtests(testdescs) or 0 | 2350 return self._runtests(testdescs) or 0 |
2342 finally: | 2351 finally: |
2343 time.sleep(.1) | 2352 time.sleep(.1) |
2489 tmpdir = os.path.join(self._hgtmp, b'child%d' % count) | 2498 tmpdir = os.path.join(self._hgtmp, b'child%d' % count) |
2490 | 2499 |
2491 # extra keyword parameters. 'case' is used by .t tests | 2500 # extra keyword parameters. 'case' is used by .t tests |
2492 kwds = dict((k, testdesc[k]) for k in ['case'] if k in testdesc) | 2501 kwds = dict((k, testdesc[k]) for k in ['case'] if k in testdesc) |
2493 | 2502 |
2494 t = testcls(refpath, tmpdir, | 2503 t = testcls(refpath, self._outputdir, tmpdir, |
2495 keeptmpdir=self.options.keep_tmpdir, | 2504 keeptmpdir=self.options.keep_tmpdir, |
2496 debug=self.options.debug, | 2505 debug=self.options.debug, |
2497 timeout=self.options.timeout, | 2506 timeout=self.options.timeout, |
2498 startport=self._getport(count), | 2507 startport=self._getport(count), |
2499 extraconfigopts=self.options.extra_config_opt, | 2508 extraconfigopts=self.options.extra_config_opt, |