##// END OF EJS Templates
run-tests: allow specifying an output dir to write .errs to...
Siddharth Agarwal -
r32716:2146f01a default
parent child Browse files
Show More
@@ -274,6 +274,8 b' def getparser():'
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'])
@@ -564,7 +566,7 b' class Test(unittest.TestCase):'
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,
@@ -605,8 +607,9 b' class Test(unittest.TestCase):'
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
@@ -2133,6 +2136,7 b' class TestRunner(object):'
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
@@ -2212,6 +2216,10 b' class TestRunner(object):'
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
@@ -2336,6 +2344,7 b' class TestRunner(object):'
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
@@ -2491,7 +2500,7 b' class TestRunner(object):'
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,
@@ -166,6 +166,42 b' basic failing test'
166 python hash seed: * (glob)
166 python hash seed: * (glob)
167 [1]
167 [1]
168
168
169 test --outputdir
170 $ mkdir output
171 $ rt --outputdir output
172
173 --- $TESTTMP/test-failure.t
174 +++ $TESTTMP/output/test-failure.t.err
175 @@ -1,5 +1,5 @@
176 $ echo babar
177 - rataxes
178 + babar
179 This is a noop statement so that
180 this test is still more bytes than success.
181 pad pad pad pad............................................................
182
183 ERROR: test-failure.t output changed
184 !.
185 --- $TESTTMP/test-failure-unicode.t
186 +++ $TESTTMP/output/test-failure-unicode.t.err
187 @@ -1,2 +1,2 @@
188 $ echo babar\xce\xb1 (esc)
189 - l\xce\xb5\xce\xb5t (esc)
190 + babar\xce\xb1 (esc)
191
192 ERROR: test-failure-unicode.t output changed
193 !
194 Failed test-failure.t: output changed
195 Failed test-failure-unicode.t: output changed
196 # Ran 3 tests, 0 skipped, 0 warned, 2 failed.
197 python hash seed: * (glob)
198 [1]
199 $ ls -a output
200 .
201 ..
202 test-failure-unicode.t.err
203 test-failure.t.err
204
169 test --xunit support
205 test --xunit support
170 $ rt --xunit=xunit.xml
206 $ rt --xunit=xunit.xml
171
207
@@ -306,6 +342,29 b' test for --retest'
306 python hash seed: * (glob)
342 python hash seed: * (glob)
307 [1]
343 [1]
308
344
345 --retest works with --outputdir
346 $ rm -r output
347 $ mkdir output
348 $ mv test-failure.t.err output
349 $ rt --retest --outputdir output
350
351 --- $TESTTMP/test-failure.t
352 +++ $TESTTMP/output/test-failure.t.err
353 @@ -1,5 +1,5 @@
354 $ echo babar
355 - rataxes
356 + babar
357 This is a noop statement so that
358 this test is still more bytes than success.
359 pad pad pad pad............................................................
360
361 ERROR: test-failure.t output changed
362 !
363 Failed test-failure.t: output changed
364 # Ran 2 tests, 1 skipped, 0 warned, 1 failed.
365 python hash seed: * (glob)
366 [1]
367
309 Selecting Tests To Run
368 Selecting Tests To Run
310 ======================
369 ======================
311
370
General Comments 0
You need to be logged in to leave comments. Login now