@@ -266,6 +266,45 @@ def test_compiler_info_file_is_loaded(self):
266266 self .assertTrue ("--target=FAKE_TARGET" in out )
267267 self .assertTrue ("-idirafter /FAKE_INCLUDE_DIR" in out )
268268
269+ def test_compiler_info_file_is_dumped (self ):
270+ """
271+ Test if the compiler info file is dumped properly.
272+ """
273+ build_json = os .path .join (self .test_workspace , "build_simple.json" )
274+ source_file = os .path .join (self .test_workspace , "simple.cpp" )
275+
276+ build_log = [{
277+ "directory" : self .test_workspace ,
278+ "command" : f"g++ -c { source_file } " ,
279+ "file" : source_file
280+ }]
281+
282+ with open (build_json , 'w' ,
283+ encoding = "utf-8" , errors = "ignore" ) as outfile :
284+ json .dump (build_log , outfile )
285+
286+ with tempfile .NamedTemporaryFile () as f :
287+ analyze_cmd = [
288+ self ._codechecker_cmd , "analyze" , build_json , "-o" , f .name ,
289+ "--dump-compiler-info-file" ]
290+
291+ process = subprocess .Popen (
292+ analyze_cmd ,
293+ stdout = subprocess .PIPE ,
294+ stderr = subprocess .PIPE ,
295+ cwd = self .test_dir ,
296+ encoding = "utf-8" ,
297+ errors = "ignore" )
298+ out , _ = process .communicate ()
299+ print (out )
300+
301+ f .flush ()
302+ f .seek (0 )
303+
304+ compiler_info = json .loads (f .read ())
305+
306+ self .assertIn ('["g++", "c++", []]' , compiler_info )
307+
269308 def test_capture_analysis_output (self ):
270309 """
271310 Test if reports/success/<output_file>.[stdout,stderr].txt
0 commit comments