[PATCH 3 of 3] tests: extend check-commit self-tests

Matt Mackall mpm at selenic.com
Fri Jan 8 12:46:58 CST 2016


# HG changeset patch
# User Matt Mackall <mpm at selenic.com>
# Date 1452276435 21600
#      Fri Jan 08 12:07:15 2016 -0600
# Node ID a8ea9d699407fcbdb44c87a097f32432039ca483
# Parent  54875580a56db3682f5dc4cadd65c7b6d9176cd7
tests: extend check-commit self-tests

This now contains both positive and negative tests for almost all the
check-commit rules.

diff -r 54875580a56d -r a8ea9d699407 tests/test-contrib-check-commit.t
--- a/tests/test-contrib-check-commit.t	Fri Jan 08 12:35:02 2016 -0600
+++ b/tests/test-contrib-check-commit.t	Fri Jan 08 12:07:15 2016 -0600
@@ -1,7 +1,7 @@
 Test the 'check-commit' script
 ==============================
 
-Test long lines in header (should not be reported as too long description)
+A fine patch:
 
   $ cat > patch-with-long-header.diff << EOF
   > # HG changeset patch
@@ -11,7 +11,36 @@
   > # Node ID c41cb6d2b7dbd62b1033727f8606b8c09fc4aa88
   > # Parent  42aa0e570eaa364a622bc4443b0bcb79b1100a58
   > # ClownJoke This is a veryly long header that should not be warned about because its not the description
-  > transplant: use Oxford comma
+  > bundle2: use Oxford comma (issue123) (BC)
+  > 
+  > diff --git a/hgext/transplant.py b/hgext/transplant.py
+  > --- a/hgext/transplant.py
+  > +++ b/hgext/transplant.py
+  > @@ -599,7 +599,7 @@
+  >              return
+  >          if not (opts.get('source') or revs or
+  >                  opts.get('merge') or opts.get('branch')):
+  > -            raise error.Abort(_('no source URL, branch revision or revision '
+  > +            raise error.Abort(_('no source URL, branch revision, or revision '
+  >                                 'list provided'))
+  >          if opts.get('all'):
+  > 
+  > + def blahblah(x):
+  > +     pass
+  > EOF
+  $ cat patch-with-long-header.diff | $TESTDIR/../contrib/check-commit
+
+A patch with lots of errors:
+
+  $ cat > patch-with-long-header.diff << EOF
+  > # HG changeset patch
+  > # User timeless
+  > # Date 1448911706 0
+  > #      Mon Nov 30 19:28:26 2015 +0000
+  > # Node ID c41cb6d2b7dbd62b1033727f8606b8c09fc4aa88
+  > # Parent  42aa0e570eaa364a622bc4443b0bcb79b1100a58
+  > # ClownJoke This is a veryly long header that should not be warned about because its not the description
+  > transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
   > 
   > diff --git a/hgext/transplant.py b/hgext/transplant.py
   > --- a/hgext/transplant.py
@@ -26,3 +55,57 @@
   >          if opts.get('all'):
   > EOF
   $ cat patch-with-long-header.diff | $TESTDIR/../contrib/check-commit
+  7: (BC) needs to be uppercase
+   transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
+  7: no space allowed between issue and number
+   transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
+  7: use (issueDDDD) instead of bug
+   transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
+  1: username is not an email address
+   # User timeless
+  7: summary keyword should be most user-relevant one-word command or topic
+   transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
+  7: summary line too long (limit is 78)
+   transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
+  [1]
+
+A patch with other errors:
+
+  $ cat > patch-with-long-header.diff << EOF
+  > # HG changeset patch
+  > # User timeless
+  > # Date 1448911706 0
+  > #      Mon Nov 30 19:28:26 2015 +0000
+  > # Node ID c41cb6d2b7dbd62b1033727f8606b8c09fc4aa88
+  > # Parent  42aa0e570eaa364a622bc4443b0bcb79b1100a58
+  > # ClownJoke This is a veryly long header that should not be warned about because its not the description
+  > This has no topic and ends with a period.
+  > 
+  > diff --git a/hgext/transplant.py b/hgext/transplant.py
+  > --- a/hgext/transplant.py
+  > +++ b/hgext/transplant.py
+  > @@ -599,7 +599,7 @@
+  >          if opts.get('all'):
+  >  
+  > +
+  > + def blah_blah(x):
+  > +     pass
+  > +
+  >  
+  > EOF
+  $ cat patch-with-long-header.diff | $TESTDIR/../contrib/check-commit
+  1: username is not an email address
+   # User timeless
+  7: summary line doesn't start with 'topic: '
+   This has no topic and ends with a period.
+  7: don't capitalize summary lines
+   This has no topic and ends with a period.
+  7: don't add trailing period on summary line
+   This has no topic and ends with a period.
+  19: adds double empty line
+    
+  15: adds double empty line
+   +
+  16: adds a function with foo_bar naming
+   + def blah_blah(x):
+  [1]


More information about the Mercurial-devel mailing list