##// END OF EJS Templates
check-code: more tests and more robust python filtering
Benoit Boissinot -
r10727:62b8f156 default
parent child Browse files
Show More
@@ -14,6 +14,12 b' def repquote(m):'
14 t = re.sub(r"[^\sx]", "o", t)
14 t = re.sub(r"[^\sx]", "o", t)
15 return m.group('quote') + t + m.group('quote')
15 return m.group('quote') + t + m.group('quote')
16
16
17 def reppython(m):
18 comment = m.group('comment')
19 if comment:
20 return "#" * len(comment)
21 return repquote(m)
22
17 def repcomment(m):
23 def repcomment(m):
18 return m.group(1) + "#" * len(m.group(2))
24 return m.group(1) + "#" * len(m.group(2))
19
25
@@ -96,10 +102,10 b' pypats = ['
96 ]
102 ]
97
103
98 pyfilters = [
104 pyfilters = [
99 (r"""(?msx)(?P<quote>('''|\"\"\"|(?<!')'(?!')|(?<!")"(?!")))
105 (r"""(?msx)(?P<comment>\#.*?$)|
100 (?P<text>(.*?))
106 ((?P<quote>('''|\"\"\"|(?<!')'(?!')|(?<!")"(?!")))
101 (?<!\\)(?P=quote)""", repquote),
107 (?P<text>(([^\\]|\\.)*?))
102 (r"( *)(#([^\n]*\S)?)", repcomment),
108 (?P=quote))""", reppython),
103 ]
109 ]
104
110
105 cpats = [
111 cpats = [
@@ -13,11 +13,13 b' def toto( arg1, arg2):'
13 EOF
13 EOF
14
14
15 cat > quote.py <<EOF
15 cat > quote.py <<EOF
16 # let's use quote in comments
16 (''' ( 4x5 )
17 (''' ( 4x5 )
17 but """\''' and finally''',
18 but """\\''' and finally''',
18 """let's fool checkpatch""", '1+2',
19 """let's fool checkpatch""", '1+2',
19 '"""', 42+1, """and
20 '"""', 42+1, """and
20 ( 4-1 ) """, "( 1+1 )\" and ")
21 ( 4-1 ) """, "( 1+1 )\" and ")
22 a, '\\\\\\\\', "\\\\\\" x-2", "c-1"
21 EOF
23 EOF
22
24
23 check_code=`dirname $0`/../contrib/check-code.py
25 check_code=`dirname $0`/../contrib/check-code.py
@@ -8,6 +8,6 b''
8 > return ( 5+6, 9)
8 > return ( 5+6, 9)
9 missing whitespace in expression
9 missing whitespace in expression
10 gratuitous whitespace in () or []
10 gratuitous whitespace in () or []
11 ./quote.py:4:
11 ./quote.py:5:
12 > '"""', 42+1, """and
12 > '"""', 42+1, """and
13 missing whitespace in expression
13 missing whitespace in expression
General Comments 0
You need to be logged in to leave comments. Login now