[PATCH 2 of 5] run-tests: write test times to output dir
Siddharth Agarwal
sid0 at fb.com
Thu Jun 8 00:26:35 EDT 2017
# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1496892731 25200
# Wed Jun 07 20:32:11 2017 -0700
# Node ID 47a479f6ee522ad1f1d4e72a8d32096000360dc2
# Parent 90d5a9bc558130c69a8eaf58712f26d2530c49af
run-tests: write test times to output dir
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1866,10 +1866,10 @@ class TestSuite(unittest.TestSuite):
# alphabetically, while times for each test are listed from oldest to
# newest.
-def loadtimes(testdir):
+def loadtimes(outputdir):
times = []
try:
- with open(os.path.join(testdir, b'.testtimes-')) as fp:
+ with open(os.path.join(outputdir, b'.testtimes-')) as fp:
for line in fp:
ts = line.split()
times.append((ts[0], [float(t) for t in ts[1:]]))
@@ -1878,8 +1878,8 @@ def loadtimes(testdir):
raise
return times
-def savetimes(testdir, result):
- saved = dict(loadtimes(testdir))
+def savetimes(outputdir, result):
+ saved = dict(loadtimes(outputdir))
maxruns = 5
skipped = set([str(t[0]) for t in result.skipped])
for tdata in result.times:
@@ -1890,11 +1890,11 @@ def savetimes(testdir, result):
ts[:] = ts[-maxruns:]
fd, tmpname = tempfile.mkstemp(prefix=b'.testtimes',
- dir=testdir, text=True)
+ dir=outputdir, text=True)
with os.fdopen(fd, 'w') as fp:
for name, ts in sorted(saved.items()):
fp.write('%s %s\n' % (name, ' '.join(['%.3f' % (t,) for t in ts])))
- timepath = os.path.join(testdir, b'.testtimes')
+ timepath = os.path.join(outputdir, b'.testtimes')
try:
os.unlink(timepath)
except OSError:
@@ -1966,7 +1966,7 @@ class TextTestRunner(unittest.TextTestRu
self._runner._checkhglib('Tested')
- savetimes(self._runner._testdir, result)
+ savetimes(self._runner._outputdir, result)
if failed and self._runner.options.known_good_rev:
def nooutput(args):
diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t
--- a/tests/test-run-tests.t
+++ b/tests/test-run-tests.t
@@ -199,6 +199,7 @@ test --outputdir
$ ls -a output
.
..
+ .testtimes
test-failure-unicode.t.err
test-failure.t.err
More information about the Mercurial-devel
mailing list