diff --git a/lib/errorlogger.cpp b/lib/errorlogger.cpp
index c1a7e6874f2..69b9667323f 100644
--- a/lib/errorlogger.cpp
+++ b/lib/errorlogger.cpp
@@ -170,6 +170,9 @@ ErrorMessage::ErrorMessage(const tinyxml2::XMLElement * const errmsg)
const char *attr = errmsg->Attribute("id");
id = attr ? attr : unknown;
+ attr = errmsg->Attribute("file0");
+ file0 = attr ? attr : "";
+
attr = errmsg->Attribute("severity");
severity = attr ? severityFromString(attr) : Severity::none;
diff --git a/test/cli/other_test.py b/test/cli/other_test.py
index 720b483d458..598151b5b6f 100644
--- a/test/cli/other_test.py
+++ b/test/cli/other_test.py
@@ -2675,11 +2675,7 @@ def test_duplicate_suppressions_mixed(tmp_path):
assert stderr == ''
-@pytest.mark.xfail(strict=True)
-def test_xml_builddir(tmp_path): # #13391 / #13485
- build_dir = tmp_path / 'b1'
- os.mkdir(build_dir)
-
+def test_xml_output(tmp_path): # #13391 / #13485
test_file = tmp_path / 'test.cpp'
with open(test_file, 'wt') as f:
f.write("""
@@ -2690,35 +2686,31 @@ def test_xml_builddir(tmp_path): # #13391 / #13485
}
""")
+ _, version_str, _ = cppcheck(['--version'])
+ version_str = version_str.replace('Cppcheck ', '').strip()
+
args = [
'-q',
'--enable=style',
- '--cppcheck-build-dir={}'.format(build_dir),
'--xml',
str(test_file)
]
exitcode_1, stdout_1, stderr_1 = cppcheck(args)
assert exitcode_1 == 0, stdout_1
assert stdout_1 == ''
- # TODO: handle version
assert (stderr_1 ==
- '''
-
-
-
-
-
-
- p
-
-
-
- '''.format(test_file, test_file, test_file))
-
- exitcode_2, stdout_2, stderr_2 = cppcheck(args)
- assert exitcode_1 == exitcode_2, stdout_2
- assert stdout_1 == stdout_2
- assert stderr_1 == stderr_2
+'''
+
+
+
+
+
+
+ p
+
+
+
+'''.format(version_str, str(test_file).replace('\\', '/'), test_file, test_file)) # TODO: the slashes are inconsistent
def test_internal_error_loc_int(tmp_path):
diff --git a/test/cli/testutils.py b/test/cli/testutils.py
index 86fe66e3f44..00b9483d08e 100644
--- a/test/cli/testutils.py
+++ b/test/cli/testutils.py
@@ -152,7 +152,10 @@ def cppcheck_ex(args, env=None, remove_checkers_report=True, cwd=None, cppcheck_
exe = cppcheck_exe if cppcheck_exe else __lookup_cppcheck_exe()
assert exe is not None, 'no cppcheck binary found'
- if 'TEST_CPPCHECK_INJECT_J' in os.environ:
+ # do not inject arguments for calls with exclusive options
+ has_exclusive = bool({'--doc', '--errorlist', '-h', '--help', '--version'} & set(args))
+
+ if not has_exclusive and ('TEST_CPPCHECK_INJECT_J' in os.environ):
found_j = False
for arg in args:
if arg.startswith('-j'):
@@ -162,7 +165,7 @@ def cppcheck_ex(args, env=None, remove_checkers_report=True, cwd=None, cppcheck_
arg_j = '-j' + str(os.environ['TEST_CPPCHECK_INJECT_J'])
args.append(arg_j)
- if 'TEST_CPPCHECK_INJECT_CLANG' in os.environ:
+ if not has_exclusive and ('TEST_CPPCHECK_INJECT_CLANG' in os.environ):
found_clang = False
for arg in args:
if arg.startswith('--clang'):
@@ -172,7 +175,7 @@ def cppcheck_ex(args, env=None, remove_checkers_report=True, cwd=None, cppcheck_
arg_clang = '--clang=' + str(os.environ['TEST_CPPCHECK_INJECT_CLANG'])
args.append(arg_clang)
- if 'TEST_CPPCHECK_INJECT_EXECUTOR' in os.environ:
+ if not has_exclusive and ('TEST_CPPCHECK_INJECT_EXECUTOR' in os.environ):
found_jn = False
found_executor = False
for arg in args:
@@ -189,7 +192,7 @@ def cppcheck_ex(args, env=None, remove_checkers_report=True, cwd=None, cppcheck_
builddir_tmp = None
- if 'TEST_CPPCHECK_INJECT_BUILDDIR' in os.environ:
+ if not has_exclusive and ('TEST_CPPCHECK_INJECT_BUILDDIR' in os.environ):
found_builddir = False
for arg in args:
if arg.startswith('--cppcheck-build-dir=') or arg == '--no-cppcheck-build-dir':