fixed #12016 - ProcessExecutor: added missing invocation of clang-tidy (#5529)

No changes in tests since the intercepted invocation function in called
in a forked process. The clang-tidy integration is also broken.
This commit is contained in:
Oliver Stöneberg 2023-10-09 12:26:58 +02:00 committed by GitHub
parent 2f62e9d316
commit cc92b09ec1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 2 deletions

View File

@ -277,7 +277,8 @@ unsigned int ProcessExecutor::check()
if (iFileSettings != mSettings.project.fileSettings.end()) {
resultOfCheck = fileChecker.check(*iFileSettings);
// TODO: call analyseClangTidy()
if (fileChecker.settings().clangTidy)
fileChecker.analyseClangTidy(*iFileSettings);
} else {
// Read file from a file
resultOfCheck = fileChecker.check(iFile->first);

View File

@ -1,6 +1,7 @@
# python -m pytest test-more-projects.py
import json
import os
import pytest
from testutils import cppcheck
@ -251,4 +252,42 @@ def test_project_std(tmpdir):
ret, stdout, stderr = cppcheck(['--project=' + compile_commands, '--enable=all', '-rp=' + str(tmpdir), '--template=cppcheck1'])
assert ret == 0, stdout
assert (stderr == '[bug1.cpp:3]: (error) Division by zero.\n')
assert (stderr == '[bug1.cpp:3]: (error) Division by zero.\n')
@pytest.mark.skip() # clang-tidy is not available in all cases
def test_clang_tidy(tmpdir):
test_file = os.path.join(tmpdir, 'test.cpp')
with open(test_file, 'wt') as f:
f.write("""
int main(int argc)
{
(void)argc;
}
""")
project_file = os.path.join(tmpdir, 'test.cppcheck')
with open(project_file, 'wt') as f:
f.write(
"""<?xml version="1.0" encoding="UTF-8"?>
<project version="1">
<paths>
<dir name="{}"/>
</paths>>
<tools>
<tool>clang-tidy</tool>
</tools>
</project>""".format(test_file))
args = ['--project={}'.format(project_file)]
exitcode, stdout, stderr = cppcheck(args)
assert exitcode == 0, stdout
lines = stdout.splitlines()
# TODO: should detect clang-tidy issue
assert len(lines) == 1
assert lines == [
'Checking {} ...'.format(test_file)
]
assert stderr == ''