Skip to content

Commit

Permalink
merged 106426:106430 branches/reinout-requirements
Browse files Browse the repository at this point in the history
Addition of include-dependencies option.
  • Loading branch information
reinout committed Dec 12, 2009
1 parent 407da2a commit 2f90414
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ CHANGES
0.12 (unreleased)
=================

- Nothing changed yet.
- Added ``include-dependencies`` option that automatically includes the
dependencies of the specified packages. Very handy to get an automatically
updated list of those packages that are most useful to test: all our
dependencies.


0.11 (2009-09-30)
Expand Down
28 changes: 28 additions & 0 deletions src/z3c/recipe/compattest/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ No further configuration is required, but you can set the following options:

- ``include``: list of packages to include (whitespace-separated)
(default: empty)
- ``include-dependencies``: list of packages to include *including* their
direct dependencies. (default: empty)
- ``exclude``: packages matching any regex in this list will be excluded
(default: empty)
- ``script``: the name of the runner script (defaults to the part name)
Expand Down Expand Up @@ -56,6 +58,32 @@ picked up:
#!...python...
...zope.dottedname...

If we use ``include-dependencies`` instead of just ``include``, our direct
dependencies are also picked up, for instance zc.buildout:

>>> write('buildout.cfg', """
... [buildout]
... parts = compattest
...
... [compattest]
... recipe = z3c.recipe.compattest
... include-dependencies = z3c.recipe.compattest
... """)
>>> print 'start', system(buildout)
start ...
Generated script '/sample-buildout/bin/compattest-zc.buildout'.
...
Generated script '/sample-buildout/bin/compattest'.

All our direct dependencies have a test script now:

>>> ls('bin')
- buildout
- compattest
- compattest-z3c.recipe.compattest
- compattest-zc.buildout
- compattest-zc.recipe.testrunner


Passing options to the test runners
===================================
Expand Down
21 changes: 20 additions & 1 deletion src/z3c/recipe/compattest/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def __init__(self, buildout, name, options):
options['max_jobs'] = '1'

self.include = string2list(self.options.get('include', ''), [])
self.include_dependencies = string2list(
self.options.get('include-dependencies', ''), [])
self.exclude = string2list(self.options.get('exclude', ''), [])
self.extra_paths = self.options.get('extra-paths', '')
self.wanted_packages = self._wanted_packages()
Expand Down Expand Up @@ -77,8 +79,25 @@ def _install_run_script(self):
bindir, arguments='%s, %s' % (self.options['max_jobs'],
', '.join(runners)))

def _find_dependencies(self):
result = []
if not self.include_dependencies:
return result
for package in self.include_dependencies:
result.append(package)
ws = self._working_set(package)
dist = ws.find(pkg_resources.Requirement.parse(package))
for requirement in dist.requires():
dist = ws.find(requirement)
if not dist:
continue
result.append(dist.project_name)
return result


def _wanted_packages(self):
projects = self.include
projects = self.include + self._find_dependencies()
projects = set(projects) # Filter out duplicates.
for project in projects:
for regex in self.exclude:
if re.compile(regex).search(project):
Expand Down

0 comments on commit 2f90414

Please sign in to comment.