diff --git a/infer/lib/python/infer b/infer/lib/python/infer index 97663e06a..8ea8d15cc 100755 --- a/infer/lib/python/infer +++ b/infer/lib/python/infer @@ -9,7 +9,7 @@ import platform import sys import inferlib -from inferlib import analyze, utils +from inferlib import analyze, config, utils CAPTURE_PACKAGE = 'capture' @@ -174,7 +174,7 @@ def main(): encoding=utils.LOCALE) as bugs_file: bugs = json.load(bugs_file) if len(bugs) > 0: - sys.exit(analyze.BUG_FOUND_ERROR_CODE) + sys.exit(config.BUG_FOUND_ERROR_CODE) except OSError: pass diff --git a/infer/lib/python/inferlib/analyze.py b/infer/lib/python/inferlib/analyze.py index 15849dfcd..c3fb4b378 100644 --- a/infer/lib/python/inferlib/analyze.py +++ b/infer/lib/python/inferlib/analyze.py @@ -25,7 +25,7 @@ import tempfile import time import xml.etree.ElementTree as ET -from . import jwlib, utils +from . import config, jwlib, utils # Increase the limit of the CSV parser to sys.maxlimit csv.field_size_limit(sys.maxsize) @@ -46,8 +46,6 @@ ERROR = 'ERROR' WARNING = 'WARNING' INFO = 'INFO' -BUG_FOUND_ERROR_CODE = 2 - def get_infer_version(): try: return subprocess.check_output([ @@ -105,7 +103,7 @@ base_group.add_argument('-nf', '--no-filtering', action='store_true', base_group.add_argument('--fail-on-bug', action='store_true', help='''Exit with error code %d if Infer found something to report''' - % BUG_FOUND_ERROR_CODE) + % config.BUG_FOUND_ERROR_CODE) base_group.add_argument('--android-harness', action='store_true', help='''[experimental] Create harness to detect bugs diff --git a/infer/lib/python/inferlib/config.py b/infer/lib/python/inferlib/config.py new file mode 100644 index 000000000..d36d5d40e --- /dev/null +++ b/infer/lib/python/inferlib/config.py @@ -0,0 +1,14 @@ +# Copyright (c) 2015 - present Facebook, Inc. +# All rights reserved. +# +# This source code is licensed under the BSD style license found in the +# LICENSE file in the root directory of this source tree. An additional grant +# of patent rights can be found in the PATENTS file in the same directory. + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals + +# exit value when infer finds something to report +BUG_FOUND_ERROR_CODE = 2