Skip to content
Snippets Groups Projects
Commit 9951a251 authored by Nathan Hertz's avatar Nathan Hertz
Browse files

Added new buildout recipe for testing buildout recipes.

parent 414eb326
No related branches found
No related tags found
No related merge requests found
from setuptools import setup
setup(
name='test_recipes',
version='0.1',
py_modules = ['test_recipes'],
entry_points = {"zc.buildout": ["default=test_recipes:Recipe"]},
)
\ No newline at end of file
import subprocess
import logging
logger = logging.getLogger("buildout/test_recipes")
def get_recipes():
"""
Get all currently installed buildout recipes (including this one!)
:return: Dictionary with format {recipe_name: recipe_path_from_root,}
"""
logger.debug("Getting list of recipes...")
recipes = {}
find = subprocess.run(['find', './build/recipes', '-name', 'setup.py'],
stdout=subprocess.PIPE)
paths = find.stdout.decode('utf-8').split('\n')
dirs = []
names = []
for p in paths:
if len(p) > 1:
# Exclude empty result from find
dirs.append(p.replace('/setup.py', ''))
names.append(p.split('/')[-2])
for d, n in zip(dirs, names):
recipes[n] = d
logger.debug("Done getting recipes.")
return recipes
class Recipe:
"""
Buildout Recipe class.
For more detailed information, see the link.
http://www.buildout.org/en/latest/topics/writing-recipes.html
"""
def __init__(self, buildout, name, options):
"""
Initializes fields needed for recipe.
:param buildout: (Boilerplate) Dictionary of options from buildout section
of buildout.cfg
:param name: (Boilerplate) Name of section that uses this recipe.
:param options: (Boilerplate) Options of section that uses this recipe.
"""
self.name = name
self.options = options
self.recipes = get_recipes()
self.choice = options['name']
def install(self):
"""
Install method that runs when recipe has components it needs to install.
In this case, nothing is "installed" per se.
:return: Paths to files, as strings, created by the recipe.
"""
if self.choice in self.recipes:
logger.debug(f"Running tests for recipe {self.choice}...")
subprocess.run(['pytest', '-vv', '--log-level=DEBUG', '--showlocals',
self.recipes[self.choice]])
......@@ -3,7 +3,11 @@
# e.g. buildout parts=build_pkgs will specify build_pkgs
# as a part that should be installed
[buildout]
develop = build/recipes/setup_to_meta build/recipes/build_pkgs
develop = build/recipes/setup_to_meta build/recipes/build_pkgs build/recipes/test_recipes
[test]
recipe = test_recipes
name = ${buildout:name}
# Section for building internal tools using conda
# Depends on gen_metadata
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment