[Checkins] SVN: z3c.recipe.compattest/trunk/ merged 106426:106430 branches/reinout-requirements

Reinout van Rees reinout at vanrees.org
Sat Dec 12 05:56:44 EST 2009


Log message for revision 106434:
  merged 106426:106430 branches/reinout-requirements
  Addition of include-dependencies option.

Changed:
  U   z3c.recipe.compattest/trunk/CHANGES.txt
  U   z3c.recipe.compattest/trunk/src/z3c/recipe/compattest/README.txt
  U   z3c.recipe.compattest/trunk/src/z3c/recipe/compattest/recipe.py

-=-
Modified: z3c.recipe.compattest/trunk/CHANGES.txt
===================================================================
--- z3c.recipe.compattest/trunk/CHANGES.txt	2009-12-11 22:55:48 UTC (rev 106433)
+++ z3c.recipe.compattest/trunk/CHANGES.txt	2009-12-12 10:56:43 UTC (rev 106434)
@@ -5,7 +5,10 @@
 0.12 (unreleased)
 =================
 
-- Nothing changed yet.
+- Added ``include-dependencies`` option that automatically includes the
+  dependencies of the specified packages.  Very handy to get an automatically
+  updated list of those packages that are most useful to test: all our
+  dependencies.
 
 
 0.11 (2009-09-30)

Modified: z3c.recipe.compattest/trunk/src/z3c/recipe/compattest/README.txt
===================================================================
--- z3c.recipe.compattest/trunk/src/z3c/recipe/compattest/README.txt	2009-12-11 22:55:48 UTC (rev 106433)
+++ z3c.recipe.compattest/trunk/src/z3c/recipe/compattest/README.txt	2009-12-12 10:56:43 UTC (rev 106434)
@@ -15,6 +15,8 @@
 
 - ``include``: list of packages to include (whitespace-separated)
   (default: empty)
+- ``include-dependencies``: list of packages to include *including* their
+  direct dependencies.  (default: empty)
 - ``exclude``: packages matching any regex in this list will be excluded
   (default: empty)
 - ``script``: the name of the runner script (defaults to the part name)
@@ -56,7 +58,33 @@
 #!...python...
 ...zope.dottedname...
 
+If we use ``include-dependencies`` instead of just ``include``, our direct
+dependencies are also picked up, for instance zc.buildout:
 
+>>> write('buildout.cfg', """
+... [buildout]
+... parts = compattest
+...
+... [compattest]
+... recipe = z3c.recipe.compattest
+... include-dependencies = z3c.recipe.compattest
+... """)
+>>> print 'start', system(buildout)
+start ...
+Generated script '/sample-buildout/bin/compattest-zc.buildout'.
+...
+Generated script '/sample-buildout/bin/compattest'.
+
+All our direct dependencies have a test script now:
+
+>>> ls('bin')
+- buildout
+- compattest
+- compattest-z3c.recipe.compattest
+- compattest-zc.buildout
+- compattest-zc.recipe.testrunner
+
+
 Passing options to the test runners
 ===================================
 

Modified: z3c.recipe.compattest/trunk/src/z3c/recipe/compattest/recipe.py
===================================================================
--- z3c.recipe.compattest/trunk/src/z3c/recipe/compattest/recipe.py	2009-12-11 22:55:48 UTC (rev 106433)
+++ z3c.recipe.compattest/trunk/src/z3c/recipe/compattest/recipe.py	2009-12-12 10:56:43 UTC (rev 106434)
@@ -25,6 +25,8 @@
             options['max_jobs'] = '1'
 
         self.include = string2list(self.options.get('include', ''), [])
+        self.include_dependencies = string2list(
+            self.options.get('include-dependencies', ''), [])
         self.exclude = string2list(self.options.get('exclude', ''), [])
         self.extra_paths = self.options.get('extra-paths', '')
         self.wanted_packages = self._wanted_packages()
@@ -77,8 +79,25 @@
             bindir, arguments='%s, %s' % (self.options['max_jobs'],
                                           ', '.join(runners)))
 
+    def _find_dependencies(self):
+        result = []
+        if not self.include_dependencies:
+            return result
+        for package in self.include_dependencies:
+            result.append(package)
+            ws = self._working_set(package)
+            dist = ws.find(pkg_resources.Requirement.parse(package))
+            for requirement in dist.requires():
+                dist = ws.find(requirement)
+                if not dist:
+                    continue
+                result.append(dist.project_name)
+        return result
+
+
     def _wanted_packages(self):
-        projects = self.include
+        projects = self.include + self._find_dependencies()
+        projects = set(projects) # Filter out duplicates.
         for project in projects:
             for regex in self.exclude:
                 if re.compile(regex).search(project):



More information about the checkins mailing list