Mercurial > hg-stable
changeset 36030:04304b779df1
tests: raise a better error when patterns are wrongly formatted
It is fairly easy to make mistakes when merging conflict in the pattern file.
A common mistake is to forget adding an extra trailing comma changing the
length of the tuple.
We now detect such error and raise a better error message that helps to find
it.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Fri, 09 Feb 2018 12:48:12 +0100 |
parents | eefb5d603482 |
children | 07cd54eae696 |
files | tests/run-tests.py |
diffstat | 1 files changed, 6 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py Sat Jan 27 17:58:19 2018 -0500 +++ b/tests/run-tests.py Fri Feb 09 12:48:12 2018 +0100 @@ -990,7 +990,12 @@ # the intermediate 'compile' step help with debugging code = compile(source.read(), replacementfile, 'exec') exec(code, data) - r.extend(data.get('substitutions', ())) + for value in data.get('substitutions', ()): + if len(value) != 2: + msg = 'malformatted substitution in %s: %r' + msg %= (replacementfile, value) + raise ValueError(msg) + r.append(value) return r def _escapepath(self, p):