[atest] ensure an error in a recipe execution (even a SyntaxError) is reported draft content-divergent
authorDavid Douard <david.douard@logilab.fr>
Thu, 13 Nov 2014 14:34:08 +0100
changeset 1743 a9b471081580
unstable content-divergent: 3cdc3ef300a4 (draft) predecessor b522e994f799
parent 1742 3cdc3ef300a4
child 1744 aa2677d6b9dc
[atest] ensure an error in a recipe execution (even a SyntaxError) is reported instead of crashing the process
_apycotlib/atest.py
--- a/_apycotlib/atest.py	Thu Nov 13 14:32:39 2014 +0100
+++ b/_apycotlib/atest.py	Thu Nov 13 14:34:08 2014 +0100
@@ -126,7 +126,12 @@
             with NamedTemporaryFile(suffix='.py') as f:
                 f.write(recipe['script'])
                 f.flush()
-                execfile(f.name, kwargs)
+                try:
+                    execfile(f.name, kwargs)
+                except Exception as exc:
+                    url = self.writer.cnxh.base_url + '/%s'%recipe['eid']
+                    self.writer.error("Execution of recipe %s (%s) FAILED" % (recipe['name'], url))
+                    raise
         finally:
             os.chdir(cwd)