[Checkins] SVN: zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/ Changed the behaviour if no working directory is specified: an empty part

Thomas Lotze tl at gocept.com
Sun Feb 25 14:24:37 EST 2007


Log message for revision 72802:
  Changed the behaviour if no working directory is specified: an empty part
  directory is now created to be used as a working directory.
  

Changed:
  U   zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/README.txt
  U   zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/__init__.py

-=-
Modified: zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/README.txt
===================================================================
--- zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/README.txt	2007-02-25 10:53:33 UTC (rev 72801)
+++ zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/README.txt	2007-02-25 19:24:36 UTC (rev 72802)
@@ -27,7 +27,8 @@
 working-directory
     The working-directory option lets to specify a directory where the
     tests will run. The testrunner will change to this directory when
-    run.         
+    run. If the working directory is the empty string or not specified
+    at all, the recipe will create a working directory among the parts.
 
 (Note that, at this time, due to limitations in the Zope test runner,
  the distributions cannot be zip files. TODO: Fix the test runner!)
@@ -144,6 +145,11 @@
     -  buildout
     -  test
 
+We also get a part directory for the tests to run in:
+
+    >>> ls (sample_buildout, 'parts')
+    d  testdemo
+
 We can run the test script to run our demo test:
 
     >>> print system(os.path.join(sample_buildout, 'bin', 'test') + ' -vv'),
@@ -213,6 +219,10 @@
       '/usr/local/zope/lib/python',
       ]
     <BLANKLINE>
+    import os
+    sys.argv[0] = os.path.abspath(sys.argv[0])
+    os.chdir('/sample-buildout/parts/testdemo')
+    <BLANKLINE>
     import zope.testing.testrunner
     <BLANKLINE>
     if __name__ == '__main__':
@@ -261,7 +271,12 @@
       '--test-path', '/sample-buildout/demo',
       ])
 
+Now that out tests use a specified working directory, their designated
+part directory is gone:
 
+    >>> ls(sample_buildout, 'parts')
+
+
 If we need to specify default options, we can use the defaults
 option. For example, Zope 3 applications typically define test suites
 in modules named ftests or tests.  The default test runner behaviour
@@ -299,6 +314,10 @@
       '/usr/local/zope/lib/python',
       ]
     <BLANKLINE>
+    import os
+    sys.argv[0] = os.path.abspath(sys.argv[0])
+    os.chdir('/sample-buildout/parts/testdemo')
+    <BLANKLINE>
     import zope.testing.testrunner
     <BLANKLINE>
     if __name__ == '__main__':

Modified: zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/__init__.py
===================================================================
--- zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/__init__.py	2007-02-25 10:53:33 UTC (rev 72801)
+++ zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/__init__.py	2007-02-25 19:24:36 UTC (rev 72802)
@@ -30,10 +30,14 @@
         options['script'] = os.path.join(buildout['buildout']['bin-directory'],
                                          options.get('script', self.name),
                                          )
+        if not options.get('working-directory', ''):
+            options['location'] = os.path.join(
+                buildout['buildout']['parts-directory'], name)
         self.egg = zc.recipe.egg.Egg(buildout, name, options)
 
     def install(self):
         options = self.options
+        dest = []
         eggs, ws = self.egg.working_set(('zope.testing', ))
 
         test_paths = [ws.find(pkg_resources.Requirement.parse(spec)).location
@@ -44,12 +48,13 @@
             defaults = '(%s) + ' % defaults
 
         wd = options.get('working-directory', '')
-        if wd:
-            initialization = initialization_template % wd
-        else:
-            initialization = ''
+        if not wd:
+            wd = options['location']
+            os.mkdir(wd)
+            dest.append(wd)
+        initialization = initialization_template % wd
         
-        return zc.buildout.easy_install.scripts(
+        dest.extend(zc.buildout.easy_install.scripts(
             [(options['script'], 'zope.testing.testrunner', 'run')],
             ws, options['executable'],
             self.buildout['buildout']['bin-directory'],
@@ -59,8 +64,10 @@
                                ', ', ",\n  '--test-path', "),
                 )),
             initialization = initialization,
-            )
+            ))
 
+        return dest
+
     update = install
 
 arg_template = """[



More information about the Checkins mailing list