Skip to content

Commit 9787005

Browse files
committed
fixed #13391 - fixed missing file0 in cached XML results
1 parent c3e9d01 commit 9787005

2 files changed

Lines changed: 9 additions & 14 deletions

File tree

lib/errorlogger.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ ErrorMessage::ErrorMessage(const tinyxml2::XMLElement * const errmsg)
170170
const char *attr = errmsg->Attribute("id");
171171
id = attr ? attr : unknown;
172172

173+
attr = errmsg->Attribute("file0");
174+
file0 = attr ? attr : "";
175+
173176
attr = errmsg->Attribute("severity");
174177
severity = attr ? severityFromString(attr) : Severity::none;
175178

test/cli/other_test.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2491,11 +2491,7 @@ def test_dump_check_config(tmp_path): # #13432
24912491
assert not os.path.exists(str(test_file) + '.dump')
24922492

24932493

2494-
@pytest.mark.xfail(strict=True)
2495-
def test_xml_builddir(tmp_path): # #13391 / #13485
2496-
build_dir = tmp_path / 'b1'
2497-
os.mkdir(build_dir)
2498-
2494+
def test_xml_output(tmp_path): # #13391 / #13485
24992495
test_file = tmp_path / 'test.cpp'
25002496
with open(test_file, 'wt') as f:
25012497
f.write("""
@@ -2506,21 +2502,22 @@ def test_xml_builddir(tmp_path): # #13391 / #13485
25062502
}
25072503
""")
25082504

2505+
_, version_str, _ = cppcheck(['--version'])
2506+
version_str = version_str.replace('Cppcheck ', '').strip()
2507+
25092508
args = [
25102509
'-q',
25112510
'--enable=style',
2512-
'--cppcheck-build-dir={}'.format(build_dir),
25132511
'--xml',
25142512
str(test_file)
25152513
]
25162514
exitcode_1, stdout_1, stderr_1 = cppcheck(args)
25172515
assert exitcode_1 == 0, stdout_1
25182516
assert stdout_1 == ''
2519-
# TODO: handle version
25202517
assert (stderr_1 ==
25212518
'''<?xml version="1.0" encoding="UTF-8"?>
25222519
<results version="2">
2523-
<cppcheck version="2.17 dev"/>
2520+
<cppcheck version="{}"/>
25242521
<errors>
25252522
<error id="nullPointerRedundantCheck" severity="warning" msg="Either the condition &apos;p&apos; is redundant or there is possible null pointer dereference: p." verbose="Either the condition &apos;p&apos; is redundant or there is possible null pointer dereference: p." cwe="476" file0="{}" remark="boom">
25262523
<location file="{}" line="5" column="12" info="Null pointer dereference"/>
@@ -2529,9 +2526,4 @@ def test_xml_builddir(tmp_path): # #13391 / #13485
25292526
</error>
25302527
</errors>
25312528
</results>
2532-
'''.format(test_file, test_file, test_file))
2533-
2534-
exitcode_2, stdout_2, stderr_2 = cppcheck(args)
2535-
assert exitcode_1 == exitcode_2, stdout_2
2536-
assert stdout_1 == stdout_2
2537-
assert stderr_1 == stderr_2
2529+
'''.format(version_str, str(test_file).replace('\\', '/'), test_file, test_file)) # TODO: the slashes are inconsistent

0 commit comments

Comments
 (0)