Patchwork [1,of,2] tests: add test that @commands in debugcommands.py are sorted

login
register
mail settings
Submitter Gregory Szorc
Date Nov. 25, 2016, 6:04 p.m.
Message ID <7b8444ec642e29b1a8cb.1480097087@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/17757/
State Accepted
Headers show

Comments

Gregory Szorc - Nov. 25, 2016, 6:04 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1480096505 28800
#      Fri Nov 25 09:55:05 2016 -0800
# Node ID 7b8444ec642e29b1a8cb3e63909d5caf9e4166d7
# Parent  906a7d8e969552536fffe0df7a5e63bf5d79b34b
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.
Yuya Nishihara - Nov. 27, 2016, 9:37 a.m.
On Fri, 25 Nov 2016 10:04:47 -0800, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1480096505 28800
> #      Fri Nov 25 09:55:05 2016 -0800
> # Node ID 7b8444ec642e29b1a8cb3e63909d5caf9e4166d7
> # Parent  906a7d8e969552536fffe0df7a5e63bf5d79b34b
> tests: add test that @commands in debugcommands.py are sorted

Queued these, thanks.

Patch

diff --git a/tests/test-check-code.t b/tests/test-check-code.t
--- a/tests/test-check-code.t
+++ b/tests/test-check-code.t
@@ -18,3 +18,20 @@  New errors are not allowed. Warnings are
   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