[Checkins] SVN: Sandbox/J1m/zookeeper-static/ Added test setup command. (Now require setuptools or distribute.)
Jim Fulton
jim at zope.com
Sun Nov 27 21:32:52 UTC 2011
Log message for revision 123501:
Added test setup command. (Now require setuptools or distribute.)
Changed:
U Sandbox/J1m/zookeeper-static/MANIFEST.in
U Sandbox/J1m/zookeeper-static/get_source_files.py
U Sandbox/J1m/zookeeper-static/setup.py
-=-
Modified: Sandbox/J1m/zookeeper-static/MANIFEST.in
===================================================================
--- Sandbox/J1m/zookeeper-static/MANIFEST.in 2011-11-27 20:16:31 UTC (rev 123500)
+++ Sandbox/J1m/zookeeper-static/MANIFEST.in 2011-11-27 21:32:51 UTC (rev 123501)
@@ -5,3 +5,5 @@
include c.tgz
include pyzk_docstrings.h
include zookeeper.c
+include src/zookeepertests/*
+
Modified: Sandbox/J1m/zookeeper-static/get_source_files.py
===================================================================
--- Sandbox/J1m/zookeeper-static/get_source_files.py 2011-11-27 20:16:31 UTC (rev 123500)
+++ Sandbox/J1m/zookeeper-static/get_source_files.py 2011-11-27 21:32:51 UTC (rev 123501)
@@ -5,12 +5,37 @@
def main():
[srcdir] = sys.argv[1:]
here = os.getcwd()
+ if os.path.exists(os.path.join(here, 'src')):
+ shutil.rmtree(os.path.join(here, 'src'))
+ os.mkdir(os.path.join(here, 'src'))
os.chdir(os.path.join(srcdir, 'src'))
os.system("tar czf %s c" % os.path.join(here, 'c.tgz'))
shutil.copy(os.path.join('c', 'LICENSE'), here)
os.chdir(os.path.join('contrib', 'zkpython'))
shutil.copy('README', os.path.join(here, 'ORIGINAL-README'))
- os.chdir(os.path.join('src', 'c'))
+ os.chdir(os.path.join('src'))
+ shutil.copytree('test', os.path.join(here, 'src', 'zookeepertests'))
+ open(os.path.join(here, 'src', 'zookeepertests', '__init__.py'),
+ 'w').close()
+ connection_test = open(
+ os.path.join(here, 'src', 'zookeepertests', 'connection_test.py')
+ ).read()
+ f = open(
+ os.path.join(here, 'src', 'zookeepertests', 'connection_test.py'),
+ 'w')
+ if ('handles = [ zookeeper.init(self.host) for i in xrange(63) ]'
+ in connection_test):
+ connection_test = connection_test.replace(
+ 'handles = [ zookeeper.init(self.host) for i in xrange(63) ]',
+ 'handles = [ zookeeper.init(self.host) for i in xrange(9) ]')
+ else:
+ connection_test = connection_test.replace('testmanyhandles',
+ 'disabledtestmanyhandles')
+
+
+ f.write(connection_test)
+ f.close()
+ os.chdir(os.path.join('c'))
shutil.copy('pyzk_docstrings.h', here)
shutil.copy('zookeeper.c', here)
os.chdir(here)
Modified: Sandbox/J1m/zookeeper-static/setup.py
===================================================================
--- Sandbox/J1m/zookeeper-static/setup.py 2011-11-27 20:16:31 UTC (rev 123500)
+++ Sandbox/J1m/zookeeper-static/setup.py 2011-11-27 21:32:51 UTC (rev 123501)
@@ -24,6 +24,7 @@
import distutils.command.build_ext
import distutils.core
+import setuptools
import os
import shutil
import time
@@ -46,7 +47,30 @@
distutils.command.build_ext.build_ext.run(self)
-distutils.core.setup(
+import setuptools.command.test
+class Test(setuptools.command.test.test):
+ def run(self):
+ import socket
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ s.settimeout(1.0)
+ ruok = None
+ try:
+ s.connect(('localhost', 22182))
+ s.send('ruok')
+ ruok = s.recv(4)
+ except socket.error:
+ pass
+ if ruok != 'imok':
+ raise SystemError(
+ 'You must be running a testing ZooKeeper server on port 22182')
+
+ os.environ["ZKPY_LOG_DIR"] = '.'
+ setuptools.command.test.test.run(self)
+
+import sys
+sys.path.append('src')
+
+setuptools.setup(
author = 'Henry Robinson',
author_email = 'henry at cloudera.com',
license = 'Apache',
@@ -54,7 +78,8 @@
name = name, version = version,
long_description=open('README.txt').read(),
description = open('README.txt').read().strip().split('\n')[0],
- cmdclass={'build_ext': build_ext},
+ cmdclass=dict(build_ext=build_ext, test=Test),
+ test_suite = 'zookeepertests',
ext_modules=[
distutils.core.Extension(
"zookeeper",
More information about the checkins
mailing list