TechEmpower/FrameworkBenchmarks — pull request #1109 by hamiltont (2014-10-18 02:58:38+00:00)
Title: Let FrameworkTest catch Exception from setup.py files

Removes `Exception`-handling responsibility from `setup.py` files, so `FrameworkTest` chooses how to handle exceptions. By default this prints them to stdout as they happen (which is super useful), and maintains the previous behavior or printing them to the `err.txt` file.

Example output:

```
-------------------------------------------------------------------------------- Rough ETA: --:--:--
Running Test: aspnet-mono
--------------------------------------------------------------------------------
INFO:root:Running setup module start (cwd=/home/vagrant/FrameworkBenchmarks/frameworks/C#)
INFO:root:Start exception:
Traceback (most recent call last):
File "/FrameworkBenchmarks/toolset/benchmark/framework_test.py", line 477, in start
self.setup_module.start(self, out, err)
File "/home/vagrant/FrameworkBenchmarks/frameworks/C#/aspnet/setup_nginx.py", line 15, in start
subprocess.check_call("xbuild /p:Configuration=Release", shell=True, cwd="aspnet/src", stderr=errfile, stdout=logfile)
File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
CalledProcessError: Command 'xbuild /p:Configuration=Release' returned non-zero exit status 1
INFO:root:Start completed, running benchmark
INFO:root:Running setup module stop (cwd=/home/vagrant/FrameworkBenchmarks/frameworks/C#)
INFO:root:Stop exception:
Traceback (most recent call last):
File "/FrameworkBenchmarks/toolset/benchmark/framework_test.py", line 520, in stop
self.setup_module.stop(out, err)
File "/home/vagrant/FrameworkBenchmarks/frameworks/C#/aspnet/setup_nginx.py", line 40, in stop
subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c $TROOT/nginx.conf -s stop", shell=True, stderr=errfile, stdout=logfile)
File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
CalledProcessError: Command 'sudo /usr/local/nginx/sbin/nginx -c $TROOT/nginx.conf -s stop' returned non-zero exit status 1
```

This removes the need for this horrible pattern, which only hides exceptions from the user. Obviously if there is a valid reason to try-except it can still be done, but it's no longer required

```
def start(args, logfile, errfile):
try:
# Do stuff here
return 0
except subprocess.CalledProcessError:
return 1
```