@@ -3805,8 +3805,14 @@ def test_unmatched_file(tmp_path): # #14248 / #14249
38053805 os .makedirs (lib_path )
38063806
38073807 test_file = lib_path / 'test.c'
3808- with open (test_file , "w" ):
3809- pass
3808+ with open (test_file , "w" ) as f :
3809+ f .write ('''
3810+ void f()
3811+ {
3812+ const int* i = malloc(4);
3813+ if (i) *i = 0;
3814+ }
3815+ ''' )
38103816
38113817 suppr_txt = tmp_path / 'suppr.txt'
38123818 with open (suppr_txt , "w" ) as f :
@@ -3824,7 +3830,7 @@ def test_unmatched_file(tmp_path): # #14248 / #14249
38243830 <fileName>lib/test.c</fileName>
38253831 </suppress>
38263832 <suppress>
3827- <id>error4 </id>
3833+ <id>memleak </id>
38283834 <fileName>lib\\ test.c</fileName>
38293835 </suppress>
38303836</suppressions>
@@ -3833,22 +3839,24 @@ def test_unmatched_file(tmp_path): # #14248 / #14249
38333839 args = [
38343840 '-q' ,
38353841 '--template=simple' ,
3836- '--enable=information' ,
3842+ '--enable=style, information' ,
38373843 f'--suppressions-list={ suppr_txt } ' ,
38383844 f'--suppress-xml={ suppr_xml } ' ,
38393845 '--suppress=error5:lib/test.c' ,
38403846 '--suppress=error6:lib\\ test.c' ,
38413847 str (test_file )
38423848 ]
38433849
3850+ lib_file = 'lib' + os .path .sep + 'test.c'
3851+
38443852 ret , stdout , stderr = cppcheck (args )
38453853 assert stdout == ''
38463854 assert stderr .splitlines () == [
3847- 'lib/test.c :-1:0: information: Unmatched suppression: error [unmatchedSuppression]' ,
3848- 'lib/test.c :-1:0: information: Unmatched suppression: error2 [unmatchedSuppression]' ,
3849- 'lib/test.c :-1:0: information: Unmatched suppression: error3 [unmatchedSuppression]' ,
3850- 'lib/test.c :-1:0: information: Unmatched suppression: error4 [unmatchedSuppression]' ,
3851- 'lib/test.c :-1:0: information: Unmatched suppression: error5 [unmatchedSuppression]' ,
3852- 'lib/test.c :-1:0: information: Unmatched suppression: error6 [unmatchedSuppression]'
3855+ f' { lib_file } :-1:0: information: Unmatched suppression: error [unmatchedSuppression]' ,
3856+ f' { lib_file } :-1:0: information: Unmatched suppression: error2 [unmatchedSuppression]' ,
3857+ f' { lib_file } :-1:0: information: Unmatched suppression: error3 [unmatchedSuppression]' ,
3858+ f' { lib_file } :-1:0: information: Unmatched suppression: error4 [unmatchedSuppression]' ,
3859+ f' { lib_file } :-1:0: information: Unmatched suppression: error5 [unmatchedSuppression]' ,
3860+ f' { lib_file } :-1:0: information: Unmatched suppression: error6 [unmatchedSuppression]'
38533861 ]
38543862 assert ret == 0 , stdout
0 commit comments