]> granicus.if.org Git - clang/commitdiff
lit: Catch (internal) exceptions when using --no-sh.
authorDaniel Dunbar <daniel@zuster.org>
Sat, 1 Aug 2009 23:18:27 +0000 (23:18 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sat, 1 Aug 2009 23:18:27 +0000 (23:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77830 91177308-0d34-0410-b5e6-96231b3b80d8

utils/test/TestRunner.py

index e605ef60138de3b537e73e97afdf62b56dfa2dad..42799093d195929cf24ef7ae854c7a1701e8e9a5 100755 (executable)
@@ -26,20 +26,13 @@ def executeShCmd(cmd, cfg, cwd, results):
     if isinstance(cmd, ShUtil.Seq):
         if cmd.op == ';':
             res = executeShCmd(cmd.lhs, cfg, cwd, results)
-            if res is None:
-                return res
-
             return executeShCmd(cmd.rhs, cfg, cwd, results)
 
         if cmd.op == '&':
-            Util.warning("unsupported test command: '&'")
-            return None
+            raise NotImplementedError,"unsupported test command: '&'"
 
         if cmd.op == '||':
             res = executeShCmd(cmd.lhs, cfg, cwd, results)
-            if res is None:
-                return res
-
             if res != 0:
                 res = executeShCmd(cmd.rhs, cfg, cwd, results)
             return res
@@ -72,7 +65,7 @@ def executeShCmd(cmd, cfg, cwd, results):
             elif r[0] == ('<',):
                 stdin = open(r[1], 'r')
             else:
-                return None
+                raise NotImplementedError,"Unsupported redirect: %r" % r
 
         procs.append(subprocess.Popen(j.args, cwd=cwd,
                                       stdin = stdin,
@@ -120,9 +113,14 @@ def executeScriptInternal(cfg, commands, cwd):
     cmd = ShUtil.ShParser(' &&\n'.join(commands)).parse()
 
     results = []
-    exitCode = executeShCmd(cmd, cfg, cwd, results)
-    if exitCode is None:
-        return None
+    try:
+        exitCode = executeShCmd(cmd, cfg, cwd, results)
+    except:
+        import traceback
+
+        out = ''
+        err = 'Exception during script execution:\n%s\n' % traceback.format_exc()
+        return out, err, 127
 
     out = err = ''
     for i,(cmd, cmd_out,cmd_err,res) in enumerate(results):