annotate tests/test-contrib-check-code.t @ 46472:98e39f04d60e

upgrade: implement partial upgrade for upgrading persistent-nodemap Upgrading repositories to use persistent nodemap should be fast and easy as it requires only two things: 1) Updating the requirements 2) Writing a persistent-nodemap on disk For both of the steps above, we don't need to edit existing revlogs. This patch makes upgrade only do the above mentioned two steps if we are only upgarding to use persistent-nodemap feature. Since `nodemap.persist_nodemap()` assumes that there exists a nodemap file for the given revlog if we are trying to call it, this patch adds `force` argument to create a file if does not exist which is true in our upgrade case. The test changes demonstrate that we no longer write nodemap files for manifest after upgrade which I think is desirable. Differential Revision: https://phab.mercurial-scm.org/D9936
author Pulkit Goyal <7895pulkit@gmail.com>
date Mon, 01 Feb 2021 00:02:00 +0530
parents 867883d454ea
children 55d132525155
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
1 $ cat > correct.py <<NO_CHECK_EOF
12632
6c98107f787e tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents: 11822
diff changeset
2 > def toto(arg1, arg2):
6c98107f787e tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents: 11822
diff changeset
3 > del arg2
6c98107f787e tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents: 11822
diff changeset
4 > return (5 + 6, 9)
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
5 > NO_CHECK_EOF
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
6 $ cat > wrong.py <<NO_CHECK_EOF
12632
6c98107f787e tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents: 11822
diff changeset
7 > def toto( arg1, arg2):
6c98107f787e tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents: 11822
diff changeset
8 > del(arg2)
6c98107f787e tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents: 11822
diff changeset
9 > return ( 5+6, 9)
41761
e2472b12c842 contrib: enforce wrapping too-long lines with () instead of \
Augie Fackler <augie@google.com>
parents: 40094
diff changeset
10 > def badwrap():
e2472b12c842 contrib: enforce wrapping too-long lines with () instead of \
Augie Fackler <augie@google.com>
parents: 40094
diff changeset
11 > return 1 + \\
e2472b12c842 contrib: enforce wrapping too-long lines with () instead of \
Augie Fackler <augie@google.com>
parents: 40094
diff changeset
12 > 2
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
13 > NO_CHECK_EOF
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
14 $ cat > quote.py <<NO_CHECK_EOF
12632
6c98107f787e tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents: 11822
diff changeset
15 > # let's use quote in comments
6c98107f787e tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents: 11822
diff changeset
16 > (''' ( 4x5 )
6c98107f787e tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents: 11822
diff changeset
17 > but """\\''' and finally''',
6c98107f787e tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents: 11822
diff changeset
18 > """let's fool checkpatch""", '1+2',
6c98107f787e tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents: 11822
diff changeset
19 > '"""', 42+1, """and
6c98107f787e tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents: 11822
diff changeset
20 > ( 4-1 ) """, "( 1+1 )\" and ")
6c98107f787e tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents: 11822
diff changeset
21 > a, '\\\\\\\\', "\\\\\\" x-2", "c-1"
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
22 > NO_CHECK_EOF
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
23 $ cat > classstyle.py <<NO_CHECK_EOF
14763
b071cd58af50 check-code: fix class style checking (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 13077
diff changeset
24 > class newstyle_class(object):
b071cd58af50 check-code: fix class style checking (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 13077
diff changeset
25 > pass
b071cd58af50 check-code: fix class style checking (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 13077
diff changeset
26 >
b071cd58af50 check-code: fix class style checking (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 13077
diff changeset
27 > class oldstyle_class:
b071cd58af50 check-code: fix class style checking (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 13077
diff changeset
28 > pass
b071cd58af50 check-code: fix class style checking (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 13077
diff changeset
29 >
b071cd58af50 check-code: fix class style checking (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 13077
diff changeset
30 > class empty():
b071cd58af50 check-code: fix class style checking (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 13077
diff changeset
31 > pass
b071cd58af50 check-code: fix class style checking (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 13077
diff changeset
32 >
b071cd58af50 check-code: fix class style checking (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 13077
diff changeset
33 > no_class = 1:
b071cd58af50 check-code: fix class style checking (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 13077
diff changeset
34 > pass
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
35 > NO_CHECK_EOF
12632
6c98107f787e tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents: 11822
diff changeset
36 $ check_code="$TESTDIR"/../contrib/check-code.py
25199
e78447e61624 check-code: entirely drop the 'non-py24.py' file from the test
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25198
diff changeset
37 $ "$check_code" ./wrong.py ./correct.py ./quote.py ./classstyle.py
12632
6c98107f787e tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents: 11822
diff changeset
38 ./wrong.py:1:
6c98107f787e tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents: 11822
diff changeset
39 > def toto( arg1, arg2):
6c98107f787e tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents: 11822
diff changeset
40 gratuitous whitespace in () or []
6c98107f787e tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents: 11822
diff changeset
41 ./wrong.py:2:
6c98107f787e tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents: 11822
diff changeset
42 > del(arg2)
13077
6b8d2ee24ce2 coding style: fix yield used as a function
Thomas Arendsen Hein <thomas@jtah.de>
parents: 13026
diff changeset
43 Python keyword is not a function
12632
6c98107f787e tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents: 11822
diff changeset
44 ./wrong.py:3:
6c98107f787e tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents: 11822
diff changeset
45 > return ( 5+6, 9)
15281
aeeb2afcdc25 check-code: support multiline matches like try/except/finally
Matt Mackall <mpm@selenic.com>
parents: 14763
diff changeset
46 gratuitous whitespace in () or []
12632
6c98107f787e tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents: 11822
diff changeset
47 missing whitespace in expression
41761
e2472b12c842 contrib: enforce wrapping too-long lines with () instead of \
Augie Fackler <augie@google.com>
parents: 40094
diff changeset
48 ./wrong.py:5:
e2472b12c842 contrib: enforce wrapping too-long lines with () instead of \
Augie Fackler <augie@google.com>
parents: 40094
diff changeset
49 > return 1 + \
e2472b12c842 contrib: enforce wrapping too-long lines with () instead of \
Augie Fackler <augie@google.com>
parents: 40094
diff changeset
50 Use () to wrap long lines in Python, not \
12632
6c98107f787e tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents: 11822
diff changeset
51 ./quote.py:5:
6c98107f787e tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents: 11822
diff changeset
52 > '"""', 42+1, """and
6c98107f787e tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents: 11822
diff changeset
53 missing whitespace in expression
14763
b071cd58af50 check-code: fix class style checking (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 13077
diff changeset
54 ./classstyle.py:4:
b071cd58af50 check-code: fix class style checking (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 13077
diff changeset
55 > class oldstyle_class:
b071cd58af50 check-code: fix class style checking (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 13077
diff changeset
56 old-style class, use class foo(object)
b071cd58af50 check-code: fix class style checking (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 13077
diff changeset
57 ./classstyle.py:7:
b071cd58af50 check-code: fix class style checking (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 13077
diff changeset
58 > class empty():
25140
317333e0793c check-code: fix the error message about 'class foo():'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25077
diff changeset
59 class foo() creates old style object, use class foo(object)
12632
6c98107f787e tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents: 11822
diff changeset
60 [1]
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
61 $ cat > python3-compat.py << NO_CHECK_EOF
18183
e1caaeb5a2ed check-code: disallow defunct <> operator
Augie Fackler <raf@durin42.com>
parents: 18180
diff changeset
62 > foo <> bar
e1caaeb5a2ed check-code: disallow defunct <> operator
Augie Fackler <raf@durin42.com>
parents: 18180
diff changeset
63 > reduce(lambda a, b: a + b, [1, 2, 3, 4])
20688
a61ed1c2d7a7 check-code: disallow use of dict(key=value) construction
Augie Fackler <raf@durin42.com>
parents: 20005
diff changeset
64 > dict(key=value)
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
65 > NO_CHECK_EOF
18183
e1caaeb5a2ed check-code: disallow defunct <> operator
Augie Fackler <raf@durin42.com>
parents: 18180
diff changeset
66 $ "$check_code" python3-compat.py
e1caaeb5a2ed check-code: disallow defunct <> operator
Augie Fackler <raf@durin42.com>
parents: 18180
diff changeset
67 python3-compat.py:1:
e1caaeb5a2ed check-code: disallow defunct <> operator
Augie Fackler <raf@durin42.com>
parents: 18180
diff changeset
68 > foo <> bar
e1caaeb5a2ed check-code: disallow defunct <> operator
Augie Fackler <raf@durin42.com>
parents: 18180
diff changeset
69 <> operator is not available in Python 3+, use !=
e1caaeb5a2ed check-code: disallow defunct <> operator
Augie Fackler <raf@durin42.com>
parents: 18180
diff changeset
70 python3-compat.py:2:
e1caaeb5a2ed check-code: disallow defunct <> operator
Augie Fackler <raf@durin42.com>
parents: 18180
diff changeset
71 > reduce(lambda a, b: a + b, [1, 2, 3, 4])
e1caaeb5a2ed check-code: disallow defunct <> operator
Augie Fackler <raf@durin42.com>
parents: 18180
diff changeset
72 reduce is not available in Python 3+
20688
a61ed1c2d7a7 check-code: disallow use of dict(key=value) construction
Augie Fackler <raf@durin42.com>
parents: 20005
diff changeset
73 python3-compat.py:3:
a61ed1c2d7a7 check-code: disallow use of dict(key=value) construction
Augie Fackler <raf@durin42.com>
parents: 20005
diff changeset
74 > dict(key=value)
a61ed1c2d7a7 check-code: disallow use of dict(key=value) construction
Augie Fackler <raf@durin42.com>
parents: 20005
diff changeset
75 dict() is different in Py2 and 3 and is slower than {}
18183
e1caaeb5a2ed check-code: disallow defunct <> operator
Augie Fackler <raf@durin42.com>
parents: 18180
diff changeset
76 [1]
13026
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
77
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
78 $ cat > foo.c <<NO_CHECK_EOF
28594
d3990da51637 check-code: prevent use of strcpy
Augie Fackler <augie@google.com>
parents: 27367
diff changeset
79 > void narf() {
d3990da51637 check-code: prevent use of strcpy
Augie Fackler <augie@google.com>
parents: 27367
diff changeset
80 > strcpy(foo, bar);
d3990da51637 check-code: prevent use of strcpy
Augie Fackler <augie@google.com>
parents: 27367
diff changeset
81 > // strcpy_s is okay, but this comment is not
d3990da51637 check-code: prevent use of strcpy
Augie Fackler <augie@google.com>
parents: 27367
diff changeset
82 > strcpy_s(foo, bar);
d3990da51637 check-code: prevent use of strcpy
Augie Fackler <augie@google.com>
parents: 27367
diff changeset
83 > }
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
84 > NO_CHECK_EOF
28594
d3990da51637 check-code: prevent use of strcpy
Augie Fackler <augie@google.com>
parents: 27367
diff changeset
85 $ "$check_code" ./foo.c
d3990da51637 check-code: prevent use of strcpy
Augie Fackler <augie@google.com>
parents: 27367
diff changeset
86 ./foo.c:2:
d3990da51637 check-code: prevent use of strcpy
Augie Fackler <augie@google.com>
parents: 27367
diff changeset
87 > strcpy(foo, bar);
d3990da51637 check-code: prevent use of strcpy
Augie Fackler <augie@google.com>
parents: 27367
diff changeset
88 don't use strcpy, use strlcpy or memcpy
d3990da51637 check-code: prevent use of strcpy
Augie Fackler <augie@google.com>
parents: 27367
diff changeset
89 ./foo.c:3:
d3990da51637 check-code: prevent use of strcpy
Augie Fackler <augie@google.com>
parents: 27367
diff changeset
90 > // strcpy_s is okay, but this comment is not
d3990da51637 check-code: prevent use of strcpy
Augie Fackler <augie@google.com>
parents: 27367
diff changeset
91 don't use //-style comments
d3990da51637 check-code: prevent use of strcpy
Augie Fackler <augie@google.com>
parents: 27367
diff changeset
92 [1]
d3990da51637 check-code: prevent use of strcpy
Augie Fackler <augie@google.com>
parents: 27367
diff changeset
93
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
94 $ cat > is-op.py <<NO_CHECK_EOF
13026
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
95 > # is-operator comparing number or string literal
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
96 > x = None
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
97 > y = x is 'foo'
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
98 > y = x is "foo"
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
99 > y = x is 5346
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
100 > y = x is -6
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
101 > y = x is not 'foo'
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
102 > y = x is not "foo"
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
103 > y = x is not 5346
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
104 > y = x is not -6
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
105 > NO_CHECK_EOF
13026
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
106
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
107 $ "$check_code" ./is-op.py
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
108 ./is-op.py:3:
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
109 > y = x is 'foo'
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
110 object comparison with literal
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
111 ./is-op.py:4:
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
112 > y = x is "foo"
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
113 object comparison with literal
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
114 ./is-op.py:5:
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
115 > y = x is 5346
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
116 object comparison with literal
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
117 ./is-op.py:6:
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
118 > y = x is -6
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
119 object comparison with literal
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
120 ./is-op.py:7:
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
121 > y = x is not 'foo'
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
122 object comparison with literal
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
123 ./is-op.py:8:
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
124 > y = x is not "foo"
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
125 object comparison with literal
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
126 ./is-op.py:9:
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
127 > y = x is not 5346
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
128 object comparison with literal
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
129 ./is-op.py:10:
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
130 > y = x is not -6
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
131 object comparison with literal
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
132 [1]
53391819f195 check-code: catch Python 'is' comparing number or string literals
Adrian Buehlmann <adrian@cadifra.com>
parents: 12632
diff changeset
133
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
134 $ cat > for-nolineno.py <<NO_CHECK_EOF
15502
7917a104a285 check-code: add --nolineno option for hiding line numbers
Mads Kiilerich <mads@kiilerich.com>
parents: 15285
diff changeset
135 > except:
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
136 > NO_CHECK_EOF
18762
a91387a37f05 check-code: do not prepend "warning" to a failure message
Simon Heimberg <simohe@besonet.ch>
parents: 18183
diff changeset
137 $ "$check_code" for-nolineno.py --nolineno
a91387a37f05 check-code: do not prepend "warning" to a failure message
Simon Heimberg <simohe@besonet.ch>
parents: 18183
diff changeset
138 for-nolineno.py:0:
15502
7917a104a285 check-code: add --nolineno option for hiding line numbers
Mads Kiilerich <mads@kiilerich.com>
parents: 15285
diff changeset
139 > except:
18762
a91387a37f05 check-code: do not prepend "warning" to a failure message
Simon Heimberg <simohe@besonet.ch>
parents: 18183
diff changeset
140 naked except clause
15502
7917a104a285 check-code: add --nolineno option for hiding line numbers
Mads Kiilerich <mads@kiilerich.com>
parents: 15285
diff changeset
141 [1]
18180
c582a71457e5 check-code: disallow two-argument form of raise
Augie Fackler <raf@durin42.com>
parents: 17620
diff changeset
142
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
143 $ cat > warning.t <<NO_CHECK_EOF
19422
d9e86d656017 check-code: automatically preppend "warning: " to all warning messages
Simon Heimberg <simohe@besonet.ch>
parents: 18762
diff changeset
144 > $ function warnonly {
d9e86d656017 check-code: automatically preppend "warning: " to all warning messages
Simon Heimberg <simohe@besonet.ch>
parents: 18762
diff changeset
145 > > }
20005
22154ec6fb8b check-code: prepend warning prefix only once, but for each warning
Simon Heimberg <simohe@besonet.ch>
parents: 19998
diff changeset
146 > $ diff -N aaa
22154ec6fb8b check-code: prepend warning prefix only once, but for each warning
Simon Heimberg <simohe@besonet.ch>
parents: 19998
diff changeset
147 > $ function onwarn {}
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
148 > NO_CHECK_EOF
19422
d9e86d656017 check-code: automatically preppend "warning: " to all warning messages
Simon Heimberg <simohe@besonet.ch>
parents: 18762
diff changeset
149 $ "$check_code" warning.t
d9e86d656017 check-code: automatically preppend "warning: " to all warning messages
Simon Heimberg <simohe@besonet.ch>
parents: 18762
diff changeset
150 $ "$check_code" --warn warning.t
d9e86d656017 check-code: automatically preppend "warning: " to all warning messages
Simon Heimberg <simohe@besonet.ch>
parents: 18762
diff changeset
151 warning.t:1:
d9e86d656017 check-code: automatically preppend "warning: " to all warning messages
Simon Heimberg <simohe@besonet.ch>
parents: 18762
diff changeset
152 > $ function warnonly {
d9e86d656017 check-code: automatically preppend "warning: " to all warning messages
Simon Heimberg <simohe@besonet.ch>
parents: 18762
diff changeset
153 warning: don't use 'function', use old style
20005
22154ec6fb8b check-code: prepend warning prefix only once, but for each warning
Simon Heimberg <simohe@besonet.ch>
parents: 19998
diff changeset
154 warning.t:3:
22154ec6fb8b check-code: prepend warning prefix only once, but for each warning
Simon Heimberg <simohe@besonet.ch>
parents: 19998
diff changeset
155 > $ diff -N aaa
22154ec6fb8b check-code: prepend warning prefix only once, but for each warning
Simon Heimberg <simohe@besonet.ch>
parents: 19998
diff changeset
156 warning: don't use 'diff -N'
22154ec6fb8b check-code: prepend warning prefix only once, but for each warning
Simon Heimberg <simohe@besonet.ch>
parents: 19998
diff changeset
157 warning.t:4:
22154ec6fb8b check-code: prepend warning prefix only once, but for each warning
Simon Heimberg <simohe@besonet.ch>
parents: 19998
diff changeset
158 > $ function onwarn {}
22154ec6fb8b check-code: prepend warning prefix only once, but for each warning
Simon Heimberg <simohe@besonet.ch>
parents: 19998
diff changeset
159 warning: don't use 'function', use old style
19422
d9e86d656017 check-code: automatically preppend "warning: " to all warning messages
Simon Heimberg <simohe@besonet.ch>
parents: 18762
diff changeset
160 [1]
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
161 $ cat > error.t <<NO_CHECK_EOF
32293
ca727147ff9f style: ban [ foo == bar] bashism in tests
Augie Fackler <augie@google.com>
parents: 29398
diff changeset
162 > $ [ foo == bar ]
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
163 > NO_CHECK_EOF
32293
ca727147ff9f style: ban [ foo == bar] bashism in tests
Augie Fackler <augie@google.com>
parents: 29398
diff changeset
164 $ "$check_code" error.t
ca727147ff9f style: ban [ foo == bar] bashism in tests
Augie Fackler <augie@google.com>
parents: 29398
diff changeset
165 error.t:1:
ca727147ff9f style: ban [ foo == bar] bashism in tests
Augie Fackler <augie@google.com>
parents: 29398
diff changeset
166 > $ [ foo == bar ]
ca727147ff9f style: ban [ foo == bar] bashism in tests
Augie Fackler <augie@google.com>
parents: 29398
diff changeset
167 [ foo == bar ] is a bashism, use [ foo = bar ] instead
ca727147ff9f style: ban [ foo == bar] bashism in tests
Augie Fackler <augie@google.com>
parents: 29398
diff changeset
168 [1]
ca727147ff9f style: ban [ foo == bar] bashism in tests
Augie Fackler <augie@google.com>
parents: 29398
diff changeset
169 $ rm error.t
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
170 $ cat > raise-format.py <<NO_CHECK_EOF
18180
c582a71457e5 check-code: disallow two-argument form of raise
Augie Fackler <raf@durin42.com>
parents: 17620
diff changeset
171 > raise SomeException, message
c582a71457e5 check-code: disallow two-argument form of raise
Augie Fackler <raf@durin42.com>
parents: 17620
diff changeset
172 > # this next line is okay
c582a71457e5 check-code: disallow two-argument form of raise
Augie Fackler <raf@durin42.com>
parents: 17620
diff changeset
173 > raise SomeException(arg1, arg2)
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
174 > NO_CHECK_EOF
19494
3119dc155ac2 check-code: do not abort on an unreadable file, only report this
Simon Heimberg <simohe@besonet.ch>
parents: 19422
diff changeset
175 $ "$check_code" not-existing.py raise-format.py
3119dc155ac2 check-code: do not abort on an unreadable file, only report this
Simon Heimberg <simohe@besonet.ch>
parents: 19422
diff changeset
176 Skipping*not-existing.py* (glob)
18180
c582a71457e5 check-code: disallow two-argument form of raise
Augie Fackler <raf@durin42.com>
parents: 17620
diff changeset
177 raise-format.py:1:
c582a71457e5 check-code: disallow two-argument form of raise
Augie Fackler <raf@durin42.com>
parents: 17620
diff changeset
178 > raise SomeException, message
c582a71457e5 check-code: disallow two-argument form of raise
Augie Fackler <raf@durin42.com>
parents: 17620
diff changeset
179 don't use old-style two-argument raise, use Exception(message)
c582a71457e5 check-code: disallow two-argument form of raise
Augie Fackler <raf@durin42.com>
parents: 17620
diff changeset
180 [1]
19494
3119dc155ac2 check-code: do not abort on an unreadable file, only report this
Simon Heimberg <simohe@besonet.ch>
parents: 19422
diff changeset
181
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
182 $ cat <<NO_CHECK_EOF > tab.t
35315
e223c0438f89 check-code: allow tabs in heredoc
Yuya Nishihara <yuya@tcha.org>
parents: 34384
diff changeset
183 > indent
e223c0438f89 check-code: allow tabs in heredoc
Yuya Nishihara <yuya@tcha.org>
parents: 34384
diff changeset
184 > > heredoc
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
185 > NO_CHECK_EOF
35315
e223c0438f89 check-code: allow tabs in heredoc
Yuya Nishihara <yuya@tcha.org>
parents: 34384
diff changeset
186 $ "$check_code" tab.t
e223c0438f89 check-code: allow tabs in heredoc
Yuya Nishihara <yuya@tcha.org>
parents: 34384
diff changeset
187 tab.t:1:
e223c0438f89 check-code: allow tabs in heredoc
Yuya Nishihara <yuya@tcha.org>
parents: 34384
diff changeset
188 > indent
e223c0438f89 check-code: allow tabs in heredoc
Yuya Nishihara <yuya@tcha.org>
parents: 34384
diff changeset
189 don't use tabs to indent
e223c0438f89 check-code: allow tabs in heredoc
Yuya Nishihara <yuya@tcha.org>
parents: 34384
diff changeset
190 [1]
e223c0438f89 check-code: allow tabs in heredoc
Yuya Nishihara <yuya@tcha.org>
parents: 34384
diff changeset
191 $ rm tab.t
e223c0438f89 check-code: allow tabs in heredoc
Yuya Nishihara <yuya@tcha.org>
parents: 34384
diff changeset
192
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
193 $ cat > rst.py <<NO_CHECK_EOF
19998
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
194 > """problematic rst text
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
195 >
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
196 > .. note::
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
197 > wrong
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
198 > """
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
199 >
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
200 > '''
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
201 >
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
202 > .. note::
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
203 >
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
204 > valid
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
205 >
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
206 > new text
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
207 >
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
208 > .. note::
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
209 >
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
210 > also valid
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
211 > '''
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
212 >
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
213 > """mixed
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
214 >
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
215 > .. note::
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
216 >
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
217 > good
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
218 >
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
219 > .. note::
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
220 > plus bad
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
221 > """
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
222 > NO_CHECK_EOF
19998
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
223 $ $check_code -w rst.py
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
224 rst.py:3:
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
225 > .. note::
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
226 warning: add two newlines after '.. note::'
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
227 rst.py:26:
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
228 > .. note::
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
229 warning: add two newlines after '.. note::'
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
230 [1]
289bbb294e82 check-code: check comment for '.. note::' without two newlines
Simon Heimberg <simohe@besonet.ch>
parents: 19501
diff changeset
231
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
232 $ cat > ./map-inside-gettext.py <<NO_CHECK_EOF
33721
24849d53697d tests: clean up many print statements to be print functions instead
Augie Fackler <augie@google.com>
parents: 32293
diff changeset
233 > print(_("map inside gettext %s" % v))
21097
e8ef59b351c3 check-code: detect "% inside _()" when there are leading whitespaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20688
diff changeset
234 >
33721
24849d53697d tests: clean up many print statements to be print functions instead
Augie Fackler <augie@google.com>
parents: 32293
diff changeset
235 > print(_("concatenating " " by " " space %s" % v))
24849d53697d tests: clean up many print statements to be print functions instead
Augie Fackler <augie@google.com>
parents: 32293
diff changeset
236 > print(_("concatenating " + " by " + " '+' %s" % v))
21097
e8ef59b351c3 check-code: detect "% inside _()" when there are leading whitespaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20688
diff changeset
237 >
33721
24849d53697d tests: clean up many print statements to be print functions instead
Augie Fackler <augie@google.com>
parents: 32293
diff changeset
238 > print(_("mapping operation in different line %s"
24849d53697d tests: clean up many print statements to be print functions instead
Augie Fackler <augie@google.com>
parents: 32293
diff changeset
239 > % v))
21097
e8ef59b351c3 check-code: detect "% inside _()" when there are leading whitespaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20688
diff changeset
240 >
33721
24849d53697d tests: clean up many print statements to be print functions instead
Augie Fackler <augie@google.com>
parents: 32293
diff changeset
241 > print(_(
24849d53697d tests: clean up many print statements to be print functions instead
Augie Fackler <augie@google.com>
parents: 32293
diff changeset
242 > "leading spaces inside of '(' %s" % v))
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
243 > NO_CHECK_EOF
21097
e8ef59b351c3 check-code: detect "% inside _()" when there are leading whitespaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20688
diff changeset
244 $ "$check_code" ./map-inside-gettext.py
e8ef59b351c3 check-code: detect "% inside _()" when there are leading whitespaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20688
diff changeset
245 ./map-inside-gettext.py:1:
33721
24849d53697d tests: clean up many print statements to be print functions instead
Augie Fackler <augie@google.com>
parents: 32293
diff changeset
246 > print(_("map inside gettext %s" % v))
21097
e8ef59b351c3 check-code: detect "% inside _()" when there are leading whitespaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20688
diff changeset
247 don't use % inside _()
e8ef59b351c3 check-code: detect "% inside _()" when there are leading whitespaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20688
diff changeset
248 ./map-inside-gettext.py:3:
33721
24849d53697d tests: clean up many print statements to be print functions instead
Augie Fackler <augie@google.com>
parents: 32293
diff changeset
249 > print(_("concatenating " " by " " space %s" % v))
21097
e8ef59b351c3 check-code: detect "% inside _()" when there are leading whitespaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20688
diff changeset
250 don't use % inside _()
e8ef59b351c3 check-code: detect "% inside _()" when there are leading whitespaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20688
diff changeset
251 ./map-inside-gettext.py:4:
33721
24849d53697d tests: clean up many print statements to be print functions instead
Augie Fackler <augie@google.com>
parents: 32293
diff changeset
252 > print(_("concatenating " + " by " + " '+' %s" % v))
21097
e8ef59b351c3 check-code: detect "% inside _()" when there are leading whitespaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20688
diff changeset
253 don't use % inside _()
e8ef59b351c3 check-code: detect "% inside _()" when there are leading whitespaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20688
diff changeset
254 ./map-inside-gettext.py:6:
33721
24849d53697d tests: clean up many print statements to be print functions instead
Augie Fackler <augie@google.com>
parents: 32293
diff changeset
255 > print(_("mapping operation in different line %s"
21097
e8ef59b351c3 check-code: detect "% inside _()" when there are leading whitespaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20688
diff changeset
256 don't use % inside _()
e8ef59b351c3 check-code: detect "% inside _()" when there are leading whitespaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20688
diff changeset
257 ./map-inside-gettext.py:9:
33721
24849d53697d tests: clean up many print statements to be print functions instead
Augie Fackler <augie@google.com>
parents: 32293
diff changeset
258 > print(_(
21097
e8ef59b351c3 check-code: detect "% inside _()" when there are leading whitespaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20688
diff changeset
259 don't use % inside _()
e8ef59b351c3 check-code: detect "% inside _()" when there are leading whitespaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20688
diff changeset
260 [1]
21487
c26464ce0781 check-code: check for consistent usage of the websub filter in hgweb templates
Steven Brown <StevenGBrown@gmail.com>
parents: 21097
diff changeset
261
c26464ce0781 check-code: check for consistent usage of the websub filter in hgweb templates
Steven Brown <StevenGBrown@gmail.com>
parents: 21097
diff changeset
262 web templates
c26464ce0781 check-code: check for consistent usage of the websub filter in hgweb templates
Steven Brown <StevenGBrown@gmail.com>
parents: 21097
diff changeset
263
c26464ce0781 check-code: check for consistent usage of the websub filter in hgweb templates
Steven Brown <StevenGBrown@gmail.com>
parents: 21097
diff changeset
264 $ mkdir -p mercurial/templates
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
265 $ cat > mercurial/templates/example.tmpl <<NO_CHECK_EOF
21487
c26464ce0781 check-code: check for consistent usage of the websub filter in hgweb templates
Steven Brown <StevenGBrown@gmail.com>
parents: 21097
diff changeset
266 > {desc}
c26464ce0781 check-code: check for consistent usage of the websub filter in hgweb templates
Steven Brown <StevenGBrown@gmail.com>
parents: 21097
diff changeset
267 > {desc|escape}
c26464ce0781 check-code: check for consistent usage of the websub filter in hgweb templates
Steven Brown <StevenGBrown@gmail.com>
parents: 21097
diff changeset
268 > {desc|firstline}
c26464ce0781 check-code: check for consistent usage of the websub filter in hgweb templates
Steven Brown <StevenGBrown@gmail.com>
parents: 21097
diff changeset
269 > {desc|websub}
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
270 > NO_CHECK_EOF
21487
c26464ce0781 check-code: check for consistent usage of the websub filter in hgweb templates
Steven Brown <StevenGBrown@gmail.com>
parents: 21097
diff changeset
271
c26464ce0781 check-code: check for consistent usage of the websub filter in hgweb templates
Steven Brown <StevenGBrown@gmail.com>
parents: 21097
diff changeset
272 $ "$check_code" --warnings mercurial/templates/example.tmpl
c26464ce0781 check-code: check for consistent usage of the websub filter in hgweb templates
Steven Brown <StevenGBrown@gmail.com>
parents: 21097
diff changeset
273 mercurial/templates/example.tmpl:2:
c26464ce0781 check-code: check for consistent usage of the websub filter in hgweb templates
Steven Brown <StevenGBrown@gmail.com>
parents: 21097
diff changeset
274 > {desc|escape}
c26464ce0781 check-code: check for consistent usage of the websub filter in hgweb templates
Steven Brown <StevenGBrown@gmail.com>
parents: 21097
diff changeset
275 warning: follow desc keyword with either firstline or websub
c26464ce0781 check-code: check for consistent usage of the websub filter in hgweb templates
Steven Brown <StevenGBrown@gmail.com>
parents: 21097
diff changeset
276 [1]
29276
4dd530df4742 check-code: replace quoted characters correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28594
diff changeset
277
4dd530df4742 check-code: replace quoted characters correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28594
diff changeset
278 'string join across lines with no space' detection
4dd530df4742 check-code: replace quoted characters correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28594
diff changeset
279
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
280 $ cat > stringjoin.py <<NO_CHECK_EOF
29276
4dd530df4742 check-code: replace quoted characters correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28594
diff changeset
281 > foo = (' foo'
4dd530df4742 check-code: replace quoted characters correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28594
diff changeset
282 > 'bar foo.'
4dd530df4742 check-code: replace quoted characters correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28594
diff changeset
283 > 'bar foo:'
4dd530df4742 check-code: replace quoted characters correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28594
diff changeset
284 > 'bar foo@'
29279
438caf194160 check-code: make repquote distinguish more characters for exact detection
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29276
diff changeset
285 > 'bar foo%'
438caf194160 check-code: make repquote distinguish more characters for exact detection
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29276
diff changeset
286 > 'bar foo*'
438caf194160 check-code: make repquote distinguish more characters for exact detection
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29276
diff changeset
287 > 'bar foo+'
438caf194160 check-code: make repquote distinguish more characters for exact detection
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29276
diff changeset
288 > 'bar foo-'
29276
4dd530df4742 check-code: replace quoted characters correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28594
diff changeset
289 > 'bar')
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
290 > NO_CHECK_EOF
29397
844f72885fb9 check-code: detect "missing _() in ui message" more exactly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29279
diff changeset
291
844f72885fb9 check-code: detect "missing _() in ui message" more exactly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29279
diff changeset
292 'missing _() in ui message' detection
844f72885fb9 check-code: detect "missing _() in ui message" more exactly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29279
diff changeset
293
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
294 $ cat > uigettext.py <<NO_CHECK_EOF
29397
844f72885fb9 check-code: detect "missing _() in ui message" more exactly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29279
diff changeset
295 > ui.status("% 10s %05d % -3.2f %*s %%"
844f72885fb9 check-code: detect "missing _() in ui message" more exactly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29279
diff changeset
296 > # this use '\\\\' instead of '\\', because the latter in
844f72885fb9 check-code: detect "missing _() in ui message" more exactly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29279
diff changeset
297 > # heredoc on shell becomes just '\'
844f72885fb9 check-code: detect "missing _() in ui message" more exactly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29279
diff changeset
298 > '\\\\ \n \t \0'
844f72885fb9 check-code: detect "missing _() in ui message" more exactly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29279
diff changeset
299 > """12345
844f72885fb9 check-code: detect "missing _() in ui message" more exactly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29279
diff changeset
300 > """
844f72885fb9 check-code: detect "missing _() in ui message" more exactly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29279
diff changeset
301 > '''.:*+-=
844f72885fb9 check-code: detect "missing _() in ui message" more exactly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29279
diff changeset
302 > ''' "%-6d \n 123456 .:*+-= foobar")
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
303 > NO_CHECK_EOF
29397
844f72885fb9 check-code: detect "missing _() in ui message" more exactly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29279
diff changeset
304
34384
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
305 superfluous pass
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
306
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
307 $ cat > superfluous_pass.py <<NO_CHECK_EOF
34384
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
308 > # correct examples
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
309 > if foo:
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
310 > pass
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
311 > else:
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
312 > # comment-only line means still need pass
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
313 > pass
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
314 > def nothing():
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
315 > pass
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
316 > class empty(object):
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
317 > pass
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
318 > if whatever:
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
319 > passvalue(value)
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
320 > # bad examples
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
321 > if foo:
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
322 > "foo"
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
323 > pass
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
324 > else: # trailing comment doesn't fool checker
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
325 > wat()
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
326 > pass
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
327 > def nothing():
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
328 > "docstring means no pass"
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
329 > pass
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
330 > class empty(object):
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
331 > """multiline
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
332 > docstring also
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
333 > means no pass"""
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
334 > pass
40094
ff47ba7a2903 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 35315
diff changeset
335 > NO_CHECK_EOF
34384
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
336
29398
2a54cf92c773 check-code: build translation table for repquote in global for efficiency
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29397
diff changeset
337 (Checking multiple invalid files at once examines whether caching
2a54cf92c773 check-code: build translation table for repquote in global for efficiency
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29397
diff changeset
338 translation table for repquote() works as expected or not. All files
2a54cf92c773 check-code: build translation table for repquote in global for efficiency
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29397
diff changeset
339 should break rules depending on result of repquote(), in this case)
2a54cf92c773 check-code: build translation table for repquote in global for efficiency
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29397
diff changeset
340
34384
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
341 $ "$check_code" stringjoin.py uigettext.py superfluous_pass.py
29276
4dd530df4742 check-code: replace quoted characters correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28594
diff changeset
342 stringjoin.py:1:
4dd530df4742 check-code: replace quoted characters correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28594
diff changeset
343 > foo = (' foo'
4dd530df4742 check-code: replace quoted characters correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28594
diff changeset
344 string join across lines with no space
4dd530df4742 check-code: replace quoted characters correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28594
diff changeset
345 stringjoin.py:2:
4dd530df4742 check-code: replace quoted characters correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28594
diff changeset
346 > 'bar foo.'
4dd530df4742 check-code: replace quoted characters correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28594
diff changeset
347 string join across lines with no space
4dd530df4742 check-code: replace quoted characters correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28594
diff changeset
348 stringjoin.py:3:
4dd530df4742 check-code: replace quoted characters correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28594
diff changeset
349 > 'bar foo:'
4dd530df4742 check-code: replace quoted characters correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28594
diff changeset
350 string join across lines with no space
4dd530df4742 check-code: replace quoted characters correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28594
diff changeset
351 stringjoin.py:4:
4dd530df4742 check-code: replace quoted characters correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28594
diff changeset
352 > 'bar foo@'
4dd530df4742 check-code: replace quoted characters correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28594
diff changeset
353 string join across lines with no space
29279
438caf194160 check-code: make repquote distinguish more characters for exact detection
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29276
diff changeset
354 stringjoin.py:5:
438caf194160 check-code: make repquote distinguish more characters for exact detection
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29276
diff changeset
355 > 'bar foo%'
438caf194160 check-code: make repquote distinguish more characters for exact detection
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29276
diff changeset
356 string join across lines with no space
438caf194160 check-code: make repquote distinguish more characters for exact detection
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29276
diff changeset
357 stringjoin.py:6:
438caf194160 check-code: make repquote distinguish more characters for exact detection
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29276
diff changeset
358 > 'bar foo*'
438caf194160 check-code: make repquote distinguish more characters for exact detection
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29276
diff changeset
359 string join across lines with no space
438caf194160 check-code: make repquote distinguish more characters for exact detection
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29276
diff changeset
360 stringjoin.py:7:
438caf194160 check-code: make repquote distinguish more characters for exact detection
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29276
diff changeset
361 > 'bar foo+'
438caf194160 check-code: make repquote distinguish more characters for exact detection
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29276
diff changeset
362 string join across lines with no space
438caf194160 check-code: make repquote distinguish more characters for exact detection
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29276
diff changeset
363 stringjoin.py:8:
438caf194160 check-code: make repquote distinguish more characters for exact detection
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29276
diff changeset
364 > 'bar foo-'
438caf194160 check-code: make repquote distinguish more characters for exact detection
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29276
diff changeset
365 string join across lines with no space
29397
844f72885fb9 check-code: detect "missing _() in ui message" more exactly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29279
diff changeset
366 uigettext.py:1:
844f72885fb9 check-code: detect "missing _() in ui message" more exactly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29279
diff changeset
367 > ui.status("% 10s %05d % -3.2f %*s %%"
844f72885fb9 check-code: detect "missing _() in ui message" more exactly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29279
diff changeset
368 missing _() in ui message (use () to hide false-positives)
34384
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
369 superfluous_pass.py:14:
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
370 > if foo:
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
371 omit superfluous pass
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
372 superfluous_pass.py:17:
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
373 > else: # trailing comment doesn't fool checker
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
374 omit superfluous pass
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
375 superfluous_pass.py:20:
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
376 > def nothing():
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
377 omit superfluous pass
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
378 superfluous_pass.py:23:
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
379 > class empty(object):
b52f22d9afa5 contrib: add a check to check-code to ban superfluous pass statements
Augie Fackler <augie@google.com>
parents: 33721
diff changeset
380 omit superfluous pass
29397
844f72885fb9 check-code: detect "missing _() in ui message" more exactly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 29279
diff changeset
381 [1]
41826
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
382
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
383 Check code fragments embedded in test script
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
384
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
385 $ cat > embedded-code.t <<NO_CHECK_EOF
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
386 > code fragment in doctest style
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
387 > >>> x = (1,2)
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
388 > ...
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
389 > ... x = (1,2)
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
390 >
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
391 > code fragment in heredoc style
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
392 > $ python <<EOF
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
393 > > x = (1,2)
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
394 > > EOF
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
395 >
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
396 > code fragment in file heredoc style
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
397 > $ python > file.py <<EOF
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
398 > > x = (1,2)
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
399 > > EOF
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
400 > NO_CHECK_EOF
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
401 $ "$check_code" embedded-code.t
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
402 embedded-code.t:2:
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
403 > x = (1,2)
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
404 missing whitespace after ,
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
405 embedded-code.t:4:
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
406 > x = (1,2)
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
407 missing whitespace after ,
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
408 embedded-code.t:8:
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
409 > x = (1,2)
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
410 missing whitespace after ,
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
411 embedded-code.t:13:
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
412 > x = (1,2)
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
413 missing whitespace after ,
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
414 [1]
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
415
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
416 "max warnings per file" is shared by all embedded code fragments
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
417
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
418 $ "$check_code" --per-file=3 embedded-code.t
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
419 embedded-code.t:2:
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
420 > x = (1,2)
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
421 missing whitespace after ,
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
422 embedded-code.t:4:
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
423 > x = (1,2)
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
424 missing whitespace after ,
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
425 embedded-code.t:8:
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
426 > x = (1,2)
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
427 missing whitespace after ,
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
428 (too many errors, giving up)
867883d454ea contrib: make check-code.py check code fragments embedded in test scripts
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 41761
diff changeset
429 [1]