Browse Source

Merge pull request #1109 from hamiltont/handle-setup-exceptions

Toolset: Let FrameworkTest catch Exception from setup.py files
Hamilton Turner 10 years ago
parent
commit
cfa7433e05
1 changed files with 22 additions and 2 deletions
  1. 22 2
      toolset/benchmark/framework_test.py

+ 22 - 2
toolset/benchmark/framework_test.py

@@ -473,7 +473,17 @@ class FrameworkTest:
     previousDir = os.getcwd()
     previousDir = os.getcwd()
     os.chdir(os.path.dirname(self.troot))
     os.chdir(os.path.dirname(self.troot))
     logging.info("Running setup module start (cwd=%s)", os.path.dirname(self.troot))
     logging.info("Running setup module start (cwd=%s)", os.path.dirname(self.troot))
-    retcode = self.setup_module.start(self, out, err)    
+    try:
+      retcode = self.setup_module.start(self, out, err)    
+      if retcode == None: 
+        retcode = 0
+    except Exception:
+      retcode = 1
+      st = traceback.format_exc()
+      st = '\n'.join((4 * ' ') + x for x in st.splitlines())
+      st = "Start exception:\n%s" % st
+      logging.info(st)
+      err.write(st + '\n')
     os.chdir(previousDir)
     os.chdir(previousDir)
 
 
     # Stop the progress printer
     # Stop the progress printer
@@ -507,7 +517,17 @@ class FrameworkTest:
     previousDir = os.getcwd()
     previousDir = os.getcwd()
     os.chdir(os.path.dirname(self.troot))
     os.chdir(os.path.dirname(self.troot))
     logging.info("Running setup module stop (cwd=%s)", os.path.dirname(self.troot))
     logging.info("Running setup module stop (cwd=%s)", os.path.dirname(self.troot))
-    retcode = self.setup_module.stop(out, err)
+    try:
+      retcode = self.setup_module.stop(out, err)
+      if retcode == None: 
+        retcode = 0
+    except Exception:
+      retcode = 1 
+      st = traceback.format_exc()
+      st = '\n'.join((4 * ' ') + x for x in st.splitlines())
+      st = "Stop exception:\n%s\n" % st
+      logging.info(st)
+      err.write(st + '\n')
     os.chdir(previousDir)
     os.chdir(previousDir)
 
 
     # Give processes sent a SIGTERM a moment to shut down gracefully
     # Give processes sent a SIGTERM a moment to shut down gracefully