[PATCH 1 of 6] add a small test for contrib/check-code.py

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Tue Mar 16 13:54:27 CDT 2010


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1268765575 -3600
# Branch stable
# Node ID f273bb861993c68dce35048e09549e5222b66f0b
# Parent  cfc89fecfe51b21cb26c08268ae64acd2bb0c856
add a small test for contrib/check-code.py

This changeset adds a test file for contrib/check-code.py. This test runs
check-code.py against two small files. The first file should not raise any
check-code.py error while the second should. A line contains multiple errors to
verify the check-code.py behaviour:  In the case of multiple errors at the same
line, the context line should only be displayed once.

diff --git a/tests/test-check-code b/tests/test-check-code
new file mode 100755
--- /dev/null
+++ b/tests/test-check-code
@@ -0,0 +1,16 @@
+#!/bin/sh
+#cd `dirname $0`
+cat > correct.py <<EOF
+def toto(arg1, arg2):
+    del arg2
+    return (5 + 6, 9)
+EOF
+
+cat > wrong.py <<EOF
+def toto( arg1, arg2):
+    del(arg2)
+    return ( 5+6, 9)
+EOF
+
+check_code=`dirname $0`/../contrib/check-code.py
+${check_code} ./wrong.py ./correct.py
diff --git a/tests/test-check-code.out b/tests/test-check-code.out
new file mode 100644
--- /dev/null
+++ b/tests/test-check-code.out
@@ -0,0 +1,10 @@
+./wrong.py:1:
+ > def toto( arg1, arg2):
+ gratuitous whitespace in () or []
+./wrong.py:2:
+ >     del(arg2)
+ del isn't a function
+./wrong.py:3:
+ >     return ( 5+6, 9)
+ missing whitespace in expression
+ gratuitous whitespace in () or []


More information about the Mercurial-devel mailing list