From 7e00a845d84881e792ed27dceb4a8689b1f598fe Mon Sep 17 00:00:00 2001 From: jrm Date: Thu, 30 Jul 2015 14:40:33 -0700 Subject: [PATCH] [infer][java] stop swallowing errors coming from compilation failures Summary: No longer swallow compilation failures for javac. Before this diff, the compilation failures where raised: > infer -- javac Test.java Test.java:5: error: ';' expected static String str = "Hello" ^ 1 error but the exit code was incorrect: > echo $? 0 With this diff, the failing command is printed in standard error: > infer -- javac Test.java Javac compilation error with: ['javac', '-g', 'Test.java', '-J-Duser.language=en'] and the exit code is different from 0. > echo $? 1 --- infer/bin/inferlib.py | 2 -- infer/bin/jwlib.py | 15 +++++++-------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/infer/bin/inferlib.py b/infer/bin/inferlib.py index acf6ae6ff..58f895cd4 100644 --- a/infer/bin/inferlib.py +++ b/infer/bin/inferlib.py @@ -69,8 +69,6 @@ class VersionAction(argparse._VersionAction): option_string) - - base_parser = argparse.ArgumentParser(add_help=False) base_group = base_parser.add_argument_group('global arguments') base_group.add_argument('-o', '--out', metavar='', diff --git a/infer/bin/jwlib.py b/infer/bin/jwlib.py index 52f078639..46f36902c 100644 --- a/infer/bin/jwlib.py +++ b/infer/bin/jwlib.py @@ -7,10 +7,10 @@ # of patent rights can be found in the PATENTS file in the same directory. import argparse -import logging -import tempfile import os +import tempfile import subprocess +import utils # javac options parser = argparse.ArgumentParser() @@ -44,14 +44,13 @@ class CompilerCall: prefix='javac_', delete=False) as file_out: self.verbose_out = file_out.name - try: subprocess.check_call(javac_cmd, stderr=file_out) - return os.EX_OK - except subprocess.CalledProcessError as exc: + except subprocess.CalledProcessError: error_msg = 'Javac compilation error with: \n\n{}\n' failing_cmd = [arg for arg in javac_cmd if arg != '-verbose'] - logging.error(error_msg.format(failing_cmd)) - os.system(' '.join(failing_cmd)) - return exc.returncode + utils.error(error_msg.format(failing_cmd)) + subprocess.check_call(failing_cmd) + + return os.EX_OK