|  |  | @ -67,6 +67,7 @@ ALL_TESTS = [ | 
			
		
	
		
		
			
				
					
					|  |  |  |     'make', |  |  |  |     'make', | 
			
		
	
		
		
			
				
					
					|  |  |  |     'multiclang', |  |  |  |     'multiclang', | 
			
		
	
		
		
			
				
					
					|  |  |  |     'ndk-build', |  |  |  |     'ndk-build', | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     'pmd-xml', | 
			
		
	
		
		
			
				
					
					|  |  |  |     'reactive', |  |  |  |     'reactive', | 
			
		
	
		
		
			
				
					
					|  |  |  |     'unknown_ext', |  |  |  |     'unknown_ext', | 
			
		
	
		
		
			
				
					
					|  |  |  |     'utf8_in_pwd', |  |  |  |     'utf8_in_pwd', | 
			
		
	
	
		
		
			
				
					|  |  | @ -112,7 +113,7 @@ def save_report(reports, filename): | 
			
		
	
		
		
			
				
					
					|  |  |  |                             separators=(',', ': '), sort_keys=True) |  |  |  |                             separators=(',', ': '), sort_keys=True) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | def run_analysis(clean_cmds, build_cmds, env=None): |  |  |  | def run_analysis(clean_cmds, build_cmds, extra_check, 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) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -136,6 +137,7 @@ def run_analysis(clean_cmds, build_cmds, env=None): | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     json_path = os.path.join(temp_out_dir, REPORT_JSON) |  |  |  |     json_path = os.path.join(temp_out_dir, REPORT_JSON) | 
			
		
	
		
		
			
				
					
					|  |  |  |     found_errors = utils.load_json_from_path(json_path) |  |  |  |     found_errors = utils.load_json_from_path(json_path) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     extra_check(temp_out_dir) | 
			
		
	
		
		
			
				
					
					|  |  |  |     shutil.rmtree(temp_out_dir) |  |  |  |     shutil.rmtree(temp_out_dir) | 
			
		
	
		
		
			
				
					
					|  |  |  |     os.chdir(SCRIPT_DIR) |  |  |  |     os.chdir(SCRIPT_DIR) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -224,6 +226,7 @@ def test(name, | 
			
		
	
		
		
			
				
					
					|  |  |  |          available=lambda: True, |  |  |  |          available=lambda: True, | 
			
		
	
		
		
			
				
					
					|  |  |  |          enabled=None, |  |  |  |          enabled=None, | 
			
		
	
		
		
			
				
					
					|  |  |  |          report_fname=None, |  |  |  |          report_fname=None, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |          extra_check=lambda x: None, | 
			
		
	
		
		
			
				
					
					|  |  |  |          preprocess=lambda: None, |  |  |  |          preprocess=lambda: None, | 
			
		
	
		
		
			
				
					
					|  |  |  |          postprocess=lambda errors: errors): |  |  |  |          postprocess=lambda errors: errors): | 
			
		
	
		
		
			
				
					
					|  |  |  |     """Run a test. |  |  |  |     """Run a test. | 
			
		
	
	
		
		
			
				
					|  |  | @ -277,6 +280,7 @@ def test(name, | 
			
		
	
		
		
			
				
					
					|  |  |  |     errors = run_analysis( |  |  |  |     errors = run_analysis( | 
			
		
	
		
		
			
				
					
					|  |  |  |         clean_commands, |  |  |  |         clean_commands, | 
			
		
	
		
		
			
				
					
					|  |  |  |         compile_commands, |  |  |  |         compile_commands, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         extra_check=extra_check, | 
			
		
	
		
		
			
				
					
					|  |  |  |         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) | 
			
		
	
	
		
		
			
				
					|  |  | @ -469,6 +473,22 @@ class BuildIntegrationTest(unittest.TestCase): | 
			
		
	
		
		
			
				
					
					|  |  |  |              [], |  |  |  |              [], | 
			
		
	
		
		
			
				
					
					|  |  |  |              preprocess=preprocess) |  |  |  |              preprocess=preprocess) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     def test_pmd_xml_output(self): | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         def pmd_check(infer_out): | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             assert os.path.exists(os.path.join(infer_out, 'report.xml')) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         try: | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             from lxml import etree | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             has_lxml = True | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         except ImportError: | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             has_lxml = False | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         test('pmd-xml', 'PMD XML output', | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |              CODETOANALYZE_DIR, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |              [{'compile': ['clang', '-c', 'hello.c'], | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                'infer_args': ['--pmd-xml']}], | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |              extra_check=pmd_check, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |              available=lambda: has_lxml) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | if __name__ == '__main__': |  |  |  | if __name__ == '__main__': | 
			
		
	
		
		
			
				
					
					|  |  |  |     # hackish capturing of the arguments after '--' |  |  |  |     # hackish capturing of the arguments after '--' | 
			
		
	
	
		
		
			
				
					|  |  | 
 |