[pypy-svn] r35562 - in pypy/dist/pypy/tool/build: . bin builds test

guido at codespeak.net guido at codespeak.net
Mon Dec 11 11:43:12 CET 2006


Author: guido
Date: Mon Dec 11 11:43:09 2006
New Revision: 35562

Modified:
   pypy/dist/pypy/tool/build/bin/client
   pypy/dist/pypy/tool/build/builds/   (props changed)
   pypy/dist/pypy/tool/build/client.py
   pypy/dist/pypy/tool/build/config.py
   pypy/dist/pypy/tool/build/conftest.py
   pypy/dist/pypy/tool/build/server.py
   pypy/dist/pypy/tool/build/test/test_client.py
   pypy/dist/pypy/tool/build/test/test_pypybuilder.py
Log:
Updated functional tests, added some more warnings about time.sleep(), added
missing test for channelwrapper, added build subdirs to svn:ignore, some
whitespace and cleanups, being a bit extra careful in shutting down client
and server (still sometimes exceptions in remote processes on shutdown,
though), using better config defaults.


Modified: pypy/dist/pypy/tool/build/bin/client
==============================================================================
--- pypy/dist/pypy/tool/build/bin/client	(original)
+++ pypy/dist/pypy/tool/build/bin/client	Mon Dec 11 11:43:09 2006
@@ -38,7 +38,7 @@
                 )
             sysinfo, compileinfo = data
             # XXX we should compile here, using data dict for info
-            print 'compilation requested for info %r, now faking that' % (
+            print 'compilation requested for info %r\n\nbuilding...' % (
                     data,)
             config = pypyoption.get_pypy_config()
             config.override(compileinfo)

Modified: pypy/dist/pypy/tool/build/client.py
==============================================================================
--- pypy/dist/pypy/tool/build/client.py	(original)
+++ pypy/dist/pypy/tool/build/client.py	Mon Dec 11 11:43:09 2006
@@ -1,7 +1,6 @@
 import thread
 import py
 from zipfile import ZipFile
-from cStringIO import StringIO
 
 
 class PPBClient(object):
@@ -33,6 +32,7 @@
             fp = buildpath.zipfile.open('w')
             try:
                 while True:
+                    # read data in chunks
                     try:
                         chunk = self.channel.receive()
                     except EOFError:
@@ -58,12 +58,15 @@
             client = PPBClient(channel, %r, %r)
             client.sit_and_wait()
         except:
-            import sys, traceback
-            exc, e, tb = sys.exc_info()
-            channel.send(str(exc) + ' - ' + str(e))
-            for line in traceback.format_tb(tb):
-                channel.send(line[:-1])
-            del tb
+            try:
+                import sys, traceback
+                exc, e, tb = sys.exc_info()
+                channel.send(str(exc) + ' - ' + str(e))
+                for line in traceback.format_tb(tb):
+                    channel.send(line[:-1])
+                del tb
+            except:
+                pass
     finally:
         channel.close()
 """
@@ -114,5 +117,3 @@
             print exc
             continue
     zip.close()
-    channel.send(None)
-   

Modified: pypy/dist/pypy/tool/build/config.py
==============================================================================
--- pypy/dist/pypy/tool/build/config.py	(original)
+++ pypy/dist/pypy/tool/build/config.py	Mon Dec 11 11:43:09 2006
@@ -3,7 +3,7 @@
 packageparent = py.magic.autopath().dirpath().dirpath().dirpath().dirpath()
 
 # general settings, used by both server and client
-server = '134.99.66.245'
+server = 'localhost'
 port = 12321
 path = [str(packageparent)]
 
@@ -25,9 +25,9 @@
 # settings for the server
 projectname = 'pypy'
 buildpath = packageparent.join('/pypy/tool/build/builds')
-mailhost = '127.0.0.1'
+mailhost = 'localhost'
 mailport = 25
-mailfrom = 'johnny at johnnydebris.net'
+mailfrom = 'pypybuilds at codespeak.net'
 
 # settings for the tests
 testpath = [str(py.magic.autopath().dirpath().dirpath())]

Modified: pypy/dist/pypy/tool/build/conftest.py
==============================================================================
--- pypy/dist/pypy/tool/build/conftest.py	(original)
+++ pypy/dist/pypy/tool/build/conftest.py	Mon Dec 11 11:43:09 2006
@@ -3,18 +3,18 @@
                                             ReSTChecker
 mypath = py.magic.autopath().dirpath()
 
-Option = py.test.Config.Option 
-option = py.test.Config.addoptions("pypybuilder test options", 
+Option = py.test.Config.Option
+option = py.test.Config.addoptions("pypybuilder test options",
         Option('', '--functional',
                action="store_true", dest="functional", default=False,
                help="run pypybuilder functional tests"
         ),
-) 
+)
 
 py.test.pypybuilder_option = option
 
 class Directory(Dir):
     def run(self):
         if self.fspath == mypath:
-            return ['README.txt', 'test']
+            return ['test']
         return super(Directory, self).run()

Modified: pypy/dist/pypy/tool/build/server.py
==============================================================================
--- pypy/dist/pypy/tool/build/server.py	(original)
+++ pypy/dist/pypy/tool/build/server.py	Mon Dec 11 11:43:09 2006
@@ -314,12 +314,18 @@
 
             server.serve_forever()
         except:
-            import sys, traceback
-            exc, e, tb = sys.exc_info()
-            channel.send(str(exc) + ' - ' + str(e))
-            for line in traceback.format_tb(tb):
-                channel.send(line[:1])
-            del tb
+            try:
+                import sys, traceback
+                exc, e, tb = sys.exc_info()
+                channel.send(str(exc) + ' - ' + str(e))
+                for line in traceback.format_tb(tb):
+                    channel.send(line[:1])
+                del tb
+            except:
+                try:
+                    channel.close()
+                except:
+                    pass
     finally:
         channel.close()
 """

Modified: pypy/dist/pypy/tool/build/test/test_client.py
==============================================================================
--- pypy/dist/pypy/tool/build/test/test_client.py	(original)
+++ pypy/dist/pypy/tool/build/test/test_client.py	Mon Dec 11 11:43:09 2006
@@ -41,3 +41,20 @@
     
     assert done[0] == info
     assert done[1] == (temp / 'build-0')
+
+def test_channelwrapper():
+    class FakeChannel(object):
+        def __init__(self):
+            self.buffer = []
+        def send(self, data):
+            self.buffer.append(data)
+    c = FakeChannel()
+    cw = client.ChannelWrapper(c)
+    assert cw.tell() == 0
+    cw.write('foo')
+    cw.write('bar')
+    assert cw.tell() == 6
+    cw.write('baz')
+    cw.close()
+    assert c.buffer == ['foo', 'bar', 'baz', None]
+

Modified: pypy/dist/pypy/tool/build/test/test_pypybuilder.py
==============================================================================
--- pypy/dist/pypy/tool/build/test/test_pypybuilder.py	(original)
+++ pypy/dist/pypy/tool/build/test/test_pypybuilder.py	Mon Dec 11 11:43:09 2006
@@ -4,9 +4,13 @@
 from pypy.config import config as pypyconfig
 import py
 
+# XXX NOTE: if you encounter failing tests on a slow system, you may want to
+# increase the sleep interval a bit to see if that helps...
+SLEEP_INTERVAL = 1.0
+
 def _get_sysconfig():
     return pypyconfig.Config(
-        pypyconfig.OptionDescription('foo', [
+        pypyconfig.OptionDescription('foo', '', [
             pypyconfig.ChoiceOption('foo', 'foo', [1,2,3], 1),
         ])
     )
@@ -21,16 +25,14 @@
     # system, but for instance contains time.sleep()s to make sure all threads
     # get the time to perform tasks and such... 
 
-    sleep_interval = 0.3
-
     # first initialize a server
     sgw = py.execnet.PopenGateway()
     temppath = py.test.ensuretemp('pypybuilder-functional')
-    sc = server.init(sgw, port=config.port, path=config.testpath, 
-                        buildpath=str(temppath))
+    sc = server.init(sgw, port=config.port, path=config.testpath,
+                     buildpath=str(temppath))
 
     # give the server some time to wake up
-    py.std.time.sleep(sleep_interval)
+    py.std.time.sleep(SLEEP_INTERVAL)
 
     # then two clients, both with different system info
     sysconfig1 = _get_sysconfig()
@@ -43,7 +45,7 @@
     cc2 = client.init(cgw2, sysconfig2, port=config.port, testing=True)
 
     # give the clients some time to register themselves
-    py.std.time.sleep(sleep_interval)
+    py.std.time.sleep(SLEEP_INTERVAL)
 
     # now we're going to send some compile jobs
     code = """
@@ -58,11 +60,11 @@
     compconf = execnetconference.conference(compgw, config.port)
 
     # this one should fail because there's no client found for foo = 3
-    compc = compconf.remote_exec(code % (config.testpath, 'foo1 at bar.com', 
+    compc = compconf.remote_exec(code % (config.testpath, 'foo1 at bar.com',
                                             {'foo': 3}))
     
     # sorry...
-    py.std.time.sleep(sleep_interval)
+    py.std.time.sleep(SLEEP_INTERVAL)
 
     ret = compc.receive()
     assert not ret[0]
@@ -73,18 +75,18 @@
                                             {'foo': 1}))
     
     # and another one
-    py.std.time.sleep(sleep_interval)
+    py.std.time.sleep(SLEEP_INTERVAL)
     
     ret = compc.receive()
     assert not ret[0]
     assert ret[1].find('found a suitable client') > -1
 
     # the messages may take a bit to arrive, too
-    py.std.time.sleep(sleep_interval)
+    py.std.time.sleep(SLEEP_INTERVAL)
 
     # client 1 should by now have received the info to build for
     cc1.receive() # 'welcome'
-    ret = cc1.receive() 
+    ret = cc1.receive()
     assert ret == ({'foo': 1}, {})
 
     # this should have created a package in the temp dir
@@ -97,7 +99,7 @@
     cc3 = client.init(cgw3, sysconfig3, port=config.port, testing=True)
 
     # again a bit of waiting may be desired
-    py.std.time.sleep(sleep_interval)
+    py.std.time.sleep(SLEEP_INTERVAL)
 
     # _try_queued() should check whether there are new clients available for 
     # queued jobs
@@ -115,8 +117,7 @@
     compgw2 = py.execnet.PopenGateway()
     compconf2 = execnetconference.conference(compgw2, config.port)
 
-    compc2 = compconf2.remote_exec(code % (config.testpath, sleep_interval))
-
+    compc2 = compconf2.remote_exec(code % (config.testpath, SLEEP_INTERVAL))
 
     # we check whether all emails are now sent, since after adding the third
     # client, and calling _try_queued(), both jobs should have been processed



More information about the Pypy-commit mailing list