Skip to content

Commit

Permalink
use buildbot.tac from the current directory as default for checkconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
thedylman committed Jan 25, 2015
1 parent 7c30578 commit 8d760b0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion master/buildbot/scripts/checkconfig.py
Expand Up @@ -38,7 +38,7 @@ def _loadConfig(basedir, configFile, quiet):

def checkconfig(config):
quiet = config.get('quiet')
configFile = config.get('configFile')
configFile = config.get('configFile', os.getcwd())

if os.path.isdir(configFile):
basedir = configFile
Expand Down
5 changes: 2 additions & 3 deletions master/buildbot/scripts/runner.py
Expand Up @@ -487,13 +487,12 @@ class CheckConfigOptions(base.SubcommandOptions):

def getSynopsis(self):
return "Usage:\t\tbuildbot checkconfig [configFile]\n" + \
"\t\tIf not specified, 'master.cfg' will be used as 'configFile'"
"\t\tIf not specified, the config file specified in " + \
"'buildbot.tac' from the current directory will be used"

def parseArgs(self, *args):
if len(args) >= 1:
self['configFile'] = args[0]
else:
self['configFile'] = 'master.cfg'


class UserOptions(base.SubcommandOptions):
Expand Down
14 changes: 11 additions & 3 deletions master/buildbot/test/unit/test_scripts_checkconfig.py
Expand Up @@ -147,19 +147,27 @@ def setUp(self):
self.loadConfig = mock.Mock(spec=checkconfig._loadConfig, return_value=3)
self.patch(checkconfig, '_loadConfig', self.loadConfig)

def test_checkconfig_default(self):
self.assertEqual(checkconfig.checkconfig(dict()), 3)
self.loadConfig.assert_called_with(basedir=os.getcwd(),
configFile='master.cfg', quiet=None)

def test_checkconfig_given_dir(self):
self.assertEqual(checkconfig.checkconfig(dict(configFile='.')), 3)
self.loadConfig.assert_called_with(basedir='.', configFile='master.cfg', quiet=None)
self.loadConfig.assert_called_with(basedir='.', configFile='master.cfg',
quiet=None)

def test_checkconfig_given_file(self):
config = dict(configFile='master.cfg')
self.assertEqual(checkconfig.checkconfig(config), 3)
self.loadConfig.assert_called_with(basedir=os.getcwd(), configFile='master.cfg', quiet=None)
self.loadConfig.assert_called_with(basedir=os.getcwd(),
configFile='master.cfg', quiet=None)

def test_checkconfig_quiet(self):
config = dict(configFile='master.cfg', quiet=True)
self.assertEqual(checkconfig.checkconfig(config), 3)
self.loadConfig.assert_called_with(basedir=os.getcwd(), configFile='master.cfg', quiet=True)
self.loadConfig.assert_called_with(basedir=os.getcwd(),
configFile='master.cfg', quiet=True)

def test_checkconfig_syntaxError_quiet(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions master/buildbot/test/unit/test_scripts_runner.py
Expand Up @@ -595,7 +595,7 @@ def test_synopsis(self):

def test_defaults(self):
opts = self.parse()
exp = dict(quiet=False, configFile='master.cfg')
exp = dict(quiet=False)
self.assertOptions(opts, exp)

def test_configfile(self):
Expand All @@ -605,7 +605,7 @@ def test_configfile(self):

def test_quiet(self):
opts = self.parse('-q')
exp = dict(quiet=True, configFile='master.cfg')
exp = dict(quiet=True)
self.assertOptions(opts, exp)


Expand Down

0 comments on commit 8d760b0

Please sign in to comment.