Skip to content

Commit 0593984

Browse files
authored
fixed #13627 - bail out on nested GUI projects instead of ignoring them silently (#7294)
1 parent 42d3df2 commit 0593984

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

cli/cmdlineparser.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,10 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
11681168
// read underlying project
11691169
projectFile = projectFileGui;
11701170
projType = project.import(projectFileGui, &mSettings, &mSuppressions);
1171+
if (projType == ImportProject::Type::CPPCHECK_GUI) {
1172+
mLogger.printError("nested Cppcheck GUI projects are not supported.");
1173+
return Result::Fail;
1174+
}
11711175
}
11721176
}
11731177
if (projType == ImportProject::Type::VS_SLN || projType == ImportProject::Type::VS_VCXPROJ) {

test/cli/more-projects_test.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,3 +861,39 @@ def test_shared_items_project():
861861
# Assume no errors, and that shared items code files have been checked as well
862862
assert '2/2 files checked ' in stdout # only perform partial check since -j2 does not report a percentage right now
863863
assert stderr == ''
864+
865+
866+
def test_project_file_nested(tmp_path):
867+
test_file = tmp_path / 'test.c'
868+
with open(test_file, 'wt'):
869+
pass
870+
871+
level3_file = tmp_path / 'level3.cppcheck'
872+
with open(level3_file, 'wt') as f:
873+
f.write(
874+
"""<project>
875+
<paths>
876+
<dir name="{}"/>
877+
</paths>
878+
</project>""".format(test_file))
879+
880+
level2_file = tmp_path / 'level2.cppcheck'
881+
with open(level2_file, 'wt') as f:
882+
f.write(
883+
"""<project>
884+
<importproject>level3.cppcheck</importproject>
885+
</project>""")
886+
887+
level1_file = tmp_path / 'level1.cppcheck'
888+
with open(level1_file, 'wt') as f:
889+
f.write(
890+
"""<project>
891+
<importproject>level2.cppcheck</importproject>
892+
</project>""")
893+
894+
args = ['--project={}'.format(level1_file)]
895+
out_lines = [
896+
'cppcheck: error: nested Cppcheck GUI projects are not supported.'
897+
]
898+
899+
assert_cppcheck(args, ec_exp=1, err_exp=[], out_exp=out_lines)

0 commit comments

Comments
 (0)