Skip to content

Commit

Permalink
fixed #13627 - bail out on nested GUI projects instead of ignoring th…
Browse files Browse the repository at this point in the history
…em silently (#7294)
  • Loading branch information
firewave authored Feb 13, 2025
1 parent 42d3df2 commit 0593984
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cli/cmdlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,10 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
// read underlying project
projectFile = projectFileGui;
projType = project.import(projectFileGui, &mSettings, &mSuppressions);
if (projType == ImportProject::Type::CPPCHECK_GUI) {
mLogger.printError("nested Cppcheck GUI projects are not supported.");
return Result::Fail;
}
}
}
if (projType == ImportProject::Type::VS_SLN || projType == ImportProject::Type::VS_VCXPROJ) {
Expand Down
36 changes: 36 additions & 0 deletions test/cli/more-projects_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,3 +861,39 @@ def test_shared_items_project():
# Assume no errors, and that shared items code files have been checked as well
assert '2/2 files checked ' in stdout # only perform partial check since -j2 does not report a percentage right now
assert stderr == ''


def test_project_file_nested(tmp_path):
test_file = tmp_path / 'test.c'
with open(test_file, 'wt'):
pass

level3_file = tmp_path / 'level3.cppcheck'
with open(level3_file, 'wt') as f:
f.write(
"""<project>
<paths>
<dir name="{}"/>
</paths>
</project>""".format(test_file))

level2_file = tmp_path / 'level2.cppcheck'
with open(level2_file, 'wt') as f:
f.write(
"""<project>
<importproject>level3.cppcheck</importproject>
</project>""")

level1_file = tmp_path / 'level1.cppcheck'
with open(level1_file, 'wt') as f:
f.write(
"""<project>
<importproject>level2.cppcheck</importproject>
</project>""")

args = ['--project={}'.format(level1_file)]
out_lines = [
'cppcheck: error: nested Cppcheck GUI projects are not supported.'
]

assert_cppcheck(args, ec_exp=1, err_exp=[], out_exp=out_lines)

0 comments on commit 0593984

Please sign in to comment.