[pypy-svn] r75253 - in pypy/build/bot2/pypybuildbot: . test

fijal at codespeak.net fijal at codespeak.net
Fri Jun 11 01:57:11 CEST 2010


Author: fijal
Date: Fri Jun 11 01:57:09 2010
New Revision: 75253

Modified:
   pypy/build/bot2/pypybuildbot/builds.py
   pypy/build/bot2/pypybuildbot/test/test_builds.py
Log:
An attempt to upload files into branch-related directories


Modified: pypy/build/bot2/pypybuildbot/builds.py
==============================================================================
--- pypy/build/bot2/pypybuildbot/builds.py	(original)
+++ pypy/build/bot2/pypybuildbot/builds.py	Fri Jun 11 01:57:09 2010
@@ -1,5 +1,5 @@
 from buildbot.process import factory
-from buildbot.steps import source, shell, transfer
+from buildbot.steps import source, shell, transfer, master
 from buildbot.status.builder import SUCCESS
 from buildbot.process.properties import WithProperties
 import os
@@ -12,6 +12,21 @@
             return self.describe(True) + ['aborted']
         return shell.ShellCommand.getText(self, cmd, results)
 
+class PyPyUpload(transfer.FileUpload):
+    parms = transfer.FileUpload.parms + ['basename']
+    
+    def start(self):
+        properties = self.build.getProperties()
+        branch = properties['branch']
+        if branch is None:
+            branch = 'trunk'
+        masterdest = properties.render(self.masterdest)
+        masterdest = os.path.expanduser(masterdest)
+        masterdest = os.path.join(masterdest, branch)
+        os.makedirs(masterdest)
+        masterdest = os.path.join(masterdest, self.basename)
+        self.masterdest = masterdest
+        transfer.FileUpload.start(self)
 
 class Translate(ShellCmd):
     name = "translate"
@@ -127,12 +142,14 @@
                 kind = 'stackless'
             else:
                 kind = 'nojit'
-        nightly = os.path.expanduser('~/nightly/pypy-c-' + kind + '-%(got_revision)s-' + platform + '.bz2')        
+        nightly = '~/nightly/'
+        name = 'pypy-c-' + kind + '-%(got_revision)s-' + platform + '.bz2'
         pypy_c_rel = 'build/pypy/translator/goal/pypy-c.bz2'
-        self.addStep(transfer.FileUpload(slavesrc=pypy_c_rel,
-                                         masterdest=WithProperties(nightly),
-                                         workdir='.',
-                                         blocksize=100*1024))
+        self.addStep(PyPyUpload(slavesrc=pypy_c_rel,
+                                masterdest=WithProperties(nightly),
+                                basename=name,
+                                workdir='.',
+                                blocksize=100*1024))
 
 
 class JITBenchmark(factory.BuildFactory):

Modified: pypy/build/bot2/pypybuildbot/test/test_builds.py
==============================================================================
--- pypy/build/bot2/pypybuildbot/test/test_builds.py	(original)
+++ pypy/build/bot2/pypybuildbot/test/test_builds.py	Fri Jun 11 01:57:09 2010
@@ -1,6 +1,11 @@
+import py
 from pypybuildbot import builds
 
 class FakeProperties(object):
+    def __getitem__(self, item):
+        if item == 'branch':
+            return None
+    
     def render(self, x):
         return x
 
@@ -10,6 +15,19 @@
     def getProperties(self):
         return FakeProperties()
 
+    def getSlaveCommandVersion(self, *args):
+        return 3
+
+class FakeStepStatus(object):
+    def setText(self, *args):
+        pass
+
+class FakeDeferred(object):
+    def addCallback(self, *args):
+        return FakeDeferred()
+    def addErrback(self, *args):
+        return FakeDeferred()
+
 def test_Translate():
     expected = ['translate.py', '--batch', '-O0',
                 'targetpypystandalone', '--no-allworkingmodules']
@@ -26,3 +44,16 @@
     rebuiltTranslate.build = FakePropertyBuilder()
     rebuiltTranslate.startCommand = lambda *args: None
     rebuiltTranslate.start()
+
+def test_pypy_upload():
+    pth = py.test.ensuretemp('buildbot')
+    inst = builds.PyPyUpload(slavesrc='slavesrc', masterdest=str(pth.join('mstr')),
+                             basename='base', workdir='.',
+                             blocksize=100)
+    factory, kw = inst.factory
+    rebuilt = factory(**kw)
+    rebuilt.build = FakePropertyBuilder()
+    rebuilt.step_status = FakeStepStatus()
+    rebuilt.runCommand = lambda *args: FakeDeferred()
+    rebuilt.start()
+    assert pth.join('mstr').check(dir=True)



More information about the Pypy-commit mailing list