Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 == ''