From 5242e8200d605266cdb4de64609a4b5772be35f7 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Sat, 1 Aug 2009 23:18:27 +0000 Subject: [PATCH] lit: Catch (internal) exceptions when using --no-sh. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77830 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/test/TestRunner.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/utils/test/TestRunner.py b/utils/test/TestRunner.py index e605ef6013..42799093d1 100755 --- a/utils/test/TestRunner.py +++ b/utils/test/TestRunner.py @@ -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): -- 2.40.0