[PATCH 3 of 3 V3] run-tests: support multiple cases in .t test
Yuya Nishihara
yuya at tcha.org
Thu May 18 09:04:09 EDT 2017
On Wed, 17 May 2017 08:36:44 -0700, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1495001431 25200
> # Tue May 16 23:10:31 2017 -0700
> # Node ID 7505f5ff2346c15cec1bf24fdf99122b305d8f4f
> # Parent 487161ec82a581324060d6300184206b5a179322
> # Available At https://bitbucket.org/quark-zju/hg-draft
> # hg pull https://bitbucket.org/quark-zju/hg-draft -r 7505f5ff2346
> run-tests: support multiple cases in .t test
> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -221,4 +221,16 @@ def parselistfiles(files, listtype, warn
> return entries
>
> +def parsettestcases(path):
> + """read a .t test file, return a set of test case names"""
> + cases = set()
> + try:
> + with open(path, 'rb') as f:
> + for l in f:
> + if l.startswith(b'#testcases '):
> + cases.update(l[11:].split())
> + except IOError:
> + pass
Nit: maybe better to check errno?
> + def __init__(self, path, *args, **kwds):
> + # accept an extra "case" parameter
> + case = None
> + if 'case' in kwds:
> + case = kwds.pop('case')
> + self._case = case
> + self._allcases = parsettestcases(path)
> + super(TTest, self).__init__(path, *args, **kwds)
> + if case:
> + self.name += b' (case %s)' % case
> + self.errpath = b'%s.%s.err' % (self.errpath[:-4], case)
> + self._tmpname += b'-%s' % case
It appears we have (name, bname) pair, which is (str, bytes) respectively.
Maybe one of them could be a @property.
More information about the Mercurial-devel
mailing list