I'm just back from a mini-vacation. Before I left, I upgrade the Mailman 3 branch to use buildout 1.5, but I experienced a build failure [1] and a bunch of test failures. Gary fixed all the build problems (thanks!) and I think released a new zope.testrunner package that got my branch back into working state. Mostly. I had one test failure that was fairly easy to fix, but it pointed to a change in zope.testrunner. This may be a question better suited to the TIP list, but well, I'll send it here as a follow up to my buildout issues. ;) The diff should illustrate the behavior change in z.t that broke the test: % bzr diff -c 6934 === modified file 'src/mailman/app/docs/hooks.txt' --- src/mailman/app/docs/hooks.txt 2010-01-12 13:27:38 +0000 +++ src/mailman/app/docs/hooks.txt 2010-08-30 01:00:26 +0000 @@ -51,7 +51,8 @@ >>> def call(): ... proc = subprocess.Popen( ... 'bin/mailman lists --domain ignore -q'.split(), - ... cwd='../..', # testrunner runs from ./parts/test + ... # testrunner runs from ./parts/test/working-directory + ... cwd='../../..', ... env=dict(MAILMAN_CONFIG_FILE=config_path, ... PYTHONPATH=config_directory), ... stdout=subprocess.PIPE, stderr=subprocess.PIPE) The test is trying to run a script that gets built into the bin directory of the built-out tree. I had to set cwd in order to find the bin directory. I probably could have used other landmarks to more dynamically find the bin directory, but this seemed expedient... until z.t changed the cwd in the new version. So my question is: would it make sense to be able to ask zope.testrunner where it's running from, so that I don't have to hard code cwd? Better still would be a function in z.t that I could call that would get me back to root directory. E.g. something like: ... cwd=zope.testrunner.root_directory() Thoughts? It's not that big of a deal, but I don't like that my test relies on undocumented zope.testrunner behavior. Cheers, -Barry [1] https://bugs.edge.launchpad.net/zc.buildout/+bug/623590
On Aug 30, 2010, at 7:09 AM, Barry Warsaw wrote: > I'm just back from a mini-vacation. Before I left, I upgrade the Mailman 3 > branch to use buildout 1.5, but I experienced a build failure [1] and a bunch > of test failures. Gary fixed all the build problems (thanks!) and I think > released a new zope.testrunner package that got my branch back into working > state. > > Mostly. I had one test failure that was fairly easy to fix, but it pointed to > a change in zope.testrunner. This may be a question better suited to the TIP > list, but well, I'll send it here as a follow up to my buildout issues. ;) > > The diff should illustrate the behavior change in z.t that broke the test: > > % bzr diff -c 6934 > === modified file 'src/mailman/app/docs/hooks.txt' > --- src/mailman/app/docs/hooks.txt 2010-01-12 13:27:38 +0000 > +++ src/mailman/app/docs/hooks.txt 2010-08-30 01:00:26 +0000 > @@ -51,7 +51,8 @@ >>>> def call(): > ... proc = subprocess.Popen( > ... 'bin/mailman lists --domain ignore -q'.split(), > - ... cwd='../..', # testrunner runs from ./parts/test > + ... # testrunner runs from ./parts/test/working-directory > + ... cwd='../../..', > ... env=dict(MAILMAN_CONFIG_FILE=config_path, > ... PYTHONPATH=config_directory), > ... stdout=subprocess.PIPE, stderr=subprocess.PIPE) > > > The test is trying to run a script that gets built into the bin directory of > the built-out tree. I had to set cwd in order to find the bin directory. I > probably could have used other landmarks to more dynamically find the bin > directory, but this seemed expedient... until z.t changed the cwd in the new > version. That was a (my) change in zc.recipe.testrunner, not in zope.testrunner. > > So my question is: would it make sense to be able to ask zope.testrunner where > it's running from, so that I don't have to hard code cwd? Better still would > be a function in z.t that I could call that would get me back to root > directory. E.g. something like: > > ... cwd=zope.testrunner.root_directory() > > Thoughts? It's not that big of a deal, but I don't like that my test relies > on undocumented zope.testrunner behavior. I think it is more a buildout question, and buildout does offer a way of getting that information when you are writing scripts. ${buildout: directory} is available in the .cfg files for script initialization (stuff it in an environ variable, maybe?), and of course can be also used in templating solutions like z3c.recipe.filetemplate. Is that sufficient for a solution? I don't know if the zope.testrunner would actually be able to give you the answer you want, but I don't know that package very well. Gary
On Aug 30, 2010, at 10:08 AM, Gary Poster wrote:
So my question is: would it make sense to be able to ask zope.testrunner where it's running from, so that I don't have to hard code cwd? Better still would be a function in z.t that I could call that would get me back to root directory. E.g. something like:
... cwd=zope.testrunner.root_directory()
Thoughts? It's not that big of a deal, but I don't like that my test relies on undocumented zope.testrunner behavior.
I think it is more a buildout question, and buildout does offer a way of getting that information when you are writing scripts. ${buildout: directory} is available in the .cfg files for script initialization (stuff it in an environ variable, maybe?), and of course can be also used in templating solutions like z3c.recipe.filetemplate.
Is that sufficient for a solution?
It is! I've already hooked in an initialization key in the [test] section's use of zc.recipe.testrunner in my buildout.cfg, so it was fairly easy to put this together. Below is the relevant code, for the archives. Thanks Gary! -Barry -----buildout.cfg [test] recipe = zc.recipe.testrunner eggs = mailman defaults = '--tests-pattern ^tests --exit-with-status'.split() # Hack in extra arguments to zope.testrunner. initialization = from mailman.testing.layers import ConfigLayer; ConfigLayer.enable_stderr(); ConfigLayer.set_root_directory('${buildout:directory}') -----src/mailman/testing/layers.py class ConfigLayer: # ... @classmethod def set_root_directory(cls, directory): """Set the directory at the root of our source tree. zc.recipe.testrunner runs from parts/test/working-directory, but that's actually changed over the life of the package. Some tests care, e.g. because they need to find our built-out bin directory. Fortunately, buildout can give us this information. See the `buildout.cfg` file for where this method is called. """ cls.root_directory = directory -----src/mailman/app/docs/hooks.txt >>> def call(): ... proc = subprocess.Popen( ... 'bin/mailman lists --domain ignore -q'.split(), ... cwd=ConfigLayer.root_directory, ... env=dict(MAILMAN_CONFIG_FILE=config_path, ... PYTHONPATH=config_directory), ... stdout=subprocess.PIPE, stderr=subprocess.PIPE)
participants (2)
-
Barry Warsaw
-
Gary Poster