Merge lp:~mikemc/ubuntuone-storage-protocol/fix-run-tests into lp:ubuntuone-storage-protocol

Proposed by Mike McCracken on 2012-08-07
Status: Merged
Approved by: Mike McCracken on 2012-08-15
Approved revision: 160
Merged at revision: 152
Proposed branch: lp:~mikemc/ubuntuone-storage-protocol/fix-run-tests
Merge into: lp:ubuntuone-storage-protocol
Diff against target: 139 lines (+99/-10)
3 files modified
run-tests (+8/-3)
run-tests.bat (+82/-0)
tests/test_context.py (+9/-7)
To merge this branch: bzr merge lp:~mikemc/ubuntuone-storage-protocol/fix-run-tests
Reviewer Review Type Date Requested Status
dobey (community) Approve on 2012-08-15
Alejandro J. Cura (community) 2012-08-07 Approve on 2012-08-07
Eric Casteleijn (community) Approve on 2012-08-07
Review via email: mp+118488@code.launchpad.net

Commit Message

- Make tests run on darwin and windows. (LP: #1033823)

Description of the Change

- Make tests run on darwin and windows. (LP: #1033823)

With this change, the tests pass on darwin and windows.
We only use the python-native version of protobuf on the client platforms, so we skip the cpp version in the tests.

All tests still pass on linux with this change.

This also fixes a path assumption in get_certificates in test_context.py that failed if TRIAL_TEMP_DIR is set to e.g. /tmp or C:/temp-test.

To post a comment you must log in.
Alejandro J. Cura (alecu) wrote :

Looks good

review: Approve
Eric Casteleijn (thisfred) wrote :

+1

Eric Casteleijn (thisfred) :
review: Approve
Alejandro J. Cura (alecu) wrote :

After the changes, it looks good, and all tests pass on the three platforms.

review: Approve
dobey (dobey) wrote :

10 +if [ "$SYSNAME" == "Darwin" ]; then
11 + u1trial="python $u1trial"
12 + u1lint="python $u1lint"
13 +else
14 + u1trial=u1trial
15 + u1lint="/usr/bin/env USE_PYFLAKES=1 u1lint"
16 +fi
17 +

I think we need to do 'export USE_PYFLAKES=1' outside the if/else here, as we really need to use pyflakes on all platforms here. It seems you also need a SET USE_PYFLAKES=1 in the run-tests.bat here.

I'm surprised that the u1lint passed on OSX or Windows in this branch. We are using pyflakes due to problems with the way pylint fails to handle some of the class structure of twisted.

review: Needs Fixing
157. By Mike McCracken on 2012-08-10

Remove env vars due to formerly broken buildout

Mike McCracken (mikemc) wrote :

Changed to use pyflakes on darwin, and remove references to env vars set to work around broken buildout, which is now fixed in https://code.launchpad.net/~mikemc/ubuntuone-windows-installer/improve-buildout/+merge/119195

158. By Mike McCracken on 2012-08-10

Add back SYSNAME so we skip cpp tests

Mike McCracken (mikemc) wrote :

with rev 158 , tests pass on darwin with no pyflakes complaints.

159. By Mike McCracken on 2012-08-15

use pyflakes on windows

160. By Mike McCracken on 2012-08-15

exclude generated protobuf code from pep8 check

Mike McCracken (mikemc) wrote :

with rev 159 windows uses pyflakes , and with 160 pep8 is happy.

dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'run-tests'
2--- run-tests 2012-04-20 23:21:10 +0000
3+++ run-tests 2012-08-15 18:10:24 +0000
4@@ -15,13 +15,18 @@
5 # along with this program. If not, see <http://www.gnu.org/licenses/>.
6 set -e
7
8+SYSNAME=`uname -s`
9+
10 /usr/bin/env python setup.py build
11 # run the tests with pure python protobuf
12 PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python u1trial tests
13-# and with the cpp extension
14-PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp u1trial tests
15+if [ "$SYSNAME" != "Darwin" ]; then
16+ # and with the cpp extension, for server (linux) only:
17+ PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp u1trial tests
18+fi
19+
20 USE_PYFLAKES=1 u1lint
21 /usr/bin/env python setup.py clean
22 rm -rf build
23-pep8 --repeat .
24+pep8 --repeat --exclude="*_pb2.py" .
25 rm -rf _trial_temp
26
27=== added file 'run-tests.bat'
28--- run-tests.bat 1970-01-01 00:00:00 +0000
29+++ run-tests.bat 2012-08-15 18:10:24 +0000
30@@ -0,0 +1,82 @@
31+:: Copyright 2012 Canonical Ltd.
32+::
33+:: This program is free software: you can redistribute it and/or modify it
34+:: under the terms of the GNU General Public License version 3, as published
35+:: by the Free Software Foundation.
36+::
37+:: This program is distributed in the hope that it will be useful, but
38+:: WITHOUT ANY WARRANTY; without even the implied warranties of
39+:: MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
40+:: PURPOSE. See the GNU General Public License for more details.
41+::
42+:: You should have received a copy of the GNU General Public License along
43+:: with this program. If not, see <http://www.gnu.org/licenses/>.
44+
45+@ECHO off
46+
47+SET MODULE="tests"
48+SET PYTHONEXEPATH=""
49+SET IGNORE_PATHS="ubuntuone\controlpanel\dbustests"
50+SET IGNORE_MODULES="test_linux.py, test_darwin.py"
51+SET PYTHONPATH=%PYTHONPATH%;..\ubuntuone-dev-tools\;..\dirspec;.
52+
53+ECHO Checking for Python on the path
54+:: Look for Python from buildout
55+FOR %%A in (python.exe) do (SET PYTHONEXEPATH=%%~$PATH:A)
56+FOR %%B in (u1trial) do (SET TRIALPATH=%%~$PATH:B)
57+FOR %%C in (u1lint) do (SET LINTPATH=%%~$PATH:C)
58+FOR %%D in (pep8.exe) do (SET PEP8PATH=%%~$PATH:D)
59+
60+IF NOT "%PYTHONEXEPATH%" == "" GOTO :PYTHONPRESENT
61+ECHO Please ensure you have python installed
62+GOTO :END
63+
64+:PYTHONPRESENT
65+
66+:: throw the first parameter away if is /skip-lint,
67+:: the way we do this is to ensure that /skip-lint
68+:: is the first parameter and copy all the rest in a loop
69+:: the main reason for that is that %* is not affected
70+:: by SHIFT, that is, it allways have all passed parameters
71+
72+SET PARAMS=%*
73+SET SKIPLINT=0
74+IF "%1" == "/skip-lint" (
75+ SET SKIPLINT=1
76+ GOTO :CLEANPARAMS
77+)ELSE (
78+ GOTO :CONTINUEBATCH)
79+:CLEANPARAMS
80+
81+SHIFT
82+SET PARAMS=%1
83+:GETREST
84+SHIFT
85+if [%1]==[] (
86+ GOTO CONTINUEBATCH)
87+SET PARAMS=%PARAMS% %1
88+GOTO GETREST
89+:CONTINUEBATCH
90+
91+
92+"%PYTHONEXEPATH%" setup.py build
93+ECHO Running tests
94+:: execute the tests with a number of ignored linux only modules
95+"%PYTHONEXEPATH%" "%TRIALPATH%" -p %IGNORE_PATHS% -i %IGNORE_MODULES% %PARAMS% %MODULE%
96+
97+:: Clean the build from the setup.py
98+ECHO Cleaning the generated code
99+"%PYTHONEXEPATH%" setup.py clean
100+
101+IF %SKIPLINT% == 1 GOTO :CLEAN
102+ECHO Performing style checks...
103+SET USE_PYFLAKES=1
104+"%PYTHONEXEPATH%" "%LINTPATH%" "%MODULE%"
105+"%PEP8PATH%" --exclude ".svn,CVS,.bzr,.hg,.git,*_ui.py,*_rc.py,*_pb2.py" --repeat .
106+
107+:CLEAN
108+:: Delete the temp folders
109+IF "%TRIAL_TEMP_DIR%" == "" GOTO :TRIALTEMPEXISTS
110+IF EXIST _trial_temp RMDIR /s /q _trial_temp
111+:TRIALTEMPEXISTS
112+IF EXIST "%TRIAL_TEMP_DIR%" RMDIR /s /q "%TRIAL_TEMP_DIR%"
113
114=== modified file 'tests/test_context.py'
115--- tests/test_context.py 2012-06-11 17:26:14 +0000
116+++ tests/test_context.py 2012-08-15 18:10:24 +0000
117@@ -123,13 +123,15 @@
118
119 def get_certificates(self):
120 """Get the uninstalled certificates, for testing."""
121- ca_1 = ssl.Certificate.loadPEM(file(os.path.abspath(os.path.join(
122- os.pardir, os.pardir, 'data',
123- 'UbuntuOne-Go_Daddy_Class_2_CA.pem')), 'r').read())
124- ca_2 = ssl.Certificate.loadPEM(file(os.path.abspath(os.path.join(
125- os.pardir, os.pardir, 'data',
126- 'UbuntuOne-Go_Daddy_CA.pem')), 'r').read())
127- return [ca_1.original, ca_2.original]
128+ certs = []
129+ data_dir = os.path.join(os.path.dirname(__file__), os.pardir, 'data')
130+ for certname in ['UbuntuOne-Go_Daddy_Class_2_CA.pem',
131+ 'UbuntuOne-Go_Daddy_CA.pem']:
132+ cert_path = os.path.abspath(os.path.join(data_dir, certname))
133+ c = ssl.Certificate.loadPEM(file(cert_path, 'r').read())
134+ certs.append(c.original)
135+
136+ return certs
137
138 @defer.inlineCallbacks
139 def verify_context(self, server_context, client_context):

Subscribers

People subscribed via source and target branches