Browse Source

Let FrameworkTest catch Exception from setup.py files

Hamilton Turner 10 years ago
parent
commit
b9d2d68925
1 changed files with 20 additions and 2 deletions
  1. 20 2
      toolset/benchmark/framework_test.py

+ 20 - 2
toolset/benchmark/framework_test.py

@@ -473,7 +473,16 @@ 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:
+      self.setup_module.start(self, out, err)    
+      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 +516,16 @@ 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:
+      self.setup_module.stop(out, err)
+      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