Exit non-zero if something goes wrong during a run

If we handle an exception, or early exit, or really anything, we should
exit non-zero (and we used to). This was a minor oversight.

Closes #209
Closes #248
This commit is contained in:
Ian Cordasco 2016-11-12 13:42:43 -06:00
parent eff9f607bb
commit c81a403fef
No known key found for this signature in database
GPG key ID: 656D3395E4A9791A
3 changed files with 79 additions and 2 deletions

View file

@ -102,6 +102,9 @@ class Application(object):
#: The total number of errors before accounting for ignored errors and
#: lines.
self.total_result_count = 0
#: Whether or not something catastrophic happened and we should exit
#: with a non-zero status code
self.catastrophic_failure = False
#: Whether the program is processing a diff or not
self.running_against_diff = False
@ -119,7 +122,8 @@ class Application(object):
print(self.result_count)
if not self.options.exit_zero:
raise SystemExit(self.result_count > 0)
raise SystemExit((self.result_count > 0) or
self.catastrophic_failure)
def find_plugins(self):
# type: () -> NoneType
@ -321,5 +325,7 @@ class Application(object):
LOG.critical('Caught keyboard interrupt from user')
LOG.exception(exc)
self.file_checker_manager._force_cleanup()
self.catastrophic_failure = True
except exceptions.EarlyQuit:
self.catastrophic_failure = True
print('... stopped while processing files')