[Neo-report] r2230 vincent - /trunk/neo/tests/functional/__init__.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Aug 27 10:53:14 CEST 2010


Author: vincent
Date: Fri Aug 27 10:53:02 2010
New Revision: 2230

Log:
Exec scripts in the same (forked) interpreter.

Avoid switching to an unexpected interpreter after forking.

Modified:
    trunk/neo/tests/functional/__init__.py

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] Fri Aug 27 10:53:02 2010
@@ -82,18 +82,24 @@ class NEOProcess(object):
         if self.pid == 0:
             # Child
             try:
-                os.execlp(command, command, *args)
+                sys.argv = [command] + args
+                execfile(command, {})
+            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), )
-            # KeyboardInterrupt is not intercepted by test runner (it is still
-            # above us in the stack), and we do want to exit.
-            # To avoid polluting test foreground output with induced
-            # traceback, replace stdout & stderr.
-            sys.stdout = sys.stderr = open('/dev/null', 'w')
-            raise KeyboardInterrupt
+            self._exit()
+
+    def _exit(self):
+	# KeyboardInterrupt is not intercepted by test runner (it is still
+	# above us in the stack), and we do want to exit.
+	# To avoid polluting test foreground output with induced
+	# traceback, replace stdout & stderr.
+	sys.stdout = sys.stderr = open('/dev/null', 'w')
+	raise KeyboardInterrupt
 
     def kill(self, sig=signal.SIGTERM):
         if self.pid:





More information about the Neo-report mailing list