[Buildbot-commits] buildbot/buildbot/test test_properties.py, 1.18, 1.19

Brian Warner warner at users.sourceforge.net
Mon May 26 23:52:15 UTC 2008


Update of /cvsroot/buildbot/buildbot/buildbot/test
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv22179/buildbot/test

Modified Files:
	test_properties.py 
Log Message:
[project @ #232:setproperty-step.patch]
A buildstep that is similar to ShellCommand, except that it captures
the output of the command into a property.

Original author: dustin at v.igoro.us
Date: 2008-05-15 22:22:08+00:00

Index: test_properties.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_properties.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- test_properties.py	22 May 2008 22:13:17 -0000	1.18
+++ test_properties.py	26 May 2008 23:52:13 -0000	1.19
@@ -202,5 +202,65 @@
         d.addCallback(_check_touch)
         return d
 
+    SetProperty_base_config = """
+from buildbot.process import factory
+from buildbot.steps.shell import ShellCommand, SetProperty, WithProperties
+from buildbot.buildslave import BuildSlave
+s = factory.s
+
+BuildmasterConfig = c = {}
+c['slaves'] = [BuildSlave('bot1', 'sekrit')]
+c['schedulers'] = []
+c['slavePortnum'] = 0
+
+f1 = factory.BuildFactory([
+##STEPS##
+])
+
+b1 = {'name': 'full1', 'slavename': 'bot1', 'builddir': 'bd1', 'factory': f1}
+c['builders'] = [b1]
+"""
+
+    SetPropertySimple_config = SetProperty_base_config.replace("##STEPS##", """
+        SetProperty(property='foo', command="echo foo"),
+        SetProperty(property=WithProperties('wp'), command="echo wp"),
+        SetProperty(property='bar', command="echo bar", strip=False),
+    """)
+
+    def testSetPropertySimple(self):
+        d = self.master.loadConfig(self.SetPropertySimple_config)
+        d.addCallback(lambda res: self.master.startService())
+        d.addCallback(lambda res: self.connectOneSlave("bot1"))
+        d.addCallback(lambda res: self.requestBuild("full1"))
+        d.addCallback(self.failUnlessBuildSucceeded)
+        def _check_props(bs):
+            self.failUnlessEqual(bs.getProperty("foo"), "foo")
+            self.failUnlessEqual(bs.getProperty("wp"), "wp")
+            # (will this fail on some platforms, due to newline differences?)
+            self.failUnlessEqual(bs.getProperty("bar"), "bar\n")
+            return bs
+        d.addCallback(_check_props)
+        return d
+
+    SetPropertyExtractFn_config = SetProperty_base_config.replace("##STEPS##", """
+        SetProperty(
+            extract_fn=lambda rc,stdout,stderr : {
+                'foo' : stdout.strip(),
+                'bar' : stderr.strip() },
+            command="echo foo; echo bar >&2"),
+    """)
+
+    def testSetPropertyExtractFn(self):
+        d = self.master.loadConfig(self.SetPropertyExtractFn_config)
+        d.addCallback(lambda res: self.master.startService())
+        d.addCallback(lambda res: self.connectOneSlave("bot1"))
+        d.addCallback(lambda res: self.requestBuild("full1"))
+        d.addCallback(self.failUnlessBuildSucceeded)
+        def _check_props(bs):
+            self.failUnlessEqual(bs.getProperty("foo"), "foo")
+            self.failUnlessEqual(bs.getProperty("bar"), "bar")
+            return bs
+        d.addCallback(_check_props)
+        return d
 
 # we test got_revision in test_vc





More information about the Commits mailing list