From 2b6118cd3aac0ddeaed8a6eadf67de58d3ebdcae Mon Sep 17 00:00:00 2001 From: Jack O'Connor Date: Wed, 6 May 2015 13:43:40 -0400 Subject: [PATCH] print an error when flake8 is missing Previously test.py was silently failing if flake8 was not installed. (It would return an error code, but nothing was printed -- that's how I missed the lint bug that I had to fix in the last commit.) Now we explicitly catch that case, and print something helpful. --- test.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test.py b/test.py index 9611ce2..b77bd27 100755 --- a/test.py +++ b/test.py @@ -43,7 +43,8 @@ def main(): command = command_start + ['-m', 'unittest'] + args try: subprocess.check_call(command, env=env, cwd=TESTS_DIR) - except: + except subprocess.CalledProcessError: + print('ERROR: unit tests returned an error code', file=sys.stderr) sys.exit(1) new_untracked = get_untracked_files() @@ -56,7 +57,11 @@ def main(): # Run the linter. try: subprocess.check_call(['flake8', 'peru', 'tests'], cwd=REPO_ROOT) - except: + except FileNotFoundError: + print('ERROR: flake8 not found', file=sys.stderr) + sys.exit(1) + except subprocess.CalledProcessError: + print('ERROR: flake8 returned an error code', file=sys.stderr) sys.exit(1)