import ConfigParser
import os
+import StringIO
def Setup(fname=''):
global config_fname
settings = ConfigParser.SafeConfigParser()
- config_fname = fname
- if config_fname == '':
- config_fname = '%s/.buildman' % os.getenv('HOME')
- if config_fname:
- settings.read(config_fname)
+ if fname is not None:
+ config_fname = fname
+ if config_fname == '':
+ config_fname = '%s/.buildman' % os.getenv('HOME')
+ if config_fname:
+ settings.read(config_fname)
+
+def AddFile(data):
+ settings.readfp(StringIO.StringIO(data))
def GetItems(section):
"""Get the items from a section of the config.
import tempfile
import unittest
+import bsettings
import cmdline
import command
import control
import terminal
import toolchain
+settings_data = '''
+# Buildman settings file
+
+[toolchain]
+
+[toolchain-alias]
+
+[make-flags]
+src=/home/sjg/c/src
+chroot=/home/sjg/c/chroot
+vboot=USE_STDINT=1 VBOOT_DEBUG=1 MAKEFLAGS_VBOOT=DEBUG=1 CFLAGS_EXTRA_VBOOT=-DUNROLL_LOOPS VBOOT_SOURCE=${src}/platform/vboot_reference
+chromeos_coreboot=VBOOT=${chroot}/build/link/usr ${vboot}
+chromeos_daisy=VBOOT=${chroot}/build/daisy/usr ${vboot}
+chromeos_peach=VBOOT=${chroot}/build/peach_pit/usr ${vboot}
+'''
+
class TestFunctional(unittest.TestCase):
"""Functional test for buildman.
command.test_result = self._HandleCommand
self._toolchains = toolchain.Toolchains()
self._toolchains.Add('gcc', test=False)
+ bsettings.Setup(None)
+ bsettings.AddFile(settings_data)
def tearDown(self):
shutil.rmtree(self._base_dir)