[Checkins] SVN: z3c.recipe.kgstest/trunk/ install test dependencies if necessary

Wolfgang Schnerring wosc at wosc.de
Wed Jan 28 05:16:27 EST 2009


Log message for revision 95286:
  install test dependencies if necessary
  

Changed:
  U   z3c.recipe.kgstest/trunk/buildout.cfg
  U   z3c.recipe.kgstest/trunk/src/z3c/recipe/kgstest/README.txt
  U   z3c.recipe.kgstest/trunk/src/z3c/recipe/kgstest/recipe.py

-=-
Modified: z3c.recipe.kgstest/trunk/buildout.cfg
===================================================================
--- z3c.recipe.kgstest/trunk/buildout.cfg	2009-01-28 10:02:20 UTC (rev 95285)
+++ z3c.recipe.kgstest/trunk/buildout.cfg	2009-01-28 10:16:26 UTC (rev 95286)
@@ -1,7 +1,13 @@
 [buildout]
 develop = .
-parts = test
+parts = test kgstest
 
 [test]
 recipe = zc.recipe.testrunner
-eggs = z3c.recipe.kgstest
+eggs = z3c.recipe.kgstest[test]
+
+# for debugging
+[kgstest]
+recipe = z3c.recipe.kgstest
+exclude = .*
+include = z3c.recipe.kgstest
\ No newline at end of file

Modified: z3c.recipe.kgstest/trunk/src/z3c/recipe/kgstest/README.txt
===================================================================
--- z3c.recipe.kgstest/trunk/src/z3c/recipe/kgstest/README.txt	2009-01-28 10:02:20 UTC (rev 95285)
+++ z3c.recipe.kgstest/trunk/src/z3c/recipe/kgstest/README.txt	2009-01-28 10:16:26 UTC (rev 95286)
@@ -10,12 +10,13 @@
 ... [kgstest]
 ... recipe = z3c.recipe.kgstest
 ... exclude = .*
-... include = zope.dottedname
+... include = z3c.recipe.kgstest
 ... """)
 >>> system(buildout).find('Installing kgstest') != -1
 True
 >>> ls('bin')
 - buildout
-- kgstest-zope.dottedname
->>> cat('bin', 'kgstest-zope.dottedname')
+- kgstest-z3c.recipe.kgstest
+>>> cat('bin', 'kgstest-z3c.recipe.kgstest')
 #!/...python...
+...zope.dottedname...

Modified: z3c.recipe.kgstest/trunk/src/z3c/recipe/kgstest/recipe.py
===================================================================
--- z3c.recipe.kgstest/trunk/src/z3c/recipe/kgstest/recipe.py	2009-01-28 10:02:20 UTC (rev 95285)
+++ z3c.recipe.kgstest/trunk/src/z3c/recipe/kgstest/recipe.py	2009-01-28 10:16:26 UTC (rev 95286)
@@ -1,6 +1,9 @@
 import os
+import pkg_resources
 import popen2
 import re
+import zc.buildout.easy_install
+import zc.recipe.egg
 import zc.recipe.testrunner
 
 
@@ -16,6 +19,7 @@
            'zope.webdev', 'zope.xmlpickle', 'zope.app.boston',]
 INCLUDE = ['zope.*', 'grokcore.*']
 
+
 def string2list(string, default):
     result = string and string.split('\n') or default
     return [item.strip() for item in result]
@@ -33,12 +37,16 @@
         self.include = string2list(self.options.get('include', ''), INCLUDE)
 
     def install(self):
-        self.update()
+        return self.update()
 
     def update(self):
         files = []
         for project in self._wanted_projects():
-            options = dict(eggs=project)
+            if self._needs_test_dependencies(project):
+                extra = ' [test]'
+            else:
+                extra = ''
+            options = dict(eggs=project + extra)
             recipe = zc.recipe.testrunner.TestRunner(
                 self.buildout, '%s-%s' % (self.name, project), options)
             files.extend(recipe.install())
@@ -61,3 +69,14 @@
             if not skip:
                 projects.append(project)
         return projects
+
+    def _needs_test_dependencies(self, package):
+        options = dict(eggs=package)
+        saved_newest = self.buildout['buildout'].get('newest', None)
+        self.buildout['buildout']['newest'] = 'true'
+        eggs = zc.recipe.egg.Egg(self.buildout, self.name, options)
+        _, ws = eggs.working_set()
+        latest = ws.find(pkg_resources.Requirement.parse(package))
+        if saved_newest:
+            self.buildout['buildout']['newest'] = saved_newest
+        return 'test' in latest.extras



More information about the Checkins mailing list