<div dir="ltr">LGTM, let me know when committed and I can update the package.<div><br></div><div> - Daniel</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 20, 2014 at 8:15 AM, Dan Liew <span dir="ltr"><<a href="mailto:dan@su-root.co.uk" target="_blank">dan@su-root.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
This fixes an issue with lit that I came across on Windows. If the<br>
command exists but is not a windows executable (for example a python<br>
script) then lit will give a very unhelpful error message during<br>
execution. In my case it is unhelpful because there were multiple<br>
``RUN:`` lines and I didn't know which command was failing.<br>
<br>
Here's an example error message:<br>
<br>
```<br>
Exception during script execution:<br>
Traceback (most recent call last):<br>
  File "C:\Python34\lib\site-packages\lit\run.py", line 166, in execute_test<br>
    result = test.config.test_format.execute(test, self.lit_config)<br>
  File "C:\Python34\lib\site-packages\lit\formats\shtest.py", line 12, in execut<br>
e<br>
    self.execute_external)<br>
  File "C:\Python34\lib\site-packages\lit\TestRunner.py", line 492, in executeSh<br>
Test<br>
    res = executeScriptInternal(test, litConfig, tmpBase, script, execdir)<br>
  File "C:\Python34\lib\site-packages\lit\TestRunner.py", line 255, in executeSc<br>
riptInternal<br>
    exitCode = executeShCmd(cmd, test.config, cwd, results)<br>
  File "C:\Python34\lib\site-packages\lit\TestRunner.py", line 45, in executeShC<br>
md<br>
    res = executeShCmd(cmd.rhs, cfg, cwd, results)<br>
  File "C:\Python34\lib\site-packages\lit\TestRunner.py", line 154, in executeSh<br>
Cmd<br>
    close_fds = kUseCloseFDs))<br>
  File "C:\Python34\lib\subprocess.py", line 858, in __init__<br>
    restore_signals, start_new_session)<br>
  File "C:\Python34\lib\subprocess.py", line 1111, in _execute_child<br>
    startupinfo)<br>
OSError: [WinError 193] %1 is not a valid Win32 application<br>
```<br>
<br>
The following patch catches OSError exceptions and then raises an<br>
InternalShellError and now lit gives a much more useful error message<br>
in my case.<br>
<br>
```<br>
Command 1: "C:\Users\Dan\Documents\foo\foo\utils\OutputCheck\bin\OutputCheck"<br>
 "-d" "C:\Users\Dan\Documents\foo\foo\test_programs\basic\concrete\assert_false.bpl"<br>
Command 1 Result: 127<br>
Command 1 Output:<br>
<br>
<br>
Command 1 Stderr:<br>
Could not create process due to [WinError 193] %1 is not a valid Win32<br>
application<br>
<br>
```<br>
<br>
Is it okay to commit this?<br>
<br>
@daniel - If this is okay to commit could you update the lit package on PyPi?<br>
<br>
Thanks,<br>
Dan.<br>
</blockquote></div><br></div>