Teach Lit to catch OSError exceptions when creating a process during the
authorDan Liew <dan@su-root.co.uk>
Mon, 20 Oct 2014 20:14:28 +0000 (20:14 +0000)
committerDan Liew <dan@su-root.co.uk>
Mon, 20 Oct 2014 20:14:28 +0000 (20:14 +0000)
execution of a shell command. This can happen for example if the
``RUN:`` line calls a python script which can work correctly under
Linux/OSX but will not work under Windows. A more useful error message
is now shown rather than an unhelpful backtrace.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220227 91177308-0d34-0410-b5e6-96231b3b80d8

utils/lit/lit/TestRunner.py

index af6e383ae4f1b0328dac07a5d2599bcf3470295b..ca87b054fa863e36f9246c7bc93f400af1b8ae28 100644 (file)
@@ -144,13 +144,16 @@ def executeShCmd(cmd, cfg, cwd, results):
                     named_temp_files.append(f.name)
                     args[i] = f.name
 
-        procs.append(subprocess.Popen(args, cwd=cwd,
-                                      executable = executable,
-                                      stdin = stdin,
-                                      stdout = stdout,
-                                      stderr = stderr,
-                                      env = cfg.environment,
-                                      close_fds = kUseCloseFDs))
+        try:
+            procs.append(subprocess.Popen(args, cwd=cwd,
+                                          executable = executable,
+                                          stdin = stdin,
+                                          stdout = stdout,
+                                          stderr = stderr,
+                                          env = cfg.environment,
+                                          close_fds = kUseCloseFDs))
+        except OSError as e:
+            raise InternalShellError(j, 'Could not create process due to {}'.format(e))
 
         # Immediately close stdin for any process taking stdin from us.
         if stdin == subprocess.PIPE: