File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 4
4
import os
5
5
import sys
6
6
import pytest
7
+ import glob
7
8
import json
8
9
import subprocess
9
10
@@ -3328,6 +3329,34 @@ def test_preprocess_enforced_cpp(tmp_path): # #10989
3328
3329
]
3329
3330
3330
3331
3332
+ def test_preprocess_system_include (tmp_path ): # #13928
3333
+ g = glob .glob ('/usr/include/c++/*/string' )
3334
+ if len (g ) != 1 :
3335
+ pytest .skip ('<string> header file not found' )
3336
+
3337
+ test_file = tmp_path / 'test.c'
3338
+ with open (test_file , 'wt' ) as f :
3339
+ f .write ('#include <string>\n '
3340
+ ';\n ' )
3341
+
3342
+ def has_missing_include_string_warning (e ):
3343
+ return '<string>' in e
3344
+
3345
+ args = [
3346
+ '--enable=missingInclude' ,
3347
+ str (test_file )
3348
+ ]
3349
+
3350
+ # include path not provided => missing include warning about <string>
3351
+ _ , _ , stderr = cppcheck (args )
3352
+ assert has_missing_include_string_warning (stderr ), stderr
3353
+
3354
+ # include path provided => no missing include warning about <string>
3355
+ args .append ('-I' + os .path .dirname (str (g [0 ])))
3356
+ _ , _ , stderr = cppcheck (args )
3357
+ assert not has_missing_include_string_warning (stderr ), stderr
3358
+
3359
+
3331
3360
# TODO: test with --xml
3332
3361
def __test_debug_normal (tmp_path , verbose ):
3333
3362
test_file = tmp_path / 'test.c'
You can’t perform that action at this time.
0 commit comments