author | Javi Merino <cibervicho@gmail.com> |
Tue, 01 Feb 2011 07:29:11 +0000 | |
branch | stable |
changeset 13330 | 551856dea9a6 |
parent 12632 | 6c98107f787e |
child 13026 | 53391819f195 |
permissions | -rw-r--r-- |
12632
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
1 |
$ cat > correct.py <<EOF |
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) |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
5 |
> EOF |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
6 |
$ cat > wrong.py <<EOF |
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) |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
10 |
> EOF |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
11 |
$ cat > quote.py <<EOF |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
12 |
> # let's use quote in comments |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
13 |
> (''' ( 4x5 ) |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
14 |
> but """\\''' and finally''', |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
15 |
> """let's fool checkpatch""", '1+2', |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
16 |
> '"""', 42+1, """and |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
17 |
> ( 4-1 ) """, "( 1+1 )\" and ") |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
18 |
> a, '\\\\\\\\', "\\\\\\" x-2", "c-1" |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
19 |
> EOF |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
20 |
$ cat > non-py24.py <<EOF |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
21 |
> # Using builtins that does not exist in Python 2.4 |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
22 |
> if any(): |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
23 |
> x = all() |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
24 |
> y = format(x) |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
25 |
> |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
26 |
> # Do not complain about our own definition |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
27 |
> def any(x): |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
28 |
> pass |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
29 |
> EOF |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
30 |
$ check_code="$TESTDIR"/../contrib/check-code.py |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
31 |
$ "$check_code" ./wrong.py ./correct.py ./quote.py ./non-py24.py |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
32 |
./wrong.py:1: |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
33 |
> def toto( arg1, arg2): |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
34 |
gratuitous whitespace in () or [] |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
35 |
./wrong.py:2: |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
36 |
> del(arg2) |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
37 |
del isn't a function |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
38 |
./wrong.py:3: |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
39 |
> return ( 5+6, 9) |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
40 |
missing whitespace in expression |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
41 |
gratuitous whitespace in () or [] |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
42 |
./quote.py:5: |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
43 |
> '"""', 42+1, """and |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
44 |
missing whitespace in expression |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
45 |
./non-py24.py:2: |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
46 |
> if any(): |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
47 |
any/all/format not available in Python 2.4 |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
48 |
./non-py24.py:3: |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
49 |
> x = all() |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
50 |
any/all/format not available in Python 2.4 |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
51 |
./non-py24.py:4: |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
52 |
> y = format(x) |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
53 |
any/all/format not available in Python 2.4 |
6c98107f787e
tests: unify test-check-code
Brodie Rao <brodie@bitheap.org>
parents:
11822
diff
changeset
|
54 |
[1] |