Skip to content

Commit 159c4a2

Browse files
committed
Fix #13928 (existing system include is not found)
1 parent 4d5a7f9 commit 159c4a2

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

test/cli/other_test.py

Lines changed: 30 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,35 @@ 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+
g0 = str(g[0])
3346+
args = [
3347+
'--enable=missingInclude',
3348+
str(test_file)
3349+
]
3350+
3351+
# include path not provided => missing include warning about <string>
3352+
_, _, stderr = cppcheck(args)
3353+
assert has_missing_include_string_warning(stderr), stderr
3354+
3355+
# include path provided => no missing include warning about <string>
3356+
args.append('-I' + g0[:g0.rfind('/')])
3357+
_, _, stderr = cppcheck(args)
3358+
assert not has_missing_include_string_warning(stderr), stderr
3359+
3360+
33313361
# TODO: test with --xml
33323362
def __test_debug_normal(tmp_path, verbose):
33333363
test_file = tmp_path / 'test.c'

0 commit comments

Comments
 (0)