pass down --reactive and --continue to python

Summary:
Python needs to know about these because it does different things depending on
whether these flags are passed or not.

Reviewed By: cristianoc

Differential Revision: D3593381

fbshipit-source-id: fe3194d
master
Jules Villard 8 years ago committed by Facebook Github Bot 2
parent 354e4c0391
commit 4078a2b276

@ -62,6 +62,8 @@ let () =
| args when buck -> | args when buck ->
IList.map (fun arg -> ["--Xbuck"; "'" ^ arg ^ "'"]) args |> IList.flatten IList.map (fun arg -> ["--Xbuck"; "'" ^ arg ^ "'"]) args |> IList.flatten
| _ -> []) @ | _ -> []) @
(if not Config.continue_capture then [] else
["--continue"]) @
(if not Config.debug_mode then [] else (if not Config.debug_mode then [] else
["--debug"]) @ ["--debug"]) @
(if not Config.debug_exceptions then [] else (if not Config.debug_exceptions then [] else
@ -73,6 +75,8 @@ let () =
(match Config.infer_cache with None -> [] | Some s -> (match Config.infer_cache with None -> [] | Some s ->
["--infer_cache"; s]) @ ["--infer_cache"; s]) @
"--multicore" :: (string_of_int Config.jobs) :: "--multicore" :: (string_of_int Config.jobs) ::
(if not Config.reactive_mode then [] else
["--reactive"]) @
"--out" :: Config.results_dir :: "--out" :: Config.results_dir ::
(match Config.project_root with None -> [] | Some pr -> (match Config.project_root with None -> [] | Some pr ->
["--project_root"; pr]) @ ["--project_root"; pr]) @

@ -45,8 +45,6 @@ CLANG_BIN = os.path.join(ROOT_DIR, 'facebook-clang-plugins', 'clang',
REPORT_JSON = 'report.json' REPORT_JSON = 'report.json'
INFER_EXECUTABLE = 'infer'
RECORD_ENV = 'INFER_RECORD_INTEGRATION_TESTS' RECORD_ENV = 'INFER_RECORD_INTEGRATION_TESTS'
REPORT_FIELDS = [ REPORT_FIELDS = [
@ -68,10 +66,11 @@ ALL_TESTS = [
'locale', 'locale',
'make', 'make',
'multiclang', 'multiclang',
'ndk-build',
'reactive',
'unknown_ext', 'unknown_ext',
'utf8_in_pwd', 'utf8_in_pwd',
'waf', 'waf',
'ndk-build',
] ]
to_test = ALL_TESTS to_test = ALL_TESTS
@ -113,14 +112,20 @@ def save_report(reports, filename):
separators=(',', ': '), sort_keys=True) separators=(',', ': '), sort_keys=True)
def run_analysis(clean_cmds, build_cmds, analyzer, env=None): def run_analysis(clean_cmds, build_cmds, env=None):
for clean_cmd in clean_cmds: for clean_cmd in clean_cmds:
subprocess.check_call(clean_cmd, env=env) subprocess.check_call(clean_cmd, env=env)
temp_out_dir = tempfile.mkdtemp(suffix='_out', prefix='infer_')
for build_cmd in build_cmds: for build_cmd in build_cmds:
temp_out_dir = tempfile.mkdtemp(suffix='_out', prefix='infer_') extra_args = (build_cmd['infer_args']
infer_cmd = (['infer', '-a', analyzer, '-o', temp_out_dir, '--'] + if 'infer_args' in build_cmd
build_cmd) else [])
infer_cmd = (['infer', '-o', temp_out_dir] +
extra_args +
['--'] +
build_cmd['compile'])
print(str(infer_cmd))
# Only record the output of the last build command. We record # Only record the output of the last build command. We record
# all of them but each command overwrites the output of the # all of them but each command overwrites the output of the
# previous one. # previous one.
@ -273,7 +278,6 @@ def test(name,
errors = run_analysis( errors = run_analysis(
clean_commands, clean_commands,
compile_commands, compile_commands,
INFER_EXECUTABLE,
env=env) env=env)
original = os.path.join(EXPECTED_OUTPUTS_DIR, report_fname) original = os.path.join(EXPECTED_OUTPUTS_DIR, report_fname)
do_test(postprocess(errors), original) do_test(postprocess(errors), original)
@ -284,7 +288,7 @@ class BuildIntegrationTest(unittest.TestCase):
def test_ant_integration(self): def test_ant_integration(self):
test('ant', 'Ant', test('ant', 'Ant',
os.path.join(SCRIPT_DIR, os.pardir), os.path.join(SCRIPT_DIR, os.pardir),
[['ant', 'compile']], [{'compile': ['ant', 'compile']}],
clean_commands=[['ant', 'clean']], clean_commands=[['ant', 'clean']],
available=lambda: is_tool_available(['ant', '-version'])) available=lambda: is_tool_available(['ant', '-version']))
@ -295,7 +299,7 @@ class BuildIntegrationTest(unittest.TestCase):
report_fname='javac_report.json'): report_fname='javac_report.json'):
test('javac', 'javac', test('javac', 'javac',
root, root,
[['javac', 'Hello.java']], [{'compile': ['javac', 'Hello.java']}],
enabled=enabled, enabled=enabled,
report_fname=report_fname) report_fname=report_fname)
@ -311,7 +315,7 @@ class BuildIntegrationTest(unittest.TestCase):
) )
test('gradle', 'Gradle', test('gradle', 'Gradle',
root, root,
[['gradle', 'build']], [{'compile': ['gradle', 'build']}],
enabled=enabled, enabled=enabled,
report_fname=report_fname, report_fname=report_fname,
env=env) env=env)
@ -319,7 +323,7 @@ class BuildIntegrationTest(unittest.TestCase):
def test_buck_integration(self): def test_buck_integration(self):
test('buck', 'Buck', test('buck', 'Buck',
ROOT_DIR, ROOT_DIR,
[['buck', 'build', 'infer']], [{'compile': ['buck', 'build', 'infer']}],
clean_commands=[['buck', 'clean']], clean_commands=[['buck', 'clean']],
available=lambda: is_tool_available(['buck', '--version'])) available=lambda: is_tool_available(['buck', '--version']))
@ -330,7 +334,7 @@ class BuildIntegrationTest(unittest.TestCase):
report_fname='make_report.json'): report_fname='make_report.json'):
test('make', 'make', test('make', 'make',
root, root,
[['make', 'all']], [{'compile': ['make', 'all']}],
clean_commands=[['make', 'clean']], clean_commands=[['make', 'clean']],
enabled=enabled, enabled=enabled,
report_fname=report_fname) report_fname=report_fname)
@ -348,7 +352,8 @@ class BuildIntegrationTest(unittest.TestCase):
env['PATH'] = '{}:{}'.format(os.getenv('PATH'), ndk_dir) env['PATH'] = '{}:{}'.format(os.getenv('PATH'), ndk_dir)
if test('ndk-build', 'ndk-build', if test('ndk-build', 'ndk-build',
root, root,
[['ndk-build', '-B', 'NDK_LIBS_OUT=./libs', 'NDK_OUT=./obj']], [{'compile': ['ndk-build', '-B',
'NDK_LIBS_OUT=./libs', 'NDK_OUT=./obj']}],
clean_commands=[['ndk-build', 'clean']], clean_commands=[['ndk-build', 'clean']],
available=lambda: is_tool_available([ available=lambda: is_tool_available([
os.path.join(ndk_dir, 'ndk-build'), '-v']), os.path.join(ndk_dir, 'ndk-build'), '-v']),
@ -362,14 +367,14 @@ class BuildIntegrationTest(unittest.TestCase):
env['LC_ALL'] = 'C' env['LC_ALL'] = 'C'
test('locale', 'wonky locale', test('locale', 'wonky locale',
os.path.join(CODETOANALYZE_DIR, 'make'), os.path.join(CODETOANALYZE_DIR, 'make'),
[['clang', '-c', 'utf8_in_function_names.c'], [{'compile': ['clang', '-c', 'utf8_in_function_names.c']},
['clang', '-c', 'utf8_in_function_names.c']], {'compile': ['clang', '-c', 'utf8_in_function_names.c']}],
env=env) env=env)
def test_waf_integration(self): def test_waf_integration(self):
test('waf', 'waf', test('waf', 'waf',
os.path.join(CODETOANALYZE_DIR, 'make'), os.path.join(CODETOANALYZE_DIR, 'make'),
[['./waf', 'build']], [{'compile': ['./waf', 'build']}],
clean_commands=[['make', 'clean']]) clean_commands=[['make', 'clean']])
def test_cmake_integration( def test_cmake_integration(
@ -380,7 +385,8 @@ class BuildIntegrationTest(unittest.TestCase):
build_root = os.path.join(root, 'build') build_root = os.path.join(root, 'build')
if test('cmake', 'CMake', if test('cmake', 'CMake',
build_root, build_root,
[['cmake', '..'], ['make', 'clean', 'all']], [{'compile': ['cmake', '..']},
{'compile': ['make', 'clean', 'all']}],
available=lambda: is_tool_available(['cmake', '--version']), available=lambda: is_tool_available(['cmake', '--version']),
enabled=enabled, enabled=enabled,
# remove build/ directory just in case # remove build/ directory just in case
@ -427,12 +433,22 @@ class BuildIntegrationTest(unittest.TestCase):
def test_unknown_extension(self): def test_unknown_extension(self):
test('unknown_ext', 'unknown extension', test('unknown_ext', 'unknown extension',
CODETOANALYZE_DIR, CODETOANALYZE_DIR,
[['clang', '-x', 'c', '-c', 'hello.unknown_ext']]) [{'compile': ['clang', '-x', 'c', '-c', 'hello.unknown_ext']}])
def test_clang_multiple_source_files(self): def test_clang_multiple_source_files(self):
test('multiclang', 'clang multiple source files', test('multiclang', 'clang multiple source files',
CODETOANALYZE_DIR, CODETOANALYZE_DIR,
[['clang', '-c', 'hello.c', 'hello2.c']]) [{'compile': ['clang', '-c', 'hello.c', 'hello2.c']}])
def test_reactive_multiple_capture(self):
reactive_args = ['-a', 'capture', '--reactive', '--continue']
test('reactive', 'reactive with multiple capture',
CODETOANALYZE_DIR,
[{'compile': ['clang', '-c', 'hello.c'],
'infer_args': reactive_args},
{'compile': ['clang', '-c', 'hello2.c'],
'infer_args': reactive_args},
{'compile': ['analyze']}])
def test_clang_cc1(self): def test_clang_cc1(self):
def preprocess(): def preprocess():
@ -445,10 +461,10 @@ class BuildIntegrationTest(unittest.TestCase):
cc1_line = filter(lambda s: s.find('"-cc1"') != -1, cc1_line = filter(lambda s: s.find('"-cc1"') != -1,
hashhashhash.splitlines())[0] hashhashhash.splitlines())[0]
# [cc1_line] usually looks like ' "/foo/clang" "bar" "baz"'. # [cc1_line] usually looks like ' "/foo/clang" "bar" "baz"'.
# return [['clang', 'bar', 'baz']] # return ['clang', 'bar', 'baz']
cmd = [s.strip('"') for s in cc1_line.strip().split('" "')] cmd = [s.strip('"') for s in cc1_line.strip().split('" "')]
cmd[0] = 'clang' cmd[0] = 'clang'
return [cmd] return [{'compile': cmd}]
test('cc1', 'clang -cc1', test('cc1', 'clang -cc1',
CODETOANALYZE_DIR, CODETOANALYZE_DIR,
[], [],

@ -0,0 +1,12 @@
[
{
"bug_type": "NULL_DEREFERENCE",
"file": "hello.c",
"procedure": "test"
},
{
"bug_type": "NULL_DEREFERENCE",
"file": "hello2.c",
"procedure": "test2"
}
]
Loading…
Cancel
Save