buildman: Avoid looking at config file or toolchains in tests
These files may not exist in the environment, or may not be suitable for testing. Provide our own config file and our own toolchains when running tests. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
fd03d63f34
commit
8b985eebd0
2 changed files with 29 additions and 5 deletions
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
import os
|
import os
|
||||||
|
import StringIO
|
||||||
|
|
||||||
|
|
||||||
def Setup(fname=''):
|
def Setup(fname=''):
|
||||||
|
@ -17,11 +18,15 @@ def Setup(fname=''):
|
||||||
global config_fname
|
global config_fname
|
||||||
|
|
||||||
settings = ConfigParser.SafeConfigParser()
|
settings = ConfigParser.SafeConfigParser()
|
||||||
config_fname = fname
|
if fname is not None:
|
||||||
if config_fname == '':
|
config_fname = fname
|
||||||
config_fname = '%s/.buildman' % os.getenv('HOME')
|
if config_fname == '':
|
||||||
if config_fname:
|
config_fname = '%s/.buildman' % os.getenv('HOME')
|
||||||
settings.read(config_fname)
|
if config_fname:
|
||||||
|
settings.read(config_fname)
|
||||||
|
|
||||||
|
def AddFile(data):
|
||||||
|
settings.readfp(StringIO.StringIO(data))
|
||||||
|
|
||||||
def GetItems(section):
|
def GetItems(section):
|
||||||
"""Get the items from a section of the config.
|
"""Get the items from a section of the config.
|
||||||
|
|
|
@ -10,6 +10,7 @@ import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
import bsettings
|
||||||
import cmdline
|
import cmdline
|
||||||
import command
|
import command
|
||||||
import control
|
import control
|
||||||
|
@ -17,6 +18,22 @@ import gitutil
|
||||||
import terminal
|
import terminal
|
||||||
import toolchain
|
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):
|
class TestFunctional(unittest.TestCase):
|
||||||
"""Functional test for buildman.
|
"""Functional test for buildman.
|
||||||
|
|
||||||
|
@ -36,6 +53,8 @@ class TestFunctional(unittest.TestCase):
|
||||||
command.test_result = self._HandleCommand
|
command.test_result = self._HandleCommand
|
||||||
self._toolchains = toolchain.Toolchains()
|
self._toolchains = toolchain.Toolchains()
|
||||||
self._toolchains.Add('gcc', test=False)
|
self._toolchains.Add('gcc', test=False)
|
||||||
|
bsettings.Setup(None)
|
||||||
|
bsettings.AddFile(settings_data)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
shutil.rmtree(self._base_dir)
|
shutil.rmtree(self._base_dir)
|
||||||
|
|
Loading…
Reference in a new issue