Skip to content

Commit 0b4c55a

Browse files
authored
Fix #13928 (existing system include is not found) (danmar#7678)
1 parent c8d2b2b commit 0b4c55a

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/cli/other_test.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import os
55
import sys
66
import pytest
7+
import glob
78
import json
89
import 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
33323361
def __test_debug_normal(tmp_path, verbose):
33333362
test_file = tmp_path / 'test.c'

0 commit comments

Comments
 (0)