[Buildbot-commits] buildbot/buildbot/test test_runner.py,NONE,1.1
Brian Warner
warner at users.sourceforge.net
Tue Apr 26 09:14:12 UTC 2005
Update of /cvsroot/buildbot/buildbot/buildbot/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24822/buildbot/test
Added Files:
test_runner.py
Log Message:
* buildbot/scripts/runner.py (loadOptions): add code to search for
~/.buildbot/, a directory with things like 'options', containing
defaults for various 'buildbot' subcommands. .buildbot/ can be in
the current directory, your $HOME directory, or anywhere
inbetween, as long as you're somewhere inside your home directory.
(debugclient): look in ~/.buildbot/options for master and passwd
(statuslog): look in ~/.buildbot/options for 'masterstatus'
* buildbot/test/test_runner.py (Options.testFindOptions): test it
--- NEW FILE: test_runner.py ---
# this file tests the 'buildbot' command, with its various sub-commands
from twisted.trial import unittest
import os, os.path
from buildbot.scripts import runner
class Options(unittest.TestCase):
optionsFile = "SDFsfsFSdfsfsFSD"
def setUp(self):
self.savedHome = os.environ['HOME']
def tearDown(self):
os.environ['HOME'] = self.savedHome
def make(self, d, key):
# we use a wacky filename here in case the test code discovers the
# user's real ~/.buildbot/ directory
os.makedirs(os.path.sep.join(d + [".buildbot"]))
f = open(os.path.sep.join(d + [".buildbot", self.optionsFile]), "w")
f.write("key = '%s'\n" % key)
f.close()
def check(self, d, key=None):
basedir = os.path.sep.join(d)
options = runner.loadOptions(basedir, self.optionsFile)
if key is None:
self.failIf(options.has_key('key'))
else:
self.failUnlessEqual(options['key'], key)
def testFindOptions(self):
self.make(["home", "dir1", "dir2", "dir3"], "one")
self.make(["home", "dir1", "dir2"], "two")
self.make(["home"], "home")
self.make(["nothome", "dir1", "dir2"], "three")
self.make(["nothome"], "nothome")
os.environ['HOME'] = os.path.abspath("home")
self.check(["home", "dir1", "dir2", "dir3"], "one")
self.check(["home", "dir1", "dir2"], "two")
self.check(["home", "dir1"], "home")
self.check(["nothome", "dir1", "dir2"], "home")
self.check(["nothome", "dir1"], "home")
self.check(["nothome"], "home")
self.check(["home", "dir1"], "home")
os.environ['HOME'] = os.path.abspath("reallynothome")
self.check(["home", "dir1"], None)
More information about the Commits
mailing list