@@ -559,4 +559,57 @@ def test_premium_disabled_unmatched(): #13663
559559 '{}premiumUnmatched.cpp:5:0: information: Unmatched suppression: uninitvar [unmatchedSuppression]' .format (__proj_inline_suppres_path )
560560 ]
561561 assert stdout == ''
562- assert ret == 0 , stdout
562+ assert ret == 0 , stdout
563+
564+
565+ def test_duplicate_include (tmp_path ):
566+ test_file_1 = tmp_path / 'test_1.c'
567+ with open (test_file_1 , "w" ) as f :
568+ f .write ('#include "test.h"' )
569+
570+ test_file_2 = tmp_path / 'test_2.c'
571+ with open (test_file_2 , "w" ) as f :
572+ f .write ('#include "test.h"' )
573+
574+ test_header = tmp_path / 'test.h'
575+ with open (test_header , "w" ) as f :
576+ f .write ('// cppcheck-suppress id' )
577+
578+ args = [
579+ '-q' ,
580+ '--template=simple' ,
581+ '--emit-duplicates' ,
582+ '--inline-suppr' ,
583+ str (test_file_1 ),
584+ str (test_file_2 )
585+ ]
586+
587+ exitcode , stdout , stderr = cppcheck (args )
588+ assert exitcode == 0 , stdout
589+ assert stdout .splitlines () == []
590+ assert stderr .splitlines () == []
591+
592+
593+ def test_duplicate_header (tmp_path ):
594+ test_file = tmp_path / 'test.c'
595+ with open (test_file , "w" ) as f :
596+ f .write ('#include "test.h"' )
597+
598+ test_header = tmp_path / 'test.h'
599+ with open (test_header , "w" ) as f :
600+ f .write ('// cppcheck-suppress [id,id]' )
601+
602+ args = [
603+ '-q' ,
604+ '--template=simple' ,
605+ '--emit-duplicates' ,
606+ '--inline-suppr' ,
607+ str (test_file )
608+ ]
609+
610+ exitcode , stdout , stderr = cppcheck (args )
611+ assert exitcode == 0 , stdout
612+ assert stdout .splitlines () == []
613+ assert stderr .splitlines () == [
614+ "{}:1:0: error: suppression 'id:{}:1' already exists [invalidSuppression]" .format (test_header ,test_header )
615+ ]
0 commit comments