Merge lp:~vds/desktopcouch/check_lint into lp:desktopcouch

Proposed by Vincenzo Di Somma
Status: Merged
Approved by: dobey
Approved revision: 191
Merged at revision: 193
Proposed branch: lp:~vds/desktopcouch/check_lint
Merge into: lp:desktopcouch
Diff against target: 102 lines (+69/-3)
2 files modified
runtests.py (+9/-3)
utilities/lint.sh (+60/-0)
To merge this branch: bzr merge lp:~vds/desktopcouch/check_lint
Reviewer Review Type Date Requested Status
Manuel de la Peña (community) Approve
Eric Casteleijn (community) Approve
Review via email: mp+39812@code.launchpad.net

Commit message

Add script to lint check changed modules.

Description of the change

Add script to lint check changed modules.

To post a comment you must log in.
Revision history for this message
Eric Casteleijn (thisfred) wrote :

Awesome!

review: Approve
Revision history for this message
Manuel de la Peña (mandel) wrote :

+1

review: Approve
Revision history for this message
dobey (dobey) wrote :

Attempt to merge into lp:desktopcouch failed due to conflicts:

text conflict in runtests.py

Revision history for this message
dobey (dobey) wrote :

Attempt to merge into lp:desktopcouch failed due to conflicts:

text conflict in runtests.py

Revision history for this message
dobey (dobey) wrote :

Instead of adding Yet Another Script In Yet Another Project, can we just call u1lint instead? It's in ubuntuone-dev-tools.

Revision history for this message
dobey (dobey) wrote :

Attempt to merge into lp:desktopcouch failed due to conflicts:

text conflict in runtests.py

lp:~vds/desktopcouch/check_lint updated
191. By Vincenzo Di Somma

conflict solved

Revision history for this message
Vincenzo Di Somma (vds) wrote :

ubuntuone-dev-tools is in maverick but not in any previous version.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'runtests.py'
2--- runtests.py 2010-11-01 14:50:06 +0000
3+++ runtests.py 2010-11-02 19:01:43 +0000
4@@ -1,23 +1,29 @@
5 #!/usr/bin/python
6
7-import os, sys
8+"""Run all tests of the module"""
9+
10+import os, sys
11 from twisted.trial import runner, itrial, reporter
12-from desktopcouch.platform import set_application_name
13
14 dir, filename = os.path.split(__file__)
15 sys.path.insert(0, os.path.realpath(dir))
16
17 def get_test_suite():
18+ """Load the test suite"""
19 loader = runner.TestLoader()
20 return loader.loadByNames(['desktopcouch'], True)
21
22 def run():
23+ """Run all the tests"""
24 test_runner = runner.TrialRunner(reporter.TreeReporter)
25 test_result = test_runner.run(get_test_suite())
26 return test_result.wasSuccessful()
27
28 if __name__ == '__main__':
29+ import subprocess
30+ from desktopcouch.platform import set_application_name
31+
32 set_application_name("desktopcouch test runner")
33-
34 ret = run()
35+ subprocess.call(["utilities/lint.sh", ""], shell=True)
36 sys.exit(not ret)
37
38=== added directory 'utilities'
39=== added file 'utilities/lint.sh'
40--- utilities/lint.sh 1970-01-01 00:00:00 +0000
41+++ utilities/lint.sh 2010-11-02 19:01:43 +0000
42@@ -0,0 +1,60 @@
43+#!/bin/bash
44+
45+echo ""
46+echo ""
47+echo "Pylint started!"
48+echo ""
49+
50+bzr diff > /dev/null
51+diff_status=$?
52+if [ $diff_status -eq 0 ] ; then
53+ # No uncommitted changes in the tree, lint changes relative to the
54+ # parent.
55+ rev=`bzr info | sed '/parent branch:/!d; s/ *parent branch: /ancestor:/'`
56+ rev_option="-r $rev"
57+elif [ $diff_status -eq 1 ] ; then
58+ # Uncommitted changes in the tree, lint those changes.
59+ rev_option=""
60+else
61+ # bzr diff failed
62+ exit 1
63+fi
64+files=`bzr st --short $rev_option | sed '/^.[MN]/!d; s/.* //'`
65+
66+if [ -z "$files" ]; then
67+ echo ""
68+ echo "No changed files detected."
69+ echo ""
70+ exit 0
71+else
72+ echo ""
73+ echo "Linting changed files:"
74+ for file in $files; do
75+ echo " $file"
76+ done
77+ echo ""
78+fi
79+
80+
81+if [ -z "$files" ]; then
82+ exit $EXIT
83+fi
84+
85+
86+export PYTHONPATH="/usr/share/pycentral/pylint/site-packages:desktopcouch:$PYTHONPATH"
87+pyfiles=`echo "$files" | egrep '.py'`
88+pylint="`which pylint` -r n"
89+
90+pylint_notices=`$pylint $pyfiles`
91+
92+if [ ! -z "$pylint_notices" ]; then
93+ echo ""
94+ echo ""
95+ echo "== Pylint notices =="
96+ echo "$pylint_notices"
97+ echo ""
98+ echo ""
99+ EXIT=1
100+fi
101+
102+exit $EXIT

Subscribers

People subscribed via source and target branches