[Checkins] SVN: z3c.recipe.kgs/trunk/ mock-up of z3c.recipe.kgs, let's see if this is the right path
Fabio Tranchitella
kobold at kobold.it
Mon Aug 3 16:21:32 EDT 2009
Log message for revision 102467:
mock-up of z3c.recipe.kgs, let's see if this is the right path
Changed:
_U z3c.recipe.kgs/trunk/
A z3c.recipe.kgs/trunk/CHANGES.txt
A z3c.recipe.kgs/trunk/README.txt
A z3c.recipe.kgs/trunk/bootstrap.py
A z3c.recipe.kgs/trunk/buildout.cfg
A z3c.recipe.kgs/trunk/setup.py
A z3c.recipe.kgs/trunk/src/
A z3c.recipe.kgs/trunk/src/z3c/
A z3c.recipe.kgs/trunk/src/z3c/__init__.py
A z3c.recipe.kgs/trunk/src/z3c/recipe/
A z3c.recipe.kgs/trunk/src/z3c/recipe/__init__.py
A z3c.recipe.kgs/trunk/src/z3c/recipe/kgs/
A z3c.recipe.kgs/trunk/src/z3c/recipe/kgs/__init__.py
A z3c.recipe.kgs/trunk/src/z3c/recipe/kgs/recipe.py
A z3c.recipe.kgs/trunk/src/z3c/recipe/kgs/runner.py
A z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/
A z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/PKG-INFO
A z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/SOURCES.txt
A z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/dependency_links.txt
A z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/entry_points.txt
A z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/namespace_packages.txt
A z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/not-zip-safe
A z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/requires.txt
A z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/top_level.txt
-=-
Property changes on: z3c.recipe.kgs/trunk
___________________________________________________________________
Added: svn:ignore
+ *.pyc
*.pyo
bin
parts
eggs
develop-eggs
.installed.cfg
Added: z3c.recipe.kgs/trunk/CHANGES.txt
===================================================================
--- z3c.recipe.kgs/trunk/CHANGES.txt (rev 0)
+++ z3c.recipe.kgs/trunk/CHANGES.txt 2009-08-03 20:21:32 UTC (rev 102467)
@@ -0,0 +1,8 @@
+=======
+CHANGES
+=======
+
+0.1 (unreleased)
+================
+
+- first public release
Added: z3c.recipe.kgs/trunk/README.txt
===================================================================
--- z3c.recipe.kgs/trunk/README.txt (rev 0)
+++ z3c.recipe.kgs/trunk/README.txt 2009-08-03 20:21:32 UTC (rev 102467)
@@ -0,0 +1,6 @@
+==============
+z3c.recipe.kgs
+==============
+
+This buildout recipe generates a list of packages to test and a test runner
+that runs each package's tests (isolated from any other tests) from a KGS.
Added: z3c.recipe.kgs/trunk/bootstrap.py
===================================================================
--- z3c.recipe.kgs/trunk/bootstrap.py (rev 0)
+++ z3c.recipe.kgs/trunk/bootstrap.py 2009-08-03 20:21:32 UTC (rev 102467)
@@ -0,0 +1,55 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id$
+"""
+
+import os, shutil, sys, tempfile, urllib2
+
+tmpeggs = tempfile.mkdtemp()
+
+try:
+ import pkg_resources
+except ImportError:
+ ez = {}
+ exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+ ).read() in ez
+ ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+ import pkg_resources
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+if sys.platform == 'win32':
+ cmd = '"%s"' % cmd # work around spawn lamosity on windows
+
+ws = pkg_resources.working_set
+assert os.spawnle(
+ os.P_WAIT, sys.executable, sys.executable,
+ '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
+ dict(os.environ,
+ PYTHONPATH=
+ ws.find(pkg_resources.Requirement.parse('setuptools')).location
+ ),
+ ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout')
+import zc.buildout.buildout
+zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
+shutil.rmtree(tmpeggs)
Added: z3c.recipe.kgs/trunk/buildout.cfg
===================================================================
--- z3c.recipe.kgs/trunk/buildout.cfg (rev 0)
+++ z3c.recipe.kgs/trunk/buildout.cfg 2009-08-03 20:21:32 UTC (rev 102467)
@@ -0,0 +1,17 @@
+[buildout]
+develop = .
+parts = test test-kgs
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = z3c.recipe.kgs
+
+[test-kgs]
+recipe = z3c.recipe.kgs
+kgs = http://svn.zope.org/*checkout*/zope.release/trunk/releases/controlled-packages.cfg
+max_jobs = 1
+packages = zope.interface
+ zope.component
+ zope.interface
+ zope.event
+ zope.configuration
Added: z3c.recipe.kgs/trunk/setup.py
===================================================================
--- z3c.recipe.kgs/trunk/setup.py (rev 0)
+++ z3c.recipe.kgs/trunk/setup.py 2009-08-03 20:21:32 UTC (rev 102467)
@@ -0,0 +1,37 @@
+from setuptools import setup, find_packages
+
+
+setup(
+ name='z3c.recipe.kgs',
+ version='0.1dev',
+ author='Fabio Tranchitella',
+ author_email='fabio at tranchitella.it',
+ description='Buildout recipe to create testrunners for testing compatibility with packages from a KGS',
+ url='http://pypi.python.org/pypi/z3c.recipe.kgs',
+ long_description=(
+ open('README.txt').read() + '\n\n' +
+ open('CHANGES.txt').read()),
+ keywords="zope3 setuptools egg kgs",
+ classifiers=[
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :: Zope Public License',
+ 'Programming Language :: Python',
+ 'Operating System :: OS Independent',
+ 'Framework :: Zope3'],
+ license='ZPL 2.1',
+ packages=find_packages('src'),
+ package_dir={'': 'src'},
+ namespace_packages=['z3c', 'z3c.recipe'],
+ install_requires=[
+ 'setuptools',
+ 'zc.buildout',
+ 'zc.recipe.egg',
+ 'zc.recipe.testrunner',
+ 'zope.kgs',
+ ],
+ entry_points = {
+ 'zc.buildout': ['default = z3c.recipe.kgs.recipe:Recipe'],
+ },
+ include_package_data=True,
+ zip_safe=False,
+)
Added: z3c.recipe.kgs/trunk/src/z3c/__init__.py
===================================================================
--- z3c.recipe.kgs/trunk/src/z3c/__init__.py (rev 0)
+++ z3c.recipe.kgs/trunk/src/z3c/__init__.py 2009-08-03 20:21:32 UTC (rev 102467)
@@ -0,0 +1,5 @@
+try:
+ __import__('pkg_resources').declare_namespace(__name__)
+except ImportError, e:
+ from pkgutil import extend_path
+ __path__ = extend_path(__path__, __name__)
Added: z3c.recipe.kgs/trunk/src/z3c/recipe/__init__.py
===================================================================
--- z3c.recipe.kgs/trunk/src/z3c/recipe/__init__.py (rev 0)
+++ z3c.recipe.kgs/trunk/src/z3c/recipe/__init__.py 2009-08-03 20:21:32 UTC (rev 102467)
@@ -0,0 +1,5 @@
+try:
+ __import__('pkg_resources').declare_namespace(__name__)
+except ImportError, e:
+ from pkgutil import extend_path
+ __path__ = extend_path(__path__, __name__)
Added: z3c.recipe.kgs/trunk/src/z3c/recipe/kgs/__init__.py
===================================================================
--- z3c.recipe.kgs/trunk/src/z3c/recipe/kgs/__init__.py (rev 0)
+++ z3c.recipe.kgs/trunk/src/z3c/recipe/kgs/__init__.py 2009-08-03 20:21:32 UTC (rev 102467)
@@ -0,0 +1 @@
+# python package
Added: z3c.recipe.kgs/trunk/src/z3c/recipe/kgs/recipe.py
===================================================================
--- z3c.recipe.kgs/trunk/src/z3c/recipe/kgs/recipe.py (rev 0)
+++ z3c.recipe.kgs/trunk/src/z3c/recipe/kgs/recipe.py 2009-08-03 20:21:32 UTC (rev 102467)
@@ -0,0 +1,64 @@
+import os
+
+from pkg_resources import Requirement
+from zc.buildout.easy_install import scripts
+from zc.recipe.egg import Egg
+from zc.recipe.testrunner import TestRunner
+from zope.kgs import kgs
+
+
+class Recipe(object):
+ """Recipe for z3c.recipe.kgs"""
+
+ def __init__(self, buildout, name, options):
+ self.buildout = buildout
+ self.name = name
+ self.options = options
+ self.packages = options.get('packages')
+ self.script = options.get('script', self.name)
+ self.max_jobs = options.get('max_jobs', 1)
+ self.kgs = kgs.KGS(options['kgs'])
+
+ def install(self):
+ return self.update()
+
+ def update(self):
+ runners = []
+ installed = []
+ # loop on the packages from the KGS
+ for package in self.kgs.packages:
+ # skip the package if it is marked as "not tested" or
+ # if it is not in the list "packages", if defined
+ if not package.tested or \
+ self.packages is not None and \
+ package.name not in self.packages:
+ continue
+ # get the extra and test dependencies
+ eggs = Egg(self.buildout, self.name, dict(
+ eggs='%s == %s' % (package.name, package.versions[-1])
+ ))
+ working_set = eggs.working_set()[1]
+ extras = working_set.find(Requirement.parse(package.name)).extras
+ # install the test runner for the package
+ options = dict(eggs="%s [%s] == %s" % (
+ package.name, ','.join(extras), package.versions[-1],
+ ))
+ name = '%s-%s' % (self.name, package.name)
+ recipe = TestRunner(self.buildout, name, options)
+ runners.append(repr(os.path.join(
+ self.buildout['buildout']['bin-directory'], name)))
+ installed.extend(recipe.install())
+ # install the KGS test runner
+ eggs = Egg(self.buildout, self.name, dict(eggs='z3c.recipe.kgs'))
+ working_set = eggs.working_set()[1]
+ installed.extend(scripts(
+ [(self.script, 'z3c.recipe.kgs.runner', 'main')], working_set,
+ self.buildout['buildout']['executable'],
+ self.buildout['buildout']['bin-directory'],
+ arguments='%s,\n ' % self.max_jobs + \
+ ',\n '.join(runners) + '\n ')
+ )
+ # return the list of installed recipes
+ return installed
+
+
Added: z3c.recipe.kgs/trunk/src/z3c/recipe/kgs/runner.py
===================================================================
--- z3c.recipe.kgs/trunk/src/z3c/recipe/kgs/runner.py (rev 0)
+++ z3c.recipe.kgs/trunk/src/z3c/recipe/kgs/runner.py 2009-08-03 20:21:32 UTC (rev 102467)
@@ -0,0 +1,104 @@
+import StringIO
+import os.path
+import select
+import subprocess
+import sys
+import time
+import pickle
+
+
+def usage():
+ print """
+usage: %s [OPTIONS]
+
+All given options will be passed to each test runner. To know which
+options you can use, refer to the test runner documentation.
+""" % sys.argv[0]
+
+class Job(object):
+
+ def __init__(self, script, args):
+ self.script = script
+ self.args = args
+ self.name = os.path.basename(script)
+ self.output = StringIO.StringIO()
+ self.exitcode = None
+
+ def start(self):
+ self.start = time.time()
+ self.process = subprocess.Popen(
+ [self.script, '--exit-with-status'] + self.args,
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ close_fds=True)
+
+ def poll(self):
+ self.exitcode = self.process.poll()
+ if self.exitcode is not None:
+ self.end = time.time()
+ read, _, _ = select.select([self.process.stdout], [], [], 0.01)
+ if read:
+ self.output.write(read[0].read())
+
+
+def main(max_jobs, *scripts):
+ argv = sys.argv[1:]
+ if '-h' in argv or '--help' in argv:
+ usage()
+ return
+
+ running = []
+ completed = []
+ scripts = list(scripts)
+
+ # Read statistics from the last run and re-order testing to start
+ # the slowest tests first.
+ stat_file_name = os.path.join(os.path.expanduser('~'), '.zope.teststats')
+ try:
+ stat_file = open(stat_file_name, 'r')
+ except IOError:
+ stats = {}
+ else:
+ stats = pickle.load(stat_file)
+ stat_file.close()
+ if stats:
+ default_time = sum(stats.values()) / float(len(stats))
+ else:
+ default_time = 0
+ scripts.sort(key=lambda package:-stats.get(os.path.basename(package), default_time))
+
+ # Main loop for controlling test runs
+ while scripts or running:
+ for job in running:
+ job.poll()
+ if job.exitcode is None:
+ continue
+ completed.append(job)
+ running.remove(job)
+ if job.exitcode:
+ print "%s failed with:" % job.name
+ print job.output.getvalue()
+
+ while (len(running) < max_jobs) and scripts:
+ script = scripts.pop(0)
+ job = Job(script, sys.argv[1:])
+ print "Running %s" % job.name
+ job.start()
+ running.append(job)
+
+ # Result output
+ failures = [job for job in completed if job.exitcode]
+ print "%d failure(s)." % len(failures)
+ for job in failures:
+ print "-", job.name
+
+ # Store statistics
+ for job in completed:
+ stats[job.name] = job.end - job.start
+ try:
+ stat_file = open(stat_file_name, 'w')
+ except IOError:
+ # Statistics aren't that important. Just ignore that.
+ pass
+ else:
+ pickle.dump(stats, stat_file)
Added: z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/PKG-INFO
===================================================================
--- z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/PKG-INFO (rev 0)
+++ z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/PKG-INFO 2009-08-03 20:21:32 UTC (rev 102467)
@@ -0,0 +1,32 @@
+Metadata-Version: 1.0
+Name: z3c.recipe.kgs
+Version: 0.1dev
+Summary: Buildout recipe to create testrunners for testing compatibility with packages from a KGS
+Home-page: http://pypi.python.org/pypi/z3c.recipe.kgs
+Author: Fabio Tranchitella
+Author-email: fabio at tranchitella.it
+License: ZPL 2.1
+Description: ==============
+ z3c.recipe.kgs
+ ==============
+
+ This buildout recipe generates a list of packages to test and a test runner
+ that runs each package's tests (isolated from any other tests) from a KGS.
+
+
+ =======
+ CHANGES
+ =======
+
+ 0.1 (unreleased)
+ ================
+
+ - first public release
+
+Keywords: zope3 setuptools egg kgs
+Platform: UNKNOWN
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: Zope Public License
+Classifier: Programming Language :: Python
+Classifier: Operating System :: OS Independent
+Classifier: Framework :: Zope3
Added: z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/SOURCES.txt
===================================================================
--- z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/SOURCES.txt (rev 0)
+++ z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/SOURCES.txt 2009-08-03 20:21:32 UTC (rev 102467)
@@ -0,0 +1,15 @@
+README.txt
+setup.py
+src/z3c/__init__.py
+src/z3c.recipe.kgs.egg-info/PKG-INFO
+src/z3c.recipe.kgs.egg-info/SOURCES.txt
+src/z3c.recipe.kgs.egg-info/dependency_links.txt
+src/z3c.recipe.kgs.egg-info/entry_points.txt
+src/z3c.recipe.kgs.egg-info/namespace_packages.txt
+src/z3c.recipe.kgs.egg-info/not-zip-safe
+src/z3c.recipe.kgs.egg-info/requires.txt
+src/z3c.recipe.kgs.egg-info/top_level.txt
+src/z3c/recipe/__init__.py
+src/z3c/recipe/kgs/__init__.py
+src/z3c/recipe/kgs/recipe.py
+src/z3c/recipe/kgs/runner.py
\ No newline at end of file
Added: z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/dependency_links.txt
===================================================================
--- z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/dependency_links.txt (rev 0)
+++ z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/dependency_links.txt 2009-08-03 20:21:32 UTC (rev 102467)
@@ -0,0 +1 @@
+
Added: z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/entry_points.txt
===================================================================
--- z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/entry_points.txt (rev 0)
+++ z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/entry_points.txt 2009-08-03 20:21:32 UTC (rev 102467)
@@ -0,0 +1,3 @@
+[zc.buildout]
+default = z3c.recipe.kgs.recipe:Recipe
+
Added: z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/namespace_packages.txt
===================================================================
--- z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/namespace_packages.txt (rev 0)
+++ z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/namespace_packages.txt 2009-08-03 20:21:32 UTC (rev 102467)
@@ -0,0 +1,2 @@
+z3c
+z3c.recipe
Added: z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/not-zip-safe
===================================================================
--- z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/not-zip-safe (rev 0)
+++ z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/not-zip-safe 2009-08-03 20:21:32 UTC (rev 102467)
@@ -0,0 +1 @@
+
Added: z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/requires.txt
===================================================================
--- z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/requires.txt (rev 0)
+++ z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/requires.txt 2009-08-03 20:21:32 UTC (rev 102467)
@@ -0,0 +1,5 @@
+setuptools
+zc.buildout
+zc.recipe.egg
+zc.recipe.testrunner
+zope.kgs
\ No newline at end of file
Added: z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/top_level.txt
===================================================================
--- z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/top_level.txt (rev 0)
+++ z3c.recipe.kgs/trunk/src/z3c.recipe.kgs.egg-info/top_level.txt 2009-08-03 20:21:32 UTC (rev 102467)
@@ -0,0 +1 @@
+z3c
More information about the Checkins
mailing list