Commit 74a50d0a authored by Jérome Perrin's avatar Jérome Perrin

test.utils.makeRecipe: support running from software folder

Now that we also run slapos.cookbook tests from SLAPOS-SR-TEST we cannot
simply examine buildout.cfg, because unlike SLAPOS-EGG-TEST this
repository is now checked out in parts of the software folder, not the
instance folder.
So that trick of looking up the egg directories in buildout does not
work, because this is a software buildout.cfg ... instead, we assume
that the standard eggs and develop-eggs directories are used.
parent 33299ad5
...@@ -40,15 +40,30 @@ def makeRecipe(recipe_class, options, name='test', slap_connection=None): ...@@ -40,15 +40,30 @@ def makeRecipe(recipe_class, options, name='test', slap_connection=None):
buildout['slap-connection'] = slap_connection buildout['slap-connection'] = slap_connection
# are we in buildout folder ? # are we in buildout folder ?
# the usual layout is # in SLAPOS-EGG-TEST the usual layout is
# ${buildout:directory}/parts/slapos-repository/slapos/test/utils.py , so try # ${buildout:directory}/parts/slapos-repository/slapos/test/utils.py in instance buildout, so try
# to find a buildout relative to this file. # to find a buildout.cfg relative to this file.
buildout_cfg = os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', 'buildout.cfg') # What can also happens is that this repository is used from software folder, this is the case in
# SLAPOS-SR-TEST. In this case, ${buildout:eggs} is not set in buildout.cfg and we can only assume
# it will be the standards eggs and develop-eggs folders.
# {BASE_DIRECTORY}/parts/slapos-repository/slapos/test/utils.py
base_directory = os.path.normpath(os.path.join(os.path.dirname(__file__), '..', '..', '..', '..'))
buildout_cfg = os.path.join(base_directory, 'buildout.cfg')
if os.path.exists(buildout_cfg): if os.path.exists(buildout_cfg):
parser = ConfigParser() parser = ConfigParser()
parser.readfp(open(buildout_cfg)) parser.readfp(open(buildout_cfg))
eggs_directory = parser.get('buildout', 'eggs-directory') eggs_directory = parser.get(
develop_eggs_directory = parser.get('buildout', 'develop-eggs-directory') 'buildout',
'eggs-directory',
# default, for the case when buildout_cfg is a software buildout
# like with SLAPOS-SR-TEST.
vars={'eggs-directory': os.path.join(base_directory, 'eggs')})
develop_eggs_directory = parser.get(
'buildout',
'develop-eggs-directory',
vars={'develop-eggs-directory': os.path.join(base_directory, 'develop-eggs')})
logging.getLogger(__name__).info( logging.getLogger(__name__).info(
'Using eggs-directory (%s) and develop-eggs-directory (%s) from buildout at %s', 'Using eggs-directory (%s) and develop-eggs-directory (%s) from buildout at %s',
eggs_directory, eggs_directory,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment