@@ -3797,4 +3797,60 @@ def test_premium_disabled_unmatched(tmp_path): #13663
37973797 'nofile:0:0: information: Unmatched suppression: uninitvar [unmatchedSuppression]'
37983798 ]
37993799 assert stdout == ''
3800- assert ret == 0 , stdout
3800+ assert ret == 0 , stdout
3801+
3802+
3803+ def test_unmatched_file (tmp_path ): # #14248 / #14249
3804+ lib_path = tmp_path / 'lib'
3805+ os .makedirs (lib_path )
3806+
3807+ test_file = lib_path / 'test.c'
3808+ with open (test_file , "w" ):
3809+ pass
3810+
3811+ suppr_txt = tmp_path / 'suppr.txt'
3812+ with open (suppr_txt , "w" ) as f :
3813+ f .write ('''
3814+ error:lib/test.c
3815+ error2:lib\\ test.c
3816+ ''' )
3817+
3818+ suppr_xml = tmp_path / 'suppr.xml'
3819+ with open (suppr_xml , "w" ) as f :
3820+ f .write ('''
3821+ <suppressions>
3822+ <suppress>
3823+ <id>error3</id>
3824+ <fileName>lib/test.c</fileName>
3825+ </suppress>
3826+ <suppress>
3827+ <id>error4</id>
3828+ <fileName>lib\\ test.c</fileName>
3829+ </suppress>
3830+ </suppressions>
3831+ ''' )
3832+
3833+ args = [
3834+ '-q' ,
3835+ '--template=simple' ,
3836+ '--enable=information' ,
3837+ f'--suppressions-list={ suppr_txt } ' ,
3838+ f'--suppress-xml={ suppr_xml } ' ,
3839+ '--suppress=error5:lib/test.c' ,
3840+ '--suppress=error6:lib\\ test.c' ,
3841+ str (test_file )
3842+ ]
3843+
3844+ lib_file = 'lib' + os .path .sep + 'test.c'
3845+
3846+ ret , stdout , stderr = cppcheck (args )
3847+ assert stdout == ''
3848+ assert stderr .splitlines () == [
3849+ f'{ lib_file } :-1:0: information: Unmatched suppression: error [unmatchedSuppression]' ,
3850+ f'{ lib_file } :-1:0: information: Unmatched suppression: error2 [unmatchedSuppression]' ,
3851+ f'{ lib_file } :-1:0: information: Unmatched suppression: error3 [unmatchedSuppression]' ,
3852+ f'{ lib_file } :-1:0: information: Unmatched suppression: error4 [unmatchedSuppression]' ,
3853+ f'{ lib_file } :-1:0: information: Unmatched suppression: error5 [unmatchedSuppression]' ,
3854+ f'{ lib_file } :-1:0: information: Unmatched suppression: error6 [unmatchedSuppression]'
3855+ ]
3856+ assert ret == 0 , stdout
0 commit comments