[Neo-report] r2736 jm - in /trunk/neo: storage/app.py tests/functional/__init__.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Apr 28 10:45:38 CEST 2011
Author: jm
Date: Thu Apr 28 10:45:38 2011
New Revision: 2736
Log:
Fix storage exiting with non-zero status in testDropNodeThenRestartCluster
Modified:
trunk/neo/storage/app.py
trunk/neo/tests/functional/__init__.py
Modified: trunk/neo/storage/app.py
==============================================================================
--- trunk/neo/storage/app.py [iso-8859-1] (original)
+++ trunk/neo/storage/app.py [iso-8859-1] Thu Apr 28 10:45:38 2011
@@ -368,4 +368,5 @@ class Application(object):
pass
# clear database to avoid polluting the cluster at restart
self.dm.setup(reset=erase)
- sys.exit("Application has been asked to shut down")
+ neo.lib.logging.info("Application has been asked to shut down")
+ sys.exit()
Modified: trunk/neo/tests/functional/__init__.py
==============================================================================
--- trunk/neo/tests/functional/__init__.py [iso-8859-1] (original)
+++ trunk/neo/tests/functional/__init__.py [iso-8859-1] Thu Apr 28 10:45:38 2011
@@ -103,6 +103,33 @@ class PortAllocator(object):
__del__ = reset
+
+class ChildException(KeyboardInterrupt):
+ """Wrap any exception into an exception that is not catched by TestCase.run
+
+ The exception is not wrapped and re-raised immediately if there is no need
+ to wrap.
+ """
+
+ def __init__(self, type, value, tb):
+ code = unittest.TestCase.run.im_func.func_code
+ f = tb.tb_frame
+ while f is not None:
+ if f.f_code is code:
+ break
+ f = f.f_back
+ else:
+ raise type, value, tb
+ super(ChildException, self).__init__(type, value, tb)
+
+ def __call__(self):
+ """Re-raise wrapped exception"""
+ type, value, tb = self.args
+ if type is KeyboardInterrupt:
+ sys.exit(1)
+ raise type, value, tb
+
+
class NEOProcess(object):
pid = 0
@@ -137,14 +164,8 @@ class NEOProcess(object):
try:
sys.argv = [command] + args
getattr(neo.scripts, command).main()
- except (SystemExit, KeyboardInterrupt):
- self._exit()
except:
- print traceback.format_exc()
- # If we reach this line, exec call failed (is it possible to reach
- # it without going through above "except" branch ?).
- print 'Error executing %r.' % (command + ' ' + ' '.join(args), )
- self._exit(-1)
+ raise ChildException(*sys.exc_info())
def _exit(self, status=0):
sys.stdout = sys.stderr = open('/dev/null', 'w')
@@ -622,6 +643,12 @@ class NEOFunctionalTest(NeoTestBase):
os.makedirs(temp_dir)
return temp_dir
+ def run(self, *args, **kw):
+ try:
+ return super(NEOFunctionalTest, self).run(*args, **kw)
+ except ChildException, e:
+ e()
+
def runWithTimeout(self, timeout, method, args=(), kwargs=None):
if kwargs is None:
kwargs = {}
More information about the Neo-report
mailing list