[PATCH][Lit] Catch OSError exception when using Popen constructor

Dan Liew dan at su-root.co.uk
Mon Oct 20 08:15:40 PDT 2014


Hi,

This fixes an issue with lit that I came across on Windows. If the
command exists but is not a windows executable (for example a python
script) then lit will give a very unhelpful error message during
execution. In my case it is unhelpful because there were multiple
``RUN:`` lines and I didn't know which command was failing.

Here's an example error message:

```
Exception during script execution:
Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\lit\run.py", line 166, in execute_test
    result = test.config.test_format.execute(test, self.lit_config)
  File "C:\Python34\lib\site-packages\lit\formats\shtest.py", line 12, in execut
e
    self.execute_external)
  File "C:\Python34\lib\site-packages\lit\TestRunner.py", line 492, in executeSh
Test
    res = executeScriptInternal(test, litConfig, tmpBase, script, execdir)
  File "C:\Python34\lib\site-packages\lit\TestRunner.py", line 255, in executeSc
riptInternal
    exitCode = executeShCmd(cmd, test.config, cwd, results)
  File "C:\Python34\lib\site-packages\lit\TestRunner.py", line 45, in executeShC
md
    res = executeShCmd(cmd.rhs, cfg, cwd, results)
  File "C:\Python34\lib\site-packages\lit\TestRunner.py", line 154, in executeSh
Cmd
    close_fds = kUseCloseFDs))
  File "C:\Python34\lib\subprocess.py", line 858, in __init__
    restore_signals, start_new_session)
  File "C:\Python34\lib\subprocess.py", line 1111, in _execute_child
    startupinfo)
OSError: [WinError 193] %1 is not a valid Win32 application
```

The following patch catches OSError exceptions and then raises an
InternalShellError and now lit gives a much more useful error message
in my case.

```
Command 1: "C:\Users\Dan\Documents\foo\foo\utils\OutputCheck\bin\OutputCheck"
 "-d" "C:\Users\Dan\Documents\foo\foo\test_programs\basic\concrete\assert_false.bpl"
Command 1 Result: 127
Command 1 Output:


Command 1 Stderr:
Could not create process due to [WinError 193] %1 is not a valid Win32
application

```

Is it okay to commit this?

@daniel - If this is okay to commit could you update the lit package on PyPi?

Thanks,
Dan.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: catch_oserror_lit.patch
Type: text/x-patch
Size: 1424 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141020/da6b8526/attachment.bin>


More information about the llvm-commits mailing list