Commit 299c235c authored by Jim Fulton's avatar Jim Fulton

Require newlines to separate distributions in a distributions

option. The values are setuptools requirements and can have spaces in
them.
parent 3ae66aba
......@@ -4,5 +4,8 @@ parts = test
[test]
recipe = zc.recipe.testrunner
distributions = zc.buildout zc.recipe.egg zc.recipe.testrunner
distributions =
zc.buildout
zc.recipe.egg
zc.recipe.testrunner
......@@ -6,9 +6,12 @@ for a project.
The rest-runner recipe has 2 options:
- The distributions option takes the names of the distributions to be tested.
These are not installed by the recipe. They must be installed by
some other recipe. This option is required.
- The distributions option takes the names of the distributions to be
tested. These are not installed by the recipe. They must be
installed by some other recipe (or using the buildout develop
option). The distributions are in the form os setuptools
requirements. Multiple distributions must be listed on separate
lines. This option is required.
- The script option gives the name of the script to generate, in the
buildout bin directory. Of the option isn't used, the part name
......@@ -17,7 +20,8 @@ The rest-runner recipe has 2 options:
(Note that, at this time, due to limitations in the Zope test runner,
the distributions cannot be zip files. TODO: Fix the test runner!)
To illustrate this, we'll create a project in our sample buildout:
To illustrate this, we'll create a pair of projects in our sample
buildout:
>>> mkdir(sample_buildout, 'demo')
>>> write(sample_buildout, 'demo', 'tests.py',
......@@ -41,21 +45,48 @@ To illustrate this, we'll create a project in our sample buildout:
>>> write(sample_buildout, 'demo', 'README.txt', '')
>>> mkdir(sample_buildout, 'demo2')
>>> write(sample_buildout, 'demo2', 'tests.py',
... '''
... import unittest
...
... class TestSomething(unittest.TestCase):
... def test_something(self):
... pass
...
... def test_suite():
... return unittest.makeSuite(TestSomething)
... ''')
>>> write(sample_buildout, 'demo2', 'setup.py',
... """
... from setuptools import setup
...
... setup(name = "demo2")
... """)
>>> write(sample_buildout, 'demo2', 'README.txt', '')
We'll update our buildout to install the demo project as a
develop egg and to create the test script:
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... develop = demo
... develop = demo demo2
... parts = testdemo
...
... [testdemo]
... recipe = zc.recipe.testrunner
... distributions = demo
... distributions =
... demo
... demo2
... script = test
... """)
Note that we specified both demo and demo2 in the distributions
section and that we put them on separate lines.
Now when we run the buildout:
>>> import os
......@@ -72,7 +103,7 @@ We can run the test script to run our demo test:
>>> print system(os.path.join(sample_buildout, 'bin', 'test')),
Running unit tests:
Ran 1 tests with 0 failures and 0 errors in 0.000 seconds.
Ran 2 tests with 0 failures and 0 errors in 0.000 seconds.
If we leave the script option out of the configuration, then the test
script will get it's name from the part:
......
......@@ -27,12 +27,15 @@ class TestRunner:
self.options = options
def install(self):
distributions = self.options['distributions'].split()
distributions = [
req.strip()
for req in self.options['distributions'].split('\n')
if req.split()
]
path = zc.buildout.egglinker.path(
distributions+['zope.testing'],
[self.buildout.eggs],
)
locations = [zc.buildout.egglinker.location(distribution,
[self.buildout.eggs])
for distribution in distributions]
......
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