Commit ac011cb9 authored by jim's avatar jim

Added a working-directory option.


git-svn-id: http://svn.zope.org/repos/main/zc.buildout/trunk@70904 62d5b8a3-27da-0310-9561-8e5933582275
parent f1ad0fe8
...@@ -2,6 +2,16 @@ ...@@ -2,6 +2,16 @@
Change History Change History
************** **************
1.0.0b4 (2006-10-24)
====================
Feature Changes
---------------
- Added a working-directoy option to specify a working directory for
the generated script.
1.0.0b3 (2006-10-16) 1.0.0b3 (2006-10-16)
==================== ====================
......
...@@ -7,7 +7,7 @@ def read(*rnames): ...@@ -7,7 +7,7 @@ def read(*rnames):
name = "zc.recipe.testrunner" name = "zc.recipe.testrunner"
setup( setup(
name = name, name = name,
version = "1.0.0b3", version = "1.0.0b4",
author = "Jim Fulton", author = "Jim Fulton",
author_email = "jim@zope.com", author_email = "jim@zope.com",
description = "ZC Buildout recipe for creating test runners", description = "ZC Buildout recipe for creating test runners",
...@@ -32,7 +32,8 @@ setup( ...@@ -32,7 +32,8 @@ setup(
include_package_data = True, include_package_data = True,
package_dir = {'':'src'}, package_dir = {'':'src'},
namespace_packages = ['zc', 'zc.recipe'], namespace_packages = ['zc', 'zc.recipe'],
install_requires = ['zc.buildout >=1.0.0b7', 'zope.testing', 'setuptools', install_requires = ['zc.buildout >=1.0.0b12',
'zope.testing', 'setuptools',
'zc.recipe.egg >=1.0.0a3', 'zc.recipe.egg >=1.0.0a3',
], ],
test_suite = name+'.tests.test_suite', test_suite = name+'.tests.test_suite',
......
...@@ -4,7 +4,7 @@ Test-Runner Recipe ...@@ -4,7 +4,7 @@ Test-Runner Recipe
The test-runner recipe, zc.recipe.testrunner, creates a test runner The test-runner recipe, zc.recipe.testrunner, creates a test runner
for a project. for a project.
The test-runner recipe has 3 options: The test-runner recipe has several options:
eggs eggs
The eggs option specified a list of eggs to test given as one ore The eggs option specified a list of eggs to test given as one ore
...@@ -20,11 +20,15 @@ extra-paths ...@@ -20,11 +20,15 @@ extra-paths
One or more extra paths to include in the generated test script. One or more extra paths to include in the generated test script.
defaults defaults
The defaults option lets you specify testrunner default The defaults option lets you specify testrunner default
options. These are specified as Python source for an expression options. These are specified as Python source for an expression
yielding a list, typically a list literal. yielding a list, typically a list literal.
working-directory
The working-directory option lets to specify a directory where the
tests will run. The testrunner will change to this directory whe
run.
(Note that, at this time, due to limitations in the Zope test runner, (Note that, at this time, due to limitations in the Zope test runner,
the distributions cannot be zip files. TODO: Fix the test runner!) the distributions cannot be zip files. TODO: Fix the test runner!)
...@@ -216,6 +220,47 @@ extra-paths option to specify them: ...@@ -216,6 +220,47 @@ extra-paths option to specify them:
'--test-path', '/sample-buildout/demo', '--test-path', '/sample-buildout/demo',
]) ])
We can use the working-directory option to specify an working
directory:
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... develop = demo
... parts = testdemo
... offline = true
...
... [testdemo]
... recipe = zc.recipe.testrunner
... eggs = demo
... extra-paths = /usr/local/zope/lib/python
... working-directory = /foo/bar
... """)
>>> print system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),
>>> cat(sample_buildout, 'bin', 'testdemo')
#!/usr/local/bin/python2.4
<BLANKLINE>
import sys
sys.path[0:0] = [
'/sample-buildout/demo',
'/sample-buildout/eggs/zope.testing-3.0-py2.3.egg',
'/sample-buildout/eggs/setuptools-0.6-py1.3.egg',
'/usr/local/zope/lib/python',
]
<BLANKLINE>
import os
os.chdir('/foo/bar')
<BLANKLINE>
import zope.testing.testrunner
<BLANKLINE>
if __name__ == '__main__':
zope.testing.testrunner.run([
'--test-path', '/sample-buildout/demo',
])
If we need to specify default options, we can use the defaults If we need to specify default options, we can use the defaults
option. For example, Zope 3 applications typically define test suites option. For example, Zope 3 applications typically define test suites
in modules named ftests or tests. The default test runner behaviour in modules named ftests or tests. The default test runner behaviour
......
...@@ -42,6 +42,12 @@ class TestRunner: ...@@ -42,6 +42,12 @@ class TestRunner:
defaults = options.get('defaults', '').strip() defaults = options.get('defaults', '').strip()
if defaults: if defaults:
defaults = '(%s) + ' % defaults defaults = '(%s) + ' % defaults
wd = options.get('working-directory', '')
if wd:
initialization = "import os\nos.chdir(%r)" % wd
else:
initialization = ''
return zc.buildout.easy_install.scripts( return zc.buildout.easy_install.scripts(
[(options['script'], 'zope.testing.testrunner', 'run')], [(options['script'], 'zope.testing.testrunner', 'run')],
...@@ -52,6 +58,7 @@ class TestRunner: ...@@ -52,6 +58,7 @@ class TestRunner:
TESTPATH=repr(test_paths)[1:-1].replace( TESTPATH=repr(test_paths)[1:-1].replace(
', ', ",\n '--test-path', "), ', ', ",\n '--test-path', "),
)), )),
initialization = initialization,
) )
update = install update = install
......
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