[Buildbot-commits] buildbot/buildbot/test emit.py, 1.1, 1.2 runutils.py, 1.9, 1.10 test_slavecommand.py, 1.21, 1.22
Brian Warner
warner at users.sourceforge.net
Tue Jun 20 08:08:53 UTC 2006
Update of /cvsroot/buildbot/buildbot/buildbot/test
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv14620/buildbot/test
Modified Files:
emit.py runutils.py test_slavecommand.py
Log Message:
[project @ tests: run commands from _trial_temp, not buildbot/test/]
Original author: warner at lothar.com
Date: 2006-06-20 03:57:27
Index: emit.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/emit.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- emit.py 8 Jan 2004 20:05:24 -0000 1.1
+++ emit.py 20 Jun 2006 08:08:51 -0000 1.2
@@ -6,5 +6,7 @@
sys.stderr.write("this is stderr\n")
if os.environ.has_key("EMIT_TEST"):
sys.stdout.write("EMIT_TEST: %s\n" % os.environ["EMIT_TEST"])
+open("log1.out","wt").write("this is log1\n")
+
rc = int(sys.argv[1])
sys.exit(rc)
Index: runutils.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/runutils.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- runutils.py 20 Jun 2006 08:08:45 -0000 1.9
+++ runutils.py 20 Jun 2006 08:08:51 -0000 1.10
@@ -250,9 +250,9 @@
class FakeSlaveBuilder:
debug = False
- def __init__(self, usePTY):
+ def __init__(self, usePTY, basedir):
self.updates = []
- self.basedir = findDir()
+ self.basedir = basedir
self.usePTY = usePTY
def sendUpdate(self, data):
@@ -263,12 +263,15 @@
class SlaveCommandTestBase(SignalMixin):
usePTY = False
- def setUp(self):
- self.builder = FakeSlaveBuilder(self.usePTY)
+
+ def setUpBuilder(self, basedir):
+ if not os.path.exists(basedir):
+ os.mkdir(basedir)
+ self.builder = FakeSlaveBuilder(self.usePTY, basedir)
def startCommand(self, cmdclass, args):
stepId = 0
- c = cmdclass(self.builder, stepId, args)
+ self.cmd = c = cmdclass(self.builder, stepId, args)
c.running = True
d = c.doStart()
return d
Index: test_slavecommand.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_slavecommand.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- test_slavecommand.py 20 Jun 2006 08:08:11 -0000 1.21
+++ test_slavecommand.py 20 Jun 2006 08:08:51 -0000 1.22
@@ -2,7 +2,7 @@
from twisted.trial import unittest
from twisted.internet import reactor, interfaces
-from twisted.python import runtime, failure
+from twisted.python import runtime, failure, util
from buildbot.twcompat import maybeWait
import os, re, sys
@@ -20,10 +20,21 @@
class ShellBase(SignalMixin):
def setUp(self):
- self.builder = FakeSlaveBuilder(self.usePTY)
+ self.basedir = "test_slavecommand"
+ if not os.path.isdir(self.basedir):
+ os.mkdir(self.basedir)
+ self.subdir = os.path.join(self.basedir, "subdir")
+ if not os.path.isdir(self.subdir):
+ os.mkdir(self.subdir)
+ self.builder = FakeSlaveBuilder(self.usePTY, self.basedir)
+ self.emitcmd = util.sibpath(__file__, "emit.py")
+ self.subemitcmd = os.path.join(util.sibpath(__file__, "subdir"),
+ "emit.py")
+ self.sleepcmd = util.sibpath(__file__, "sleep.py")
def failUnlessIn(self, substring, string):
- self.failUnless(string.find(substring) != -1)
+ self.failUnless(string.find(substring) != -1,
+ "'%s' not in '%s'" % (substring, string))
def getfile(self, which):
got = ""
@@ -64,13 +75,19 @@
self.assertEquals(got, expected)
def testShell1(self):
- cmd = sys.executable + " emit.py 0"
+ targetfile = os.path.join(self.basedir, "log1.out")
+ if os.path.exists(targetfile):
+ os.unlink(targetfile)
+ cmd = "%s %s 0" % (sys.executable, self.emitcmd)
args = {'command': cmd, 'workdir': '.', 'timeout': 60}
c = SlaveShellCommand(self.builder, None, args)
d = c.start()
expected = [('stdout', "this is stdout\n"),
('stderr', "this is stderr\n")]
d.addCallback(self._checkPass, expected, 0)
+ def _check_targetfile(res):
+ self.failUnless(os.path.exists(targetfile))
+ d.addCallback(_check_targetfile)
return maybeWait(d)
def _checkPass(self, res, expected, rc):
@@ -78,7 +95,7 @@
self.checkrc(rc)
def testShell2(self):
- cmd = [sys.executable, "emit.py", "0"]
+ cmd = [sys.executable, self.emitcmd, "0"]
args = {'command': cmd, 'workdir': '.', 'timeout': 60}
c = SlaveShellCommand(self.builder, None, args)
d = c.start()
@@ -88,7 +105,7 @@
return maybeWait(d)
def testShellRC(self):
- cmd = [sys.executable, "emit.py", "1"]
+ cmd = [sys.executable, self.emitcmd, "1"]
args = {'command': cmd, 'workdir': '.', 'timeout': 60}
c = SlaveShellCommand(self.builder, None, args)
d = c.start()
@@ -98,7 +115,7 @@
return maybeWait(d)
def testShellEnv(self):
- cmd = sys.executable + " emit.py 0"
+ cmd = "%s %s 0" % (sys.executable, self.emitcmd)
args = {'command': cmd, 'workdir': '.',
'env': {'EMIT_TEST': "envtest"}, 'timeout': 60}
c = SlaveShellCommand(self.builder, None, args)
@@ -111,13 +128,19 @@
return maybeWait(d)
def testShellSubdir(self):
- cmd = sys.executable + " emit.py 0"
+ targetfile = os.path.join(self.basedir, "subdir", "log1.out")
+ if os.path.exists(targetfile):
+ os.unlink(targetfile)
+ cmd = "%s %s 0" % (sys.executable, self.subemitcmd)
args = {'command': cmd, 'workdir': "subdir", 'timeout': 60}
c = SlaveShellCommand(self.builder, None, args)
d = c.start()
expected = [('stdout', "this is stdout in subdir\n"),
('stderr', "this is stderr\n")]
d.addCallback(self._checkPass, expected, 0)
+ def _check_targetfile(res):
+ self.failUnless(os.path.exists(targetfile))
+ d.addCallback(_check_targetfile)
return maybeWait(d)
def testShellMissingCommand(self):
@@ -137,7 +160,7 @@
# stopped trying.
def testTimeout(self):
- args = {'command': [sys.executable, "sleep.py", "10"],
+ args = {'command': [sys.executable, self.sleepcmd, "10"],
'workdir': '.', 'timeout': 2}
c = SlaveShellCommand(self.builder, None, args)
d = c.start()
@@ -157,7 +180,7 @@
testTimeout.todo = "timeout doesn't appear to work under windows"
def testInterrupt1(self):
- args = {'command': [sys.executable, "sleep.py", "10"],
+ args = {'command': [sys.executable, self.sleepcmd, "10"],
'workdir': '.', 'timeout': 20}
c = SlaveShellCommand(self.builder, None, args)
d = c.start()
@@ -183,7 +206,7 @@
# test the backup timeout. This doesn't work under a PTY, because the
# transport.loseConnection we do in the timeout handler actually
# *does* kill the process.
- args = {'command': [sys.executable, "sleep.py", "5"],
+ args = {'command': [sys.executable, self.sleepcmd, "5"],
'workdir': '.', 'timeout': 20}
c = SlaveShellCommand(self.builder, None, args)
d = c.start()
@@ -208,7 +231,7 @@
# make sure that a) the old command's output doesn't interfere with
# the new one, and b) the old command's actual termination doesn't
# break anything
- args = {'command': [sys.executable, "sleep.py", "5"],
+ args = {'command': [sys.executable, self.sleepcmd, "5"],
'workdir': '.', 'timeout': 20}
c = SlaveShellCommand(self.builder, None, args)
d = c.start()
More information about the Commits
mailing list