# HG changeset patch
# User Boris Feld <boris.f...@octobus.net>
# Date 1518176892 -3600
#      Fri Feb 09 12:48:12 2018 +0100
# Node ID 3fe40329001a42dcbe98c69b342aa00ec821fa92
# Parent  80e5210df25c330bd2a4e8f12385422545cb69bf
# EXP-Topic pattern-error
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
3fe40329001a
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.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -990,7 +990,12 @@ class Test(unittest.TestCase):
                 # 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):
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to