Merge lp:~hlaf/mockproc/windows_support into lp:mockproc

Proposed by Henrique Lindgren
Status: Needs review
Proposed branch: lp:~hlaf/mockproc/windows_support
Merge into: lp:mockproc
Diff against target: 200 lines (+95/-7)
10 files modified
.bzrignore (+2/-0)
.eclipse/run_configurations/mockproc tests.launch (+20/-0)
.project (+46/-0)
.pydevproject (+8/-0)
MANIFEST.in (+1/-0)
mockproc/__init__.py (+1/-1)
mockproc/mockprocess.py (+12/-3)
requirements-test.txt (+2/-0)
setup.py (+1/-0)
tox.ini (+2/-3)
To merge this branch: bzr merge lp:~hlaf/mockproc/windows_support
Reviewer Review Type Date Requested Status
Mike C. Fletcher Pending
Review via email: mp+376476@code.launchpad.net

Commit message

Add support for using MockProc on Windows

Description of the change

Made MockProc fully compatible with Windows by leveraging functionality available in the cx-Freeze module.

The feature was added without changing the current Linux/Unix implementation or API, for which reason the existing test bench runs successfully, and with no modification, against this branch, for both Linux and Windows.

To post a comment you must log in.

Unmerged revisions

31. By hlaf

Make sure the Python interpreter that executes the mock scripts is the same as that running mockproc

30. By hlaf

Update the Eclipse project resource filters

29. By hlaf

Update the Eclipse project's Python interpreter name

28. By hlaf

Use a requirements-test.txt file

27. By hlaf

Update the .bzrignore file

26. By hlaf

Add an Eclipse run configuration for tests

25. By hlaf

Add Eclipse project files

24. By hlaf

Fix test dependencies

23. By hlaf

Add cx-Freeze to the module dependencies (Windows-only)

22. By hlaf

Bump version number

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2012-01-19 03:44:26 +0000
3+++ .bzrignore 2019-12-06 17:51:31 +0000
4@@ -5,3 +5,5 @@
5 *.egg-info
6 doc/_build/*
7 doc/_build
8+.tox
9+.venv
10
11=== added directory '.eclipse'
12=== added directory '.eclipse/run_configurations'
13=== added file '.eclipse/run_configurations/mockproc tests.launch'
14--- .eclipse/run_configurations/mockproc tests.launch 1970-01-01 00:00:00 +0000
15+++ .eclipse/run_configurations/mockproc tests.launch 2019-12-06 17:51:31 +0000
16@@ -0,0 +1,20 @@
17+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
18+<launchConfiguration type="org.python.pydev.debug.unittestLaunchConfigurationType">
19+<stringAttribute key="LAUNCH_CONFIG_OVERRIDE_PYUNIT_RUN_PARAMS" value=""/>
20+<booleanAttribute key="LAUNCH_CONFIG_OVERRIDE_PYUNIT_RUN_PARAMS_CHOICE" value="true"/>
21+<intAttribute key="LAUNCH_CONFIG_OVERRIDE_TEST_RUNNER" value="1"/>
22+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
23+<listEntry value="/mockproc/test"/>
24+</listAttribute>
25+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
26+<listEntry value="2"/>
27+</listAttribute>
28+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:mockproc/test}"/>
29+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_OTHER_WORKING_DIRECTORY" value="${workspace_loc:mockproc}"/>
30+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value=""/>
31+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:mockproc}"/>
32+<stringAttribute key="org.python.pydev.debug.ATTR_INTERPRETER" value="__default"/>
33+<stringAttribute key="org.python.pydev.debug.ATTR_PROJECT" value="mockproc"/>
34+<intAttribute key="org.python.pydev.debug.ATTR_RESOURCE_TYPE" value="2"/>
35+<stringAttribute key="process_factory_id" value="org.python.pydev.debug.processfactory.PyProcessFactory"/>
36+</launchConfiguration>
37
38=== added file '.project'
39--- .project 1970-01-01 00:00:00 +0000
40+++ .project 2019-12-06 17:51:31 +0000
41@@ -0,0 +1,46 @@
42+<?xml version="1.0" encoding="UTF-8"?>
43+<projectDescription>
44+ <name>mockproc</name>
45+ <comment></comment>
46+ <projects>
47+ </projects>
48+ <buildSpec>
49+ <buildCommand>
50+ <name>org.python.pydev.PyDevBuilder</name>
51+ <arguments>
52+ </arguments>
53+ </buildCommand>
54+ </buildSpec>
55+ <natures>
56+ <nature>org.python.pydev.pythonNature</nature>
57+ </natures>
58+ <filteredResources>
59+ <filter>
60+ <id>1574868799166</id>
61+ <name></name>
62+ <type>10</type>
63+ <matcher>
64+ <id>org.eclipse.ui.ide.multiFilter</id>
65+ <arguments>1.0-name-matches-true-false-*.egg-info</arguments>
66+ </matcher>
67+ </filter>
68+ <filter>
69+ <id>1574868799172</id>
70+ <name></name>
71+ <type>10</type>
72+ <matcher>
73+ <id>org.eclipse.ui.ide.multiFilter</id>
74+ <arguments>1.0-name-matches-true-false-.venv*</arguments>
75+ </matcher>
76+ </filter>
77+ <filter>
78+ <id>1574868799179</id>
79+ <name></name>
80+ <type>10</type>
81+ <matcher>
82+ <id>org.eclipse.ui.ide.multiFilter</id>
83+ <arguments>1.0-name-matches-true-false-.tox</arguments>
84+ </matcher>
85+ </filter>
86+ </filteredResources>
87+</projectDescription>
88
89=== added file '.pydevproject'
90--- .pydevproject 1970-01-01 00:00:00 +0000
91+++ .pydevproject 2019-12-06 17:51:31 +0000
92@@ -0,0 +1,8 @@
93+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
94+<?eclipse-pydev version="1.0"?><pydev_project>
95+<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">py27_mockproc</pydev_property>
96+<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
97+<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
98+<path>/${PROJECT_DIR_NAME}</path>
99+</pydev_pathproperty>
100+</pydev_project>
101
102=== modified file 'MANIFEST.in'
103--- MANIFEST.in 2012-01-19 03:47:48 +0000
104+++ MANIFEST.in 2019-12-06 17:51:31 +0000
105@@ -2,3 +2,4 @@
106 include doc/Makefile
107 include doc/*.py
108 include tests/*.py
109+include *.txt
110
111=== modified file 'mockproc/__init__.py'
112--- mockproc/__init__.py 2016-08-30 15:46:35 +0000
113+++ mockproc/__init__.py 2019-12-06 17:51:31 +0000
114@@ -1,3 +1,3 @@
115 """Package for the mockproc test fixture"""
116 from mockproc.mockprocess import *
117-__version__ = '0.3.1'
118+__version__ = '0.3.2'
119
120=== modified file 'mockproc/mockprocess.py'
121--- mockproc/mockprocess.py 2016-08-30 15:43:35 +0000
122+++ mockproc/mockprocess.py 2019-12-06 17:51:31 +0000
123@@ -1,5 +1,7 @@
124 from __future__ import absolute_import
125-import os,tempfile,shutil,logging
126+import os,platform,sys,tempfile,shutil,logging
127+if platform.system() == 'Windows':
128+ import cx_Freeze
129 log = logging.getLogger( __name__ )
130
131 __all__ = ('MockProc',)
132@@ -48,12 +50,19 @@
133 exit = __exit__
134 def write_script( self, description ):
135 if not description.get('script'):
136+ description['python_interpreter'] = sys.executable
137 description['script'] = self.script_template % description
138 description['filename'] = filename = os.path.join( self.bindir, description['executable'] )
139 fh = open( filename, 'w' )
140 fh.write( description['script'] )
141 fh.close()
142 os.chmod( filename,0o755 )
143+ if platform.system() == 'Windows':
144+ executables = [cx_Freeze.Executable(filename)]
145+ freezer = cx_Freeze.Freezer(executables,
146+ targetDir = self.bindir,
147+ silent=True)
148+ freezer.Freeze()
149 return filename
150 def delete_script( self, description ):
151 try:
152@@ -127,7 +136,7 @@
153 self.write_script( scripts[-1] )
154 return script
155
156- script_template = """#! /usr/bin/env python
157+ script_template = """#! %(python_interpreter)s
158
159 # mocked implementation of %(executable)s
160
161@@ -139,4 +148,4 @@
162 if stderr:
163 sys.stderr.write( stderr )
164 sys.exit( %(returncode)s )
165-"""
166+"""
167
168=== added file 'requirements-test.txt'
169--- requirements-test.txt 1970-01-01 00:00:00 +0000
170+++ requirements-test.txt 2019-12-06 17:51:31 +0000
171@@ -0,0 +1,2 @@
172+globalsub
173+nose
174
175=== modified file 'setup.py'
176--- setup.py 2012-01-18 23:36:57 +0000
177+++ setup.py 2019-12-06 17:51:31 +0000
178@@ -31,6 +31,7 @@
179 author = "Mike C. Fletcher",
180 author_email = "mcfletch@vrplumber.com",
181 install_requires = [
182+ 'cx-Freeze == 5.1.1 ; platform_system=="Windows"',
183 ],
184 license = "BSD",
185 package_dir = {
186
187=== modified file 'tox.ini'
188--- tox.ini 2016-08-29 19:39:41 +0000
189+++ tox.ini 2019-12-06 17:51:31 +0000
190@@ -3,9 +3,8 @@
191 skip_missing_interpreters=True
192 [testenv]
193 usedevelop=True
194-deps=
195- ../globalsub
196- nose
197+deps =
198+ -rrequirements-test.txt
199 commands=
200 python -m "nose" {posargs}
201

Subscribers

People subscribed via source and target branches