@@ -217,6 +217,22 @@ def run_cppcheck():
217217
218218 return_code , stdout , stderr = run_cppcheck ()
219219
220+ def remove_checkers_msg (msgs ):
221+ if msgs .find ('[checkersReport]\n ' ) > 0 :
222+ start_id = msgs .find ('[checkersReport]\n ' )
223+ start_line = msgs .rfind ('\n ' , 0 , start_id )
224+ if start_line <= 0 :
225+ msgs = ''
226+ else :
227+ msgs = msgs [:start_line + 1 ]
228+ elif msgs .find (': (information) Active checkers: ' ) >= 0 :
229+ pos = msgs .find (': (information) Active checkers: ' )
230+ if pos == 0 :
231+ msgs = ''
232+ elif msgs [pos - 1 ] == '\n ' :
233+ msgs = msgs [:pos ]
234+ return msgs
235+
220236 if builddir_tmp :
221237 # run it again with the generated cache and make sure the output is identical
222238
@@ -233,18 +249,32 @@ def get_cache_contents():
233249
234250 return_code_1 , stdout_1 , stderr_1 = run_cppcheck ()
235251
252+ # TODO: the following asserts do not show a diff when the test fails
253+ # this can apparently by fixed by using register_assert_rewrite() but I have no idea how
254+
236255 assert return_code == return_code_1
237- print (stdout )
238- print (stdout_1 )
256+
239257 stdout_lines = stdout .splitlines ()
258+ stdout_1_lines = stdout_1 .splitlines ()
259+ print ('stdout - expected' )
260+ print (stdout_lines )
261+ print ('stdout - actual' )
262+ print (stdout_1_lines )
240263 # strip some common output only seen during analysis
241264 stdout_lines = [entry for entry in stdout_lines if not entry .startswith ('Processing rule: ' )]
242265 stdout_lines = [entry for entry in stdout_lines if not entry .startswith ('progress: ' )]
243- assert stdout_lines == stdout_1 .splitlines ()
244- print (stderr )
245- print (stderr_1 )
246- assert stderr == stderr_1
247- #register_assert_rewrite
266+ # TODO: no messages for checked configurations when using cached data
267+ assert stdout_lines == stdout_1_lines
268+
269+ stderr_lines = stderr .splitlines ()
270+ stderr_1_lines = stderr_1 .splitlines ()
271+ print ('stderr - expected' )
272+ print (stderr_lines )
273+ print ('stderr - actual' )
274+ print (stderr_1_lines )
275+ stderr_lines = remove_checkers_msg (stderr ).splitlines ()
276+ stderr_1_lines = remove_checkers_msg (stderr_1 ).splitlines ()
277+ assert stderr_lines == stderr_1_lines
248278
249279 cache_content_1 = get_cache_contents ()
250280
@@ -254,19 +284,8 @@ def get_cache_contents():
254284 builddir_tmp .cleanup ()
255285
256286 if remove_checkers_report :
257- if stderr .find ('[checkersReport]\n ' ) > 0 :
258- start_id = stderr .find ('[checkersReport]\n ' )
259- start_line = stderr .rfind ('\n ' , 0 , start_id )
260- if start_line <= 0 :
261- stderr = ''
262- else :
263- stderr = stderr [:start_line + 1 ]
264- elif stderr .find (': (information) Active checkers: ' ) >= 0 :
265- pos = stderr .find (': (information) Active checkers: ' )
266- if pos == 0 :
267- stderr = ''
268- elif stderr [pos - 1 ] == '\n ' :
269- stderr = stderr [:pos ]
287+ stderr = remove_checkers_msg (stderr )
288+
270289 return return_code , stdout , stderr , exe
271290
272291
0 commit comments