Mercurial > hg
comparison tests/run-tests.py @ 35991: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 | 69d7fcd91696 |
children | 8de90e006c78 |
comparison
equal
deleted
inserted
replaced
35990:eefb5d603482 | 35991:04304b779df1 |
---|---|
988 data = {} | 988 data = {} |
989 with open(replacementfile, mode='rb') as source: | 989 with open(replacementfile, mode='rb') as source: |
990 # the intermediate 'compile' step help with debugging | 990 # the intermediate 'compile' step help with debugging |
991 code = compile(source.read(), replacementfile, 'exec') | 991 code = compile(source.read(), replacementfile, 'exec') |
992 exec(code, data) | 992 exec(code, data) |
993 r.extend(data.get('substitutions', ())) | 993 for value in data.get('substitutions', ()): |
994 if len(value) != 2: | |
995 msg = 'malformatted substitution in %s: %r' | |
996 msg %= (replacementfile, value) | |
997 raise ValueError(msg) | |
998 r.append(value) | |
994 return r | 999 return r |
995 | 1000 |
996 def _escapepath(self, p): | 1001 def _escapepath(self, p): |
997 if os.name == 'nt': | 1002 if os.name == 'nt': |
998 return ( | 1003 return ( |