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.

llvm-svn: 220227

llvm/utils/lit/lit/TestRunner.py

index af6e383..ca87b05 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: