Mercurial > hg > mercurial-source
changeset 33499: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 |
files | tests/run-tests.py tests/test-run-tests.t |
diffstat | 2 files changed, 71 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -274,6 +274,8 @@ help="run each test N times (default=1)", default=1) parser.add_option("-n", "--nodiff", action="store_true", help="skip showing test changes") + parser.add_option("--outputdir", type="string", + help="directory to write error logs to (default=test directory)") parser.add_option("-p", "--port", type="int", help="port on which servers should listen" " (default: $%s or %d)" % defaults['port']) @@ -564,7 +566,7 @@ # Status code reserved for skipped tests (used by hghave). SKIPPED_STATUS = 80 - def __init__(self, path, tmpdir, keeptmpdir=False, + def __init__(self, path, outputdir, tmpdir, keeptmpdir=False, debug=False, timeout=defaults['timeout'], startport=defaults['port'], extraconfigopts=None, @@ -605,8 +607,9 @@ self.bname = os.path.basename(path) self.name = _strpath(self.bname) self._testdir = os.path.dirname(path) + self._outputdir = outputdir self._tmpname = os.path.basename(path) - self.errpath = os.path.join(self._testdir, b'%s.err' % self.bname) + self.errpath = os.path.join(self._outputdir, b'%s.err' % self.bname) self._threadtmp = tmpdir self._keeptmpdir = keeptmpdir @@ -2133,6 +2136,7 @@ self.options = None self._hgroot = None self._testdir = None + self._outputdir = None self._hgtmp = None self._installdir = None self._bindir = None @@ -2212,6 +2216,10 @@ self._testdir = osenvironb[b'TESTDIR'] = getattr( os, 'getcwdb', os.getcwd)() + if self.options.outputdir: + self._outputdir = canonpath(_bytespath(self.options.outputdir)) + else: + self._outputdir = self._testdir if 'PYTHONHASHSEED' not in os.environ: # use a random python hash seed all the time @@ -2336,6 +2344,7 @@ vlog("# Using HGTMP", self._hgtmp) vlog("# Using PATH", os.environ["PATH"]) vlog("# Using", IMPL_PATH, osenvironb[IMPL_PATH]) + vlog("# Writing to directory", self._outputdir) try: return self._runtests(testdescs) or 0 @@ -2491,7 +2500,7 @@ # extra keyword parameters. 'case' is used by .t tests kwds = dict((k, testdesc[k]) for k in ['case'] if k in testdesc) - t = testcls(refpath, tmpdir, + t = testcls(refpath, self._outputdir, tmpdir, keeptmpdir=self.options.keep_tmpdir, debug=self.options.debug, timeout=self.options.timeout,
--- a/tests/test-run-tests.t +++ b/tests/test-run-tests.t @@ -166,6 +166,42 @@ python hash seed: * (glob) [1] +test --outputdir + $ mkdir output + $ rt --outputdir output + + --- $TESTTMP/test-failure.t + +++ $TESTTMP/output/test-failure.t.err + @@ -1,5 +1,5 @@ + $ echo babar + - rataxes + + babar + This is a noop statement so that + this test is still more bytes than success. + pad pad pad pad............................................................ + + ERROR: test-failure.t output changed + !. + --- $TESTTMP/test-failure-unicode.t + +++ $TESTTMP/output/test-failure-unicode.t.err + @@ -1,2 +1,2 @@ + $ echo babar\xce\xb1 (esc) + - l\xce\xb5\xce\xb5t (esc) + + babar\xce\xb1 (esc) + + ERROR: test-failure-unicode.t output changed + ! + Failed test-failure.t: output changed + Failed test-failure-unicode.t: output changed + # Ran 3 tests, 0 skipped, 0 warned, 2 failed. + python hash seed: * (glob) + [1] + $ ls -a output + . + .. + test-failure-unicode.t.err + test-failure.t.err + test --xunit support $ rt --xunit=xunit.xml @@ -306,6 +342,29 @@ python hash seed: * (glob) [1] +--retest works with --outputdir + $ rm -r output + $ mkdir output + $ mv test-failure.t.err output + $ rt --retest --outputdir output + + --- $TESTTMP/test-failure.t + +++ $TESTTMP/output/test-failure.t.err + @@ -1,5 +1,5 @@ + $ echo babar + - rataxes + + babar + This is a noop statement so that + this test is still more bytes than success. + pad pad pad pad............................................................ + + ERROR: test-failure.t output changed + ! + Failed test-failure.t: output changed + # Ran 2 tests, 1 skipped, 0 warned, 1 failed. + python hash seed: * (glob) + [1] + Selecting Tests To Run ======================