Skip to content

Commit

Permalink
Patch from Jonathan.Ballet <jonathan.ballet@securactive.net>:
Browse files Browse the repository at this point in the history
allow passing options to the underlying test runner.
  • Loading branch information
wosc committed Sep 28, 2009
1 parent 41178c0 commit b78ef5b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
4 changes: 2 additions & 2 deletions CHANGES.txt
Expand Up @@ -5,8 +5,8 @@ CHANGES
0.10 (unreleased)
=================

- Nothing changed yet.

- Options prefixed by ``runner-`` are automatically passed to generated test
runners.

0.9 (2009-09-14)
================
Expand Down
25 changes: 25 additions & 0 deletions src/z3c/recipe/compattest/README.txt
Expand Up @@ -109,3 +109,28 @@ But no additional develop-egg links are present:

>>> ls('develop-eggs')
- z3c.recipe.compattest.egg-link

Passing options to the test runners
===================================

If you want to use custom options in the generated test runners, you can specify
them in the part options, prefixed by ``runner-``. That is, if you want to pass
the ``--foo`` option by default to all generated test runners, you can set
``runner-defaults = ['--foo']`` in your part:

>>> write('buildout.cfg', """
... [buildout]
... parts = compattest
...
... [compattest]
... recipe = z3c.recipe.compattest
... include = z3c.recipe.compattest
... runner-defaults = ['-c', '-v', '-v']
... """)
>>> ignore = system(buildout)
>>> cat('bin', 'compattest-z3c.recipe.compattest')
#!...python...
...run(...['-c', '-v', '-v']...

Every options prefixed by ``runner-`` will be automatically passed to the
generated test runners.
15 changes: 14 additions & 1 deletion src/z3c/recipe/compattest/recipe.py
Expand Up @@ -12,6 +12,9 @@ def string2list(string, default):
return [item.strip() for item in result]


RUNNER_PREFIX = 'runner-'


class Recipe(object):

def __init__(self, buildout, name, options):
Expand All @@ -35,6 +38,13 @@ def __init__(self, buildout, name, options):
'svn_directory', os.path.join(
self.buildout['buildout']['parts-directory'], self.name))

# gather options to be passed to the underlying testrunner
self.testrunner_options = {}
for opt in self.options:
if opt.startswith(RUNNER_PREFIX):
runner_opt = opt[len(RUNNER_PREFIX):]
self.testrunner_options[runner_opt] = self.options[opt]

def install(self):
if self.svn_url:
if not os.path.exists(self.svn_directory):
Expand Down Expand Up @@ -72,7 +82,10 @@ def _install_testrunners(self):
self.wanted_packages.remove(package)
continue
raise
options = dict(eggs=package + extras)

options = self.testrunner_options.copy()
options['eggs'] = package + extras

recipe = zc.recipe.testrunner.TestRunner(
self.buildout, '%s-%s' % (self.name, package), options)
installed.extend(recipe.install())
Expand Down

0 comments on commit b78ef5b

Please sign in to comment.