Mercurial > hg
annotate tests/test-contrib-check-commit.t @ 27700:374fad80ce69
tests: extend check-commit self-tests
This now contains both positive and negative tests for almost all the
check-commit rules.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Fri, 08 Jan 2016 12:07:15 -0600 |
parents | 96dc6664fa9c |
children | 7291c8165e33 |
rev | line source |
---|---|
27328
96dc6664fa9c
check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
1 Test the 'check-commit' script |
96dc6664fa9c
check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
2 ============================== |
96dc6664fa9c
check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
3 |
27700
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
4 A fine patch: |
27328
96dc6664fa9c
check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
5 |
96dc6664fa9c
check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
6 $ cat > patch-with-long-header.diff << EOF |
96dc6664fa9c
check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
7 > # HG changeset patch |
96dc6664fa9c
check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
8 > # User timeless <timeless@mozdev.org> |
96dc6664fa9c
check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
9 > # Date 1448911706 0 |
96dc6664fa9c
check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
10 > # Mon Nov 30 19:28:26 2015 +0000 |
96dc6664fa9c
check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
11 > # Node ID c41cb6d2b7dbd62b1033727f8606b8c09fc4aa88 |
96dc6664fa9c
check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
12 > # Parent 42aa0e570eaa364a622bc4443b0bcb79b1100a58 |
96dc6664fa9c
check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
13 > # ClownJoke This is a veryly long header that should not be warned about because its not the description |
27700
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
14 > bundle2: use Oxford comma (issue123) (BC) |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
15 > |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
16 > diff --git a/hgext/transplant.py b/hgext/transplant.py |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
17 > --- a/hgext/transplant.py |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
18 > +++ b/hgext/transplant.py |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
19 > @@ -599,7 +599,7 @@ |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
20 > return |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
21 > if not (opts.get('source') or revs or |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
22 > opts.get('merge') or opts.get('branch')): |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
23 > - raise error.Abort(_('no source URL, branch revision or revision ' |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
24 > + raise error.Abort(_('no source URL, branch revision, or revision ' |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
25 > 'list provided')) |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
26 > if opts.get('all'): |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
27 > |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
28 > + def blahblah(x): |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
29 > + pass |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
30 > EOF |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
31 $ cat patch-with-long-header.diff | $TESTDIR/../contrib/check-commit |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
32 |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
33 A patch with lots of errors: |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
34 |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
35 $ cat > patch-with-long-header.diff << EOF |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
36 > # HG changeset patch |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
37 > # User timeless |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
38 > # Date 1448911706 0 |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
39 > # Mon Nov 30 19:28:26 2015 +0000 |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
40 > # Node ID c41cb6d2b7dbd62b1033727f8606b8c09fc4aa88 |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
41 > # Parent 42aa0e570eaa364a622bc4443b0bcb79b1100a58 |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
42 > # ClownJoke This is a veryly long header that should not be warned about because its not the description |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
43 > transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244) |
27328
96dc6664fa9c
check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
44 > |
96dc6664fa9c
check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
45 > diff --git a/hgext/transplant.py b/hgext/transplant.py |
96dc6664fa9c
check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
46 > --- a/hgext/transplant.py |
96dc6664fa9c
check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
47 > +++ b/hgext/transplant.py |
96dc6664fa9c
check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
48 > @@ -599,7 +599,7 @@ |
96dc6664fa9c
check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
49 > return |
96dc6664fa9c
check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
50 > if not (opts.get('source') or revs or |
96dc6664fa9c
check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
51 > opts.get('merge') or opts.get('branch')): |
96dc6664fa9c
check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
52 > - raise error.Abort(_('no source URL, branch revision or revision ' |
96dc6664fa9c
check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
53 > + raise error.Abort(_('no source URL, branch revision, or revision ' |
96dc6664fa9c
check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
54 > 'list provided')) |
96dc6664fa9c
check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
55 > if opts.get('all'): |
96dc6664fa9c
check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
56 > EOF |
96dc6664fa9c
check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
57 $ cat patch-with-long-header.diff | $TESTDIR/../contrib/check-commit |
27700
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
58 7: (BC) needs to be uppercase |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
59 transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244) |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
60 7: no space allowed between issue and number |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
61 transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244) |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
62 7: use (issueDDDD) instead of bug |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
63 transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244) |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
64 1: username is not an email address |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
65 # User timeless |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
66 7: summary keyword should be most user-relevant one-word command or topic |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
67 transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244) |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
68 7: summary line too long (limit is 78) |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
69 transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244) |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
70 [1] |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
71 |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
72 A patch with other errors: |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
73 |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
74 $ cat > patch-with-long-header.diff << EOF |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
75 > # HG changeset patch |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
76 > # User timeless |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
77 > # Date 1448911706 0 |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
78 > # Mon Nov 30 19:28:26 2015 +0000 |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
79 > # Node ID c41cb6d2b7dbd62b1033727f8606b8c09fc4aa88 |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
80 > # Parent 42aa0e570eaa364a622bc4443b0bcb79b1100a58 |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
81 > # ClownJoke This is a veryly long header that should not be warned about because its not the description |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
82 > This has no topic and ends with a period. |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
83 > |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
84 > diff --git a/hgext/transplant.py b/hgext/transplant.py |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
85 > --- a/hgext/transplant.py |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
86 > +++ b/hgext/transplant.py |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
87 > @@ -599,7 +599,7 @@ |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
88 > if opts.get('all'): |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
89 > |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
90 > + |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
91 > + def blah_blah(x): |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
92 > + pass |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
93 > + |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
94 > |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
95 > EOF |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
96 $ cat patch-with-long-header.diff | $TESTDIR/../contrib/check-commit |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
97 1: username is not an email address |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
98 # User timeless |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
99 7: summary line doesn't start with 'topic: ' |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
100 This has no topic and ends with a period. |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
101 7: don't capitalize summary lines |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
102 This has no topic and ends with a period. |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
103 7: don't add trailing period on summary line |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
104 This has no topic and ends with a period. |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
105 19: adds double empty line |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
106 |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
107 15: adds double empty line |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
108 + |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
109 16: adds a function with foo_bar naming |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
110 + def blah_blah(x): |
374fad80ce69
tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents:
27328
diff
changeset
|
111 [1] |