[py-svn] r35595 - in py/branch/rsession-cleanup/py/test/rsession: . testing

fijal at codespeak.net fijal at codespeak.net
Mon Dec 11 20:02:26 CET 2006


Author: fijal
Date: Mon Dec 11 20:02:24 2006
New Revision: 35595

Modified:
   py/branch/rsession-cleanup/py/test/rsession/slave.py
   py/branch/rsession-cleanup/py/test/rsession/testing/test_slave.py
Log:
Fixed -x semantics, so remote process really dies after receiving such signal.


Modified: py/branch/rsession-cleanup/py/test/rsession/slave.py
==============================================================================
--- py/branch/rsession-cleanup/py/test/rsession/slave.py	(original)
+++ py/branch/rsession-cleanup/py/test/rsession/slave.py	Mon Dec 11 20:02:24 2006
@@ -3,11 +3,14 @@
 """
 
 import py
-from py.__.test.rsession.executor import RunExecutor, BoxExecutor
+from py.__.test.rsession.executor import RunExecutor, BoxExecutor, AsyncExecutor
 from py.__.test.rsession.outcome import Outcome
 
+class Info:
+    pid = None
+
 class SlaveNode(object):
-    def __init__(self, rootcollector, executor=BoxExecutor):
+    def __init__(self, rootcollector, executor=AsyncExecutor):
         self.rootcollector = rootcollector
         self.executor = executor
 
@@ -17,7 +20,13 @@
         #    ex = Executor(item.obj, setup=item.setup)
         #else:
         ex = self.executor(item)
-        return ex.execute()
+        if self.executor is AsyncExecutor:
+            cont, pid = ex.execute()
+        else:
+            # for tests only
+            return ex.execute()
+        Info.pid = pid
+        return cont()
 
     def run(self, itemspec):
         #outcome = self.execute(itemspec)
@@ -64,9 +73,12 @@
     
 def setup():
     def callback_gen(queue):
+        from py.__.test.rsession.slave import Info
         def callback(item):
             if item == 42: # magic call-cleanup
                 # XXX should kill a pid here
+                if Info.pid:
+                    os.kill(Info.pid, 15)
                 sys.exit(0)
             queue.put(item)
         return callback
@@ -82,6 +94,8 @@
     import py
     options['we_are_remote'] = True
     from py.__.test.rsession.rsession import RemoteOptions
+    from py.__.test.rsession.slave import Info
+    Info.pid = 0
     py.test.remote = RemoteOptions(options)
     # XXX the following assumes that py lib is there, a bit
     # much of an assumtion 

Modified: py/branch/rsession-cleanup/py/test/rsession/testing/test_slave.py
==============================================================================
--- py/branch/rsession-cleanup/py/test/rsession/testing/test_slave.py	(original)
+++ py/branch/rsession-cleanup/py/test/rsession/testing/test_slave.py	Mon Dec 11 20:02:24 2006
@@ -40,6 +40,10 @@
 def funcoptioncustom():
     assert py.test.remote.custom == "custom"
 
+def funchang():
+    import time
+    time.sleep(1000)
+
 BASE = "py/test/rsession/testing/test_slave.py/"
 funcpass_spec = (BASE + "funcpass").split("/")
 funcfail_spec = (BASE + "funcfail").split("/")
@@ -48,6 +52,7 @@
 funcprintfail_spec = (BASE + "funcprintfail").split("/")
 funcoption_spec = (BASE + "funcoption").split("/")
 funcoptioncustom_spec = (BASE + "funcoptioncustom").split("/")
+funchang_spec = (BASE + "funchang").split("/")
 mod_spec = BASE[:-1].split("/")
 
 # ----------------------------------------------------------------------
@@ -132,7 +137,7 @@
                 from py.__.test.rsession.rsession import remote_options
                 retval = remote_options.d
             else:
-                raise NotImplementedError("mora data")
+                raise NotImplementedError("more data")
             self.count += 1
             return retval
     try:
@@ -156,7 +161,7 @@
             from py.__.test.rsession.rsession import remote_options
             self.q = [str(tmp),
                 remote_options.d,
-                funcpass_spec,
+                funchang_spec,
                 42,
                 funcpass_spec]
             self.q.reverse()
@@ -195,7 +200,7 @@
                 from py.__.test.rsession.rsession import remote_options
                 retval = remote_options.d
             else:
-                raise NotImplementedError("mora data")
+                raise NotImplementedError("more data")
             self.count += 1
             return retval
     try:



More information about the pytest-commit mailing list