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 44import os
55import sys
66import pytest
7+ import glob
78import json
89import subprocess
910
@@ -3328,6 +3329,34 @@ def test_preprocess_enforced_cpp(tmp_path): # #10989
33283329 ]
33293330
33303331
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+
33313360# TODO: test with --xml
33323361def __test_debug_normal (tmp_path , verbose ):
33333362 test_file = tmp_path / 'test.c'
You can’t perform that action at this time.
0 commit comments