Skip to content

Commit

Permalink
fixed #12016 - ProcessExecutor: added missing invocation of clang-tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Oct 8, 2023
1 parent cc44966 commit ddc6785
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cli/processexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,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);
Expand Down
41 changes: 40 additions & 1 deletion test/cli/test-more-projects.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# python -m pytest test-more-projects.py
import json
import os
import pytest
from testutils import cppcheck


Expand Down Expand Up @@ -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 == ''

0 comments on commit ddc6785

Please sign in to comment.