hgmo: test for mozlink after firstline filter (bug 1328717); r?wlach draft
authorGregory Szorc <gps@mozilla.com>
Wed, 04 Jan 2017 14:23:06 -0800
changeset 10088 84da1c3093eb4cadb55581eff58c7e037e8fcf07
parent 10085 3650e63e16b92b8b8b247e82db27a408ced11f74
child 10089 af281f622701a604ce4bde2b8a14714ae94b6018
push id1427
push userbmo:gps@mozilla.com
push dateWed, 04 Jan 2017 23:36:14 +0000
reviewerswlach
bugs1328717
hgmo: test for mozlink after firstline filter (bug 1328717); r?wlach mozlink doesn't work correctly if it only operates on the first line of a commit message. So, we add a crude static analysis test that prints warnings for all occurrences of this bug. MozReview-Commit-ID: La6Z6sIVivV
hgext/hgmo/tests/test-mozlink.t
--- a/hgext/hgmo/tests/test-mozlink.t
+++ b/hgext/hgmo/tests/test-mozlink.t
@@ -51,8 +51,33 @@
   > EOF
 
   $ hg log -r . -T '{desc|mozlink}\n'
   <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=124562">bug 124562</a> - fix a thing
   
   Fixes <a href="https://github.com/mozilla/foo/issues/32">#32</a> and <a href="https://github.com/mozilla/foo/issues/462">#462</a>
   
   Source-Repo: <a href="https://github.com/mozilla/foo">https://github.com/mozilla/foo</a>
+
+  $ cd ..
+
+The mozlink filter requires context from the full commit message to work properly.
+If the firstline filter runs before it, it lacks this context. This is a quick
+static analysis check that "mozlink" comes before "firstline".
+
+  $ cat >> checktemplate.py << EOF
+  > import os, sys
+  > for path in sys.stdin:
+  >     path = path.rstrip()
+  >     lines = open(path, 'rb').readlines()
+  >     for i, line in enumerate(lines):
+  >         if 'mozlink' in line and 'firstline' in line:
+  >             if line.index('firstline') < line.index('mozlink'):
+  >                 relpath = os.path.relpath(path, os.environ['TESTDIR'])
+  >                 print('%s:%d has firstline before mozlink' % (relpath, i + 1))
+  > EOF
+
+  $ find $TESTDIR/hgtemplates -type f | $PYTHON checktemplate.py
+  hgtemplates/gitweb_mozilla/map:109 has firstline before mozlink
+  hgtemplates/gitweb_mozilla/map:278 has firstline before mozlink
+  hgtemplates/gitweb_mozilla/map:284 has firstline before mozlink
+  hgtemplates/gitweb_mozilla/map:298 has firstline before mozlink
+  hgtemplates/gitweb_mozilla/changeset.tmpl:32 has firstline before mozlink