tests/test-check-code.t
author Patrick Mezard <pmezard@gmail.com>
Sat, 22 Jan 2011 16:15:40 +0100
branchstable
changeset 13287 d0e0d3d43e14
parent 12632 6c98107f787e
child 13026 53391819f195
permissions -rw-r--r--
subrepo: compare svn subrepo state to last committed revision A subversion project revisions are a subset of the repository revisions, you can ask subversion to update a working directory from one revision to another without changing anything. Unfortunately, Mercurial will think the subrepository has changed and will commit it again. To avoid useless commits, we compare the subrepository state to its actual "parent" revision. To ensure ascending compatibility with existing subrepositories which might reference fake revisions, we also keep comparing with the subrepo working directory revision. NOTE: not sure if this should go in stable or not.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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]