Merge lp:~divmod-dev/divmod.org/848493-remove-epsilon-release into lp:divmod.org
- 848493-remove-epsilon-release
- Merge into trunk
Proposed by
Tristan Seligmann
Status: | Merged |
---|---|
Merged at revision: | 2725 |
Proposed branch: | lp:~divmod-dev/divmod.org/848493-remove-epsilon-release |
Merge into: | lp:divmod.org |
Diff against target: |
746 lines (+0/-732) 3 files modified
Epsilon/bin/release-divmod (+0/-5) Epsilon/epsilon/release.py (+0/-446) Epsilon/epsilon/test/test_release.py (+0/-281) |
To merge this branch: | bzr merge lp:~divmod-dev/divmod.org/848493-remove-epsilon-release |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Laurens Van Houtven | Approve | ||
Review via email: mp+178441@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === removed file 'Epsilon/bin/release-divmod' |
2 | --- Epsilon/bin/release-divmod 2007-09-25 12:21:26 +0000 |
3 | +++ Epsilon/bin/release-divmod 1970-01-01 00:00:00 +0000 |
4 | @@ -1,5 +0,0 @@ |
5 | -#!/usr/bin/python |
6 | -# Copyright 2007 Divmod, Inc. See LICENSE file for details |
7 | - |
8 | -from epsilon.release import main |
9 | -main() |
10 | |
11 | === removed file 'Epsilon/epsilon/release.py' |
12 | --- Epsilon/epsilon/release.py 2007-12-03 23:40:32 +0000 |
13 | +++ Epsilon/epsilon/release.py 1970-01-01 00:00:00 +0000 |
14 | @@ -1,446 +0,0 @@ |
15 | -# -*- test-case-name: epsilon.test.test_release -*- |
16 | - |
17 | -""" |
18 | -Automation for most of the release process for Divmod projects. |
19 | -""" |
20 | - |
21 | -import sys, re |
22 | -from os import chdir |
23 | - |
24 | -from twisted.python.reflect import namedModule |
25 | -from twisted.python.versions import Version |
26 | -from twisted.python.usage import Options |
27 | -from twisted.python.filepath import FilePath |
28 | -from twisted.python.release import sh, runChdirSafe |
29 | - |
30 | -from combinator.branchmgr import theBranchManager |
31 | -from epsilon.structlike import record |
32 | - |
33 | -class Project(record("name initPath package version")): |
34 | - """ |
35 | - Container for information about a particular Divmod project being released. |
36 | - |
37 | - @ivar name: The name of the project. |
38 | - @ivar initPath: A C{FilePath} to the Python package of the project. |
39 | - @ivar package: A module object, the package for this project. |
40 | - @ivar version: The current version of this project. |
41 | - """ |
42 | - |
43 | -verstringMatcher = re.compile(r"^([0-9]+)\.([0-9]+)\.([0-9]+)$") |
44 | - |
45 | - |
46 | -def replaceProjectVersion(filename, newversion): |
47 | - """ |
48 | - Write version specification code into the given filename, which |
49 | - sets the version to the given version number. |
50 | - |
51 | - @param filename: A filename which is most likely a "_version.py" |
52 | - under some Twisted project. |
53 | - @param newversion: A sequence of three numbers. |
54 | - """ |
55 | - f = open(filename, 'w') |
56 | - f.write('''\ |
57 | -# This is an auto-generated file. Use Epsilon/bin/release-divmod to update. |
58 | -from twisted.python import versions |
59 | -version = versions.Version(__name__[:__name__.rfind('.')], %s, %s, %s) |
60 | -''' % tuple(newversion)) |
61 | - f.close() |
62 | - |
63 | - |
64 | - |
65 | -def namesToPaths(projectNames, verbose=True): |
66 | - """ |
67 | - Turn names of projects into project objects. |
68 | - |
69 | - @type projectNames: C{list} of C{str} |
70 | - @param projectNames: The names of Python packages in each project to find |
71 | - and for which to create a L{Project} instance. |
72 | - |
73 | - @type verbose: C{bool} |
74 | - @param verbose: If true, report some information about what happens to |
75 | - stdout. |
76 | - |
77 | - @rtype: C{list} of L{Project} |
78 | - @return: Project instances for each package in C{projectNames}, with |
79 | - C{name}, C{initPath}, and C{package} set. |
80 | - """ |
81 | - projectObjects = [] |
82 | - for projName in projectNames: |
83 | - for pfx in '', 'x': |
84 | - try: |
85 | - projPackage = namedModule(pfx + projName) |
86 | - except ImportError: |
87 | - pass |
88 | - else: |
89 | - projPackagePath = FilePath(projPackage.__file__) |
90 | - break |
91 | - else: |
92 | - raise SystemExit("Failed to find Python package for %s." |
93 | - % (projName,)) |
94 | - |
95 | - realName = projPackagePath.parent().parent().basename() |
96 | - projectObjects.append(Project(name=realName, |
97 | - initPath=projPackagePath, |
98 | - package=projPackage, |
99 | - version=None)) |
100 | - if verbose: |
101 | - print 'Found', projName, 'as', realName, 'at', projPackagePath.path |
102 | - return projectObjects |
103 | - |
104 | - |
105 | - |
106 | -def inputNewVersionWithDefault(proj, raw_input=raw_input): |
107 | - """ |
108 | - Ask the user to input a new version number for the given project. Default |
109 | - to the top version in NEWS.txt. |
110 | - |
111 | - @type proj: L{Project} |
112 | - @param proj: The project for which to get a version. |
113 | - |
114 | - @rtype: L{tuple} of C{int} |
115 | - @return: A three-tuple giving the new major, minor, and micro version. |
116 | - """ |
117 | - news = proj.initPath.parent().parent().child("NEWS.txt") |
118 | - if news.exists(): |
119 | - f = news.open() |
120 | - defaultVersionString = f.read(16).strip().split(' ')[0] |
121 | - else: |
122 | - defaultVersionString = '0.1.0' |
123 | - match = None |
124 | - while match is None: |
125 | - new_vers = (raw_input("New version for %s (default %s)? " |
126 | - % (proj.name, defaultVersionString))) |
127 | - if not new_vers: |
128 | - new_vers = defaultVersionString |
129 | - match = verstringMatcher.match(new_vers) |
130 | - if match is None: |
131 | - print 'Invalid format. Use e.g. 2.0.0.' |
132 | - |
133 | - major, minor, micro = map(int, match.groups()) |
134 | - return major, minor, micro |
135 | - |
136 | - |
137 | - |
138 | -def updateVersionFiles(projectObjects, verbose=True, |
139 | - inputNewVersionWithDefault=inputNewVersionWithDefault, |
140 | - replaceProjectVersion=replaceProjectVersion): |
141 | - """ |
142 | - Gather version information and change _version.py files to contain new |
143 | - version number. |
144 | - |
145 | - @type projectObjects: C{list} of L{Project} instances |
146 | - @param projectObjects: The projects which will have their version |
147 | - information updated. |
148 | - |
149 | - @type verbose: C{bool} |
150 | - @param verbose: If true, report some information about what happens to |
151 | - stdout. |
152 | - """ |
153 | - for proj in projectObjects: |
154 | - projVersion = inputNewVersionWithDefault(proj) |
155 | - if projVersion is None: |
156 | - projVersion = proj.package.version |
157 | - projVersion = (projVersion.major, projVersion.minor, |
158 | - projVersion.micro) |
159 | - projVersionFilePath = proj.initPath.sibling('_version.py') |
160 | - replaceProjectVersion( |
161 | - projVersionFilePath.path, |
162 | - projVersion) |
163 | - proj.version = Version(proj.name, *projVersion) |
164 | - if verbose: |
165 | - print 'Updated version in', projVersionFilePath.path |
166 | - |
167 | - |
168 | - |
169 | -def doCommit(rootPath, prompt, msg, sh=sh): |
170 | - """ |
171 | - Commit version files and probably NEWS.txt files to version control. |
172 | - |
173 | - @type rootPath: L{FilePath} |
174 | - @param rootPath: The root path to commit to version control. |
175 | - |
176 | - @type prompt: C{bool} |
177 | - @param prompt: If true, ask the user before executing any shell commands. |
178 | - |
179 | - @type msg: C{str} |
180 | - @param msg: Version control commit message. |
181 | - """ |
182 | - cmd = 'svn commit %(rootPath)s -m "%(msg)s"' |
183 | - sh(cmd % {'rootPath': rootPath.path, 'msg': msg}, |
184 | - null=False, |
185 | - prompt=prompt) |
186 | - |
187 | - |
188 | - |
189 | -def doExport(projectName, rootPath, prompt, theBranchManager=theBranchManager, sh=sh): |
190 | - """ |
191 | - Export the repo from SVN into a clean directory. |
192 | - |
193 | - @type projectName: C{str} |
194 | - @param projectName: The Combinator name of the project to export. |
195 | - |
196 | - @type rootPath: L{FilePath} |
197 | - @param rootPath: The working copy of the SVN path to export. |
198 | - |
199 | - @type prompt: C{bool} |
200 | - @param prompt: If true, ask the user before executing any shell commands. |
201 | - |
202 | - @rtype: C{tuple} of L{FilePath} and C{str} |
203 | - @return: The path to which the export was done and the URI which was |
204 | - exported. |
205 | - """ |
206 | - branchRelativePath = theBranchManager.currentBranchFor(projectName) |
207 | - branchURI = theBranchManager.projectBranchURI( |
208 | - projectName, branchRelativePath) |
209 | - exportPath = FilePath('.release').temporarySibling() |
210 | - cmd = 'svn export -rHEAD %(rootPath)s %(exportPath)s' |
211 | - sh(cmd % {'rootPath': rootPath.path, 'exportPath': exportPath.path}, |
212 | - null=False, |
213 | - prompt=prompt) |
214 | - return exportPath, branchURI |
215 | - |
216 | - |
217 | - |
218 | -def doSourceDist(projectObjects, exportPath, prompt, sh=sh, chdir=chdir): |
219 | - """ |
220 | - Create tarballs with distutils for each project. |
221 | - |
222 | - @type projectObjects: C{list} of L{Project} instances |
223 | - @param projectObjects: The projects for which to create tarballs. |
224 | - |
225 | - @type exportPath: L{FilePath} |
226 | - @param exportPath: The directory which contains svn exports of all of the |
227 | - projects to operate on. |
228 | - |
229 | - @type prompt: C{bool} |
230 | - @param prompt: If true, ask the user before executing any shell commands. |
231 | - """ |
232 | - for proj in projectObjects: |
233 | - def makeSourceRelease(): |
234 | - chdir(exportPath.child(proj.name).path) |
235 | - cmd = '%(python)s setup.py sdist' |
236 | - sh(cmd % {'python': sys.executable}, |
237 | - null=False, |
238 | - prompt=prompt) |
239 | - |
240 | - runChdirSafe(makeSourceRelease) |
241 | - |
242 | - |
243 | - |
244 | -def doSourceUnpack(projectObjects, exportPath, prompt, sh=sh, chdir=chdir): |
245 | - """ |
246 | - Unpack source tarballs for projects. |
247 | - |
248 | - @type projectObjects: C{list} of L{Project} instances |
249 | - @param projectObjects: The projects for which to unpack tarballs. |
250 | - |
251 | - @type exportPath: L{FilePath} |
252 | - @param exportPath: The directory which contains svn exports of all of the |
253 | - projects to operate on. These should have previously had tarballs |
254 | - created for them with L{doSourceDist}. |
255 | - |
256 | - @type prompt: C{bool} |
257 | - @param prompt: If true, ask the user before executing any shell commands. |
258 | - """ |
259 | - for proj in projectObjects: |
260 | - def unpackSourceRelease(): |
261 | - projectExport = exportPath.child(proj.name) |
262 | - chdir(projectExport.child('dist').path) |
263 | - cmd = 'tar xzf %(projectName)s-%(projectVersion)s.tar.gz' |
264 | - sh(cmd % {'projectName': proj.name, |
265 | - 'projectVersion': proj.version.short()}, |
266 | - null=False, |
267 | - prompt=prompt) |
268 | - |
269 | - runChdirSafe(unpackSourceRelease) |
270 | - |
271 | - |
272 | - |
273 | -def doInstall(projectObjects, exportPath, prompt, sh=sh, chdir=chdir): |
274 | - """ |
275 | - Run distutils installation for each project. |
276 | - |
277 | - @type projectObjects: C{list} of L{Project} instances |
278 | - @param projectObjects: The projects to install. |
279 | - |
280 | - @type exportPath: L{FilePath} |
281 | - @param exportPath: The directory which contains svn exports of all of the |
282 | - projects to operate on. These should have previously had tarballs |
283 | - created and unpacked with L{doSourceDist} and L{doSourceUnpack}. |
284 | - |
285 | - @type prompt: C{bool} |
286 | - @param prompt: If true, ask the user before executing any shell commands. |
287 | - |
288 | - @rtype: L{FilePath} |
289 | - @return: The installation prefix path. |
290 | - """ |
291 | - installPath = FilePath('.install').temporarySibling() |
292 | - for proj in projectObjects: |
293 | - def installSourceRelease(): |
294 | - projectExport = exportPath.child(proj.name) |
295 | - projectDir = '%s-%s' % (proj.name, proj.version.short()) |
296 | - unpackPath = projectExport.child('dist').child(projectDir) |
297 | - chdir(unpackPath.path) |
298 | - cmd = '%(python)s setup.py install --prefix %(installPath)s' |
299 | - sh(cmd % {'python': sys.executable, |
300 | - 'installPath': installPath.path}, |
301 | - null=False, |
302 | - prompt=prompt) |
303 | - |
304 | - runChdirSafe(installSourceRelease) |
305 | - return installPath |
306 | - |
307 | - |
308 | - |
309 | -def runTests(projectObjects, installPath, prompt, sh=sh): |
310 | - """ |
311 | - Run unit tests for each project. |
312 | - |
313 | - @type projectObjects: C{list} of L{Project} instances |
314 | - @param projectObjects: The projects for which to run tests. |
315 | - |
316 | - @type installPath: L{FilePath} |
317 | - @param installPath: The installation prefix path which contains the |
318 | - packages for which to run tests. |
319 | - |
320 | - @type prompt: C{bool} |
321 | - @param prompt: If true, ask the user before executing any shell commands. |
322 | - """ |
323 | - # distutils.sysconfig.get_python_lib(prefix=...) might be more appropriate |
324 | - libPath = installPath.child('lib') |
325 | - pythonPath = libPath.child('python%d.%d' % sys.version_info[:2]) |
326 | - siteInstallPath = pythonPath.child('site-packages') |
327 | - for proj in projectObjects: |
328 | - def testSourceInstall(): |
329 | - cmd = 'PYTHONPATH=%(installPath)s:$PYTHONPATH trial %(projectName)s' |
330 | - sh(cmd % {'installPath': siteInstallPath.path, |
331 | - 'projectName': proj.initPath.parent().basename()}, |
332 | - null=False, |
333 | - prompt=prompt) |
334 | - |
335 | - runChdirSafe(testSourceInstall) |
336 | - |
337 | - |
338 | - |
339 | -def makeTags(projectObjects, repo, branchURI, prompt, sh=sh): |
340 | - """ |
341 | - Make SVN tags for the code in these projects. |
342 | - |
343 | - @type projectObjects: C{list} of L{Project} instances |
344 | - @param projectObjects: The projects for which to make tags. |
345 | - |
346 | - @type repo: C{str} |
347 | - @param repo: The segment of the repository URI immediately before the |
348 | - {trunk,branches,tags} segment. |
349 | - |
350 | - @type branchURI: C{str} |
351 | - @param branchURI: The URI of the branch for which to create a tag. |
352 | - |
353 | - @type prompt: C{bool} |
354 | - @param prompt: If true, ask the user before executing any shell commands. |
355 | - """ |
356 | - #XXX Maybe this should be a parameter too? |
357 | - tagRootURI = 'svn+ssh://divmod.org/svn/%s/tags/releases' % (repo,) |
358 | - for proj in projectObjects: |
359 | - def tagRelease(): |
360 | - source = '%(branchURI)s/%(projectName)s' |
361 | - dest = '%(tagRootURI)s/%(projectName)s-%(projectVersion)s' |
362 | - cmd = 'svn cp %s %s -m "Tagging release"' % (source, dest) |
363 | - sh(cmd % {'branchURI': branchURI, |
364 | - 'projectName': proj.name, |
365 | - 'tagRootURI': tagRootURI, |
366 | - 'projectVersion': proj.version.short()}, |
367 | - null=False, |
368 | - prompt=prompt) |
369 | - |
370 | - runChdirSafe(tagRelease) |
371 | - |
372 | - |
373 | - |
374 | -def collectTarballs(projectObjects, exportPath, releasePath): |
375 | - """ |
376 | - Collect tarballs in the releases/ directory. |
377 | - |
378 | - @type projectObjects: C{list} of L{Project} instances |
379 | - @param projectObjects: The projects for which to make tags. |
380 | - |
381 | - @type exportPath: L{FilePath} |
382 | - @param exportPath: The directory which contains release tarballs previously |
383 | - generated with L{doSourceDist}. |
384 | - |
385 | - @type releasePath: L{FilePath} |
386 | - @param releasePath: A directory which will have a I{releases} subdirectory |
387 | - added to it (if one does not already exist) into which the tarballs |
388 | - will be moved. |
389 | - """ |
390 | - releasePath = releasePath.child('releases') |
391 | - if not releasePath.isdir(): |
392 | - releasePath.makedirs() |
393 | - |
394 | - for proj in projectObjects: |
395 | - def collectTarball(): |
396 | - projectExport = exportPath.child(proj.name) |
397 | - releaseFile = '%s-%s.tar.gz' % (proj.name, |
398 | - proj.version.short()) |
399 | - projectPath = projectExport.child('dist').child(releaseFile) |
400 | - projectPath.moveTo(releasePath.child(releaseFile)) |
401 | - runChdirSafe(collectTarball) |
402 | - |
403 | - |
404 | - |
405 | -def release(rootPath, repo, projectNames, prompt): |
406 | - """ |
407 | - Prompt for new versions of the indicated projects and re-write their |
408 | - version information. |
409 | - |
410 | - @type rootPath: L{FilePath} |
411 | - @param rootPath: The root of the working copy from which to release. |
412 | - |
413 | - @param projectNames: A C{list} of C{str} which name Python modules for |
414 | - projects in the Divmod repository. |
415 | - """ |
416 | - if not projectNames: |
417 | - raise SystemExit("Specify some package names to release.") |
418 | - |
419 | - projectObjects = namesToPaths(projectNames) |
420 | - updateVersionFiles(projectObjects) |
421 | - |
422 | - doCommit(rootPath, prompt, "Version updates for release") |
423 | - exportPath, branchURI = doExport(repo, rootPath, prompt) |
424 | - |
425 | - doSourceDist(projectObjects, exportPath, prompt) |
426 | - doSourceUnpack(projectObjects, exportPath, prompt) |
427 | - installPath = doInstall(projectObjects, exportPath, prompt) |
428 | - |
429 | - runTests(projectObjects, installPath, prompt) |
430 | - makeTags(projectObjects, repo, branchURI, prompt) |
431 | - collectTarballs(projectObjects, exportPath, FilePath('.')) |
432 | - |
433 | - |
434 | - |
435 | -class ReleaseOptions(Options): |
436 | - optParameters = [['project', 'P', 'Divmod', |
437 | - 'The Combinator-managed project name in which to find ' |
438 | - 'the packages being released.']] |
439 | - |
440 | - def parseArgs(self, *packages): |
441 | - self['packageNames'] = packages |
442 | - |
443 | - |
444 | - |
445 | -def main(): |
446 | - """ |
447 | - Parse options from C{sys.argv} and perform a release based on them. |
448 | - |
449 | - The working directory of the process in which this is called should be the |
450 | - base of a working copy of the release branch which is being used to |
451 | - generate the release. |
452 | - |
453 | - Version files for packages being released will be updated and committed, a |
454 | - tag will be created, release tarballs will be generated using distutils, |
455 | - and the results will be unpacked, installed, and have their unit tests run |
456 | - using trial. |
457 | - """ |
458 | - o = ReleaseOptions() |
459 | - o.parseOptions(sys.argv[1:]) |
460 | - release(FilePath('.'), o['project'], o['packageNames'], True) |
461 | |
462 | === removed file 'Epsilon/epsilon/test/test_release.py' |
463 | --- Epsilon/epsilon/test/test_release.py 2007-12-03 23:40:32 +0000 |
464 | +++ Epsilon/epsilon/test/test_release.py 1970-01-01 00:00:00 +0000 |
465 | @@ -1,281 +0,0 @@ |
466 | -""" |
467 | -Tests for Divmod package-release automation. |
468 | -""" |
469 | -from sys import executable, version_info |
470 | - |
471 | -from twisted.trial.unittest import TestCase |
472 | -from twisted.python.versions import Version |
473 | -from twisted.python.filepath import FilePath |
474 | - |
475 | -import epsilon |
476 | - |
477 | -from epsilon.release import ( |
478 | - namesToPaths, inputNewVersionWithDefault, updateVersionFiles, doCommit, |
479 | - doExport, doSourceDist, doSourceUnpack, doInstall, runTests, makeTags, |
480 | - collectTarballs, replaceProjectVersion, Project) |
481 | - |
482 | - |
483 | -class ReleaseTests(TestCase): |
484 | - """ |
485 | - Tests for Divmod package-release automation. |
486 | - """ |
487 | - def setUp(self): |
488 | - self.currentDirectory = None |
489 | - self.commands = [] |
490 | - |
491 | - def test_replaceProjectVersion(self): |
492 | - """ |
493 | - Test that replaceProjectVersion generates a _version.py correctly. |
494 | - """ |
495 | - f = self.mktemp() |
496 | - replaceProjectVersion(f, (7,8,9)) |
497 | - self.assertEqual(open(f).read(), """\ |
498 | -# This is an auto-generated file. Use Epsilon/bin/release-divmod to update. |
499 | -from twisted.python import versions |
500 | -version = versions.Version(__name__[:__name__.rfind('.')], 7, 8, 9) |
501 | -""") |
502 | - |
503 | - def test_namesToPaths(self): |
504 | - """ |
505 | - Test that package names get resolved to the correct paths. |
506 | - """ |
507 | - project = namesToPaths(["epsilon"], False)[0] |
508 | - self.assertEqual(project.name, "Epsilon") |
509 | - self.assertEqual(project.initPath.path, epsilon.__file__) |
510 | - self.assertEqual(project.package, epsilon) |
511 | - |
512 | - |
513 | - def test_inputNewVersionWithDefault(self): |
514 | - """ |
515 | - L{inputNewVersionWithDefault} should prompt for a new version number, |
516 | - using C{raw_input}, finding the current version number in a I{NEWS.txt} |
517 | - file in the grandparent of the C{initPath} of the project it is passed |
518 | - and supplying that as a default. |
519 | - """ |
520 | - projectPath = FilePath(self.mktemp()).child('FakeProject') |
521 | - projectPath.makedirs() |
522 | - projectPath.child('NEWS.txt').setContent('0.9.99') |
523 | - |
524 | - packagePath = projectPath.child('fakeproject') |
525 | - initPath = packagePath.child('__init__.py') |
526 | - project = Project(name="FakeProject", initPath=initPath, |
527 | - package=None, version=None) |
528 | - |
529 | - def checkPrompt(prompt): |
530 | - self.assertEqual(prompt, "New version for FakeProject (default 0.9.99)? ") |
531 | - return "" |
532 | - |
533 | - self.assertEqual( |
534 | - inputNewVersionWithDefault(project, raw_input=checkPrompt), |
535 | - (0, 9, 99)) |
536 | - self.assertEqual( |
537 | - inputNewVersionWithDefault(project, raw_input=lambda _: "6.7.89"), |
538 | - (6, 7, 89)) |
539 | - |
540 | - |
541 | - def test_updateVersionFiles(self): |
542 | - """ |
543 | - C{updateVersionFiles} should rewrite I{_version.py} for the packages of |
544 | - the projects it is passed so that they include new version information, |
545 | - as provided by repeated calls to L{inputNewVersionWithDefault}. |
546 | - """ |
547 | - initPath = FilePath(self.mktemp()) |
548 | - project = Project(name="Epsilon", initPath=initPath, |
549 | - package=None, version=None) |
550 | - def checkReplaceVersion(path, version): |
551 | - self.assertEqual(path, initPath.sibling("_version.py").path) |
552 | - |
553 | - updateVersionFiles( |
554 | - [project], False, |
555 | - inputNewVersionWithDefault=lambda _: (4, 5, 6), |
556 | - replaceProjectVersion=checkReplaceVersion) |
557 | - |
558 | - self.assertEqual(project.version.package, "Epsilon") |
559 | - self.assertEqual(project.version.major, 4) |
560 | - self.assertEqual(project.version.minor, 5) |
561 | - self.assertEqual(project.version.micro, 6) |
562 | - |
563 | - |
564 | - def test_doCommit(self): |
565 | - """ |
566 | - C{doCommit} should execute a shell command which does an svn commit on |
567 | - the given path with the given commit message. |
568 | - """ |
569 | - commands = [] |
570 | - def fakeShell(cmd, null, prompt): |
571 | - commands.append((cmd, null, prompt)) |
572 | - def checkSVNCommand(cmd, null, prompt): |
573 | - self.assertEqual(cmd, |
574 | - 'svn commit /test/path -m "a great commit"') |
575 | - doCommit(FilePath("/test/path"), |
576 | - False, "a great commit", |
577 | - sh=fakeShell) |
578 | - self.assertEqual( |
579 | - commands, |
580 | - [('svn commit /test/path -m "a great commit"', False, False)]) |
581 | - |
582 | - |
583 | - def test_doExport(self): |
584 | - """ |
585 | - C{doExport} should execute a shell command which does an svn export of |
586 | - the current branch of the indicated project to the given path. |
587 | - """ |
588 | - currentLookups = [] |
589 | - branchLookups = [] |
590 | - class FakeBranchManager: |
591 | - def currentBranchFor(self, repo): |
592 | - currentLookups.append(repo) |
593 | - return "branch-1" |
594 | - |
595 | - def projectBranchURI(self, repo, relpath): |
596 | - branchLookups.append((repo, relpath)) |
597 | - return "http://branch/uri/" |
598 | - |
599 | - commands = [] |
600 | - def fakeShell(cmd, null, prompt): |
601 | - commands.append((cmd, null, prompt)) |
602 | - |
603 | - exportPath, branchURI = doExport( |
604 | - 'Divmod', FilePath("/test/path"), False, |
605 | - theBranchManager=FakeBranchManager(), |
606 | - sh=fakeShell) |
607 | - self.assertEqual(currentLookups, ["Divmod"]) |
608 | - self.assertEqual(branchLookups, [("Divmod", "branch-1")]) |
609 | - self.assertEqual(branchURI, "http://branch/uri/") |
610 | - self.assertEqual( |
611 | - commands, |
612 | - [('svn export -rHEAD /test/path ' + exportPath.path, |
613 | - False, False)]) |
614 | - |
615 | - |
616 | - def fakeChdir(self, path): |
617 | - # This is a very dumb implementation of chdir |
618 | - if path.startswith('/'): |
619 | - self.currentDirectory = path |
620 | - else: |
621 | - raise NotImplementedError("Sorry - path logic too difficult.") |
622 | - |
623 | - |
624 | - def fakeShell(self, command, null, prompt): |
625 | - self.commands.append((self.currentDirectory, command, null, prompt)) |
626 | - |
627 | - |
628 | - def test_doSourceDist(self): |
629 | - """ |
630 | - C{doSourceDist} should execute a shell command which runs the I{sdist} |
631 | - subcommand of the I{setup.py} for each project given. |
632 | - """ |
633 | - project = Project(name="Foo", initPath=FilePath(self.mktemp()), |
634 | - package=None, version=None) |
635 | - doSourceDist( |
636 | - [project], FilePath("/test/path"), False, |
637 | - sh=self.fakeShell, chdir=self.fakeChdir) |
638 | - |
639 | - self.assertEqual( |
640 | - self.commands, |
641 | - [("/test/path/Foo", |
642 | - executable + " setup.py sdist", False, False)]) |
643 | - |
644 | - |
645 | - def test_doSourceUnpack(self): |
646 | - """ |
647 | - C{doSourceUnpack} should execute a shell command which runs an untar |
648 | - command on the release tarball for the given projects. It should run |
649 | - each command in the dist directory of the corresponding project. |
650 | - """ |
651 | - project = Project(name="Foo", initPath=FilePath(self.mktemp()), |
652 | - version=Version("Foo", 1, 2, 3), package=None) |
653 | - |
654 | - doSourceUnpack( |
655 | - [project], FilePath("/test/path"), False, |
656 | - sh=self.fakeShell, chdir=self.fakeChdir) |
657 | - |
658 | - self.assertEqual( |
659 | - self.commands, |
660 | - [("/test/path/Foo/dist", |
661 | - "tar xzf Foo-1.2.3.tar.gz", False, False)]) |
662 | - |
663 | - |
664 | - def test_doInstall(self): |
665 | - """ |
666 | - C{doInstall} should execute a shell command which runs the I{install} |
667 | - subcommand of the I{setup.py} for each project given. It should run |
668 | - each command in the unpacked source directory of each project. |
669 | - """ |
670 | - project = Project(name="Foo", initPath=FilePath(self.mktemp()), |
671 | - version=Version("Foo", 1, 2, 3), package=None) |
672 | - |
673 | - installedPath = doInstall( |
674 | - [project], FilePath("/test/path"), False, |
675 | - sh=self.fakeShell, chdir=self.fakeChdir) |
676 | - |
677 | - self.assertEqual( |
678 | - self.commands, |
679 | - [("/test/path/Foo/dist/Foo-1.2.3", |
680 | - executable + " setup.py install --prefix " + installedPath.path, |
681 | - False, False)]) |
682 | - |
683 | - |
684 | - def test_runTests(self): |
685 | - """ |
686 | - C{runTests} should execute a shell command which runs the unit tests |
687 | - for all of the given projects. |
688 | - """ |
689 | - prefix = "/test/path/lib/python%d.%d/site-packages" % version_info[:2] |
690 | - initPath = FilePath(prefix).child("foo").child("__init__.py") |
691 | - runTests( |
692 | - [Project(name="Foo", initPath=initPath, |
693 | - package=None, version=None)], |
694 | - FilePath("/test/path"), False, |
695 | - sh=self.fakeShell) |
696 | - |
697 | - path = [prefix, '$PYTHONPATH'] |
698 | - self.assertEqual( |
699 | - self.commands, |
700 | - [(None, |
701 | - "PYTHONPATH=" + ":".join(path) + " trial foo", |
702 | - False, False)]) |
703 | - |
704 | - |
705 | - def test_makeTags(self): |
706 | - """ |
707 | - C{makeTags} should execute a shell command which creates a release tag |
708 | - of the given release branch for each given project. |
709 | - """ |
710 | - project = Project(name="Foo", initPath=self.mktemp(), |
711 | - version=Version("Foo", 1, 2, 3), package=None) |
712 | - makeTags( |
713 | - [project], "Stuff", |
714 | - "svn+ssh://divmod.org/svn/Stuff/branches/release-1", |
715 | - False, |
716 | - sh=self.fakeShell) |
717 | - |
718 | - self.assertEqual( |
719 | - self.commands, |
720 | - [(None, |
721 | - "svn cp svn+ssh://divmod.org/svn/Stuff/branches/release-1/Foo " |
722 | - "svn+ssh://divmod.org/svn/Stuff/tags/releases/Foo-1.2.3 " |
723 | - '-m "Tagging release"', False, False)]) |
724 | - |
725 | - |
726 | - def test_collectTarballs(self): |
727 | - """ |
728 | - C{collectTarballs} should move the release tarball for each given |
729 | - project into a directory named I{releases} of the current working |
730 | - directory. |
731 | - """ |
732 | - moves = [] |
733 | - class FakeFilePath(FilePath): |
734 | - def moveTo(self, target): |
735 | - moves.append((self, target)) |
736 | - FakeFilePath.clonePath = FakeFilePath |
737 | - project = Project(name="Foo", initPath=FakeFilePath(self.mktemp()), |
738 | - version=Version("Foo", 1, 2, 3), package=None) |
739 | - releasePath = FilePath(self.mktemp()) |
740 | - collectTarballs([project], FakeFilePath("/test/path"), releasePath) |
741 | - self.assertEqual( |
742 | - moves, |
743 | - [(FilePath('/test/path/Foo/dist/Foo-1.2.3.tar.gz'), |
744 | - releasePath.child('releases').child('Foo-1.2.3.tar.gz'))]) |
745 | - |
746 | - |
LGTM, merging.