changeset 30540:d955cebd8d6a

tests: add test that @commands in debugcommands.py are sorted I felt like inline Python in test-check-code.t was the most appropriate place for this, as other linters in contrib/ seem to be source file agnostic. The test currently fails.
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 25 Nov 2016 09:55:05 -0800
parents 29b35dac3b1f
children 342d0cb4f446
files tests/test-check-code.t
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-check-code.t	Fri Nov 25 07:30:46 2016 -0800
+++ b/tests/test-check-code.t	Fri Nov 25 09:55:05 2016 -0800
@@ -18,3 +18,20 @@
   Skipping mercurial/httpclient/__init__.py it has no-che?k-code (glob)
   Skipping mercurial/httpclient/_readers.py it has no-che?k-code (glob)
   Skipping mercurial/statprof.py it has no-che?k-code (glob)
+
+@commands in debugcommands.py should be in alphabetical order.
+
+  >>> import re
+  >>> commands = []
+  >>> with open('mercurial/debugcommands.py', 'rb') as fh:
+  ...     for line in fh:
+  ...         m = re.match("^@command\('([a-z]+)", line)
+  ...         if m:
+  ...             commands.append(m.group(1))
+  >>> scommands = list(sorted(commands))
+  >>> for i, command in enumerate(scommands):
+  ...     if command != commands[i]:
+  ...         print('commands in debugcommands.py not sorted; first differing '
+  ...               'command is %s; expected %s' % (commands[i], command))
+  ...         break
+  commands in debugcommands.py not sorted; first differing command is debugbuilddag; expected debugapplystreamclonebundle