Skip to content

fixed #13941 - do not overwrite addons from CLI in GUI project import #7603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
21 changes: 11 additions & 10 deletions lib/importproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1292,9 +1292,9 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings &setti
} else if (strcmp(name, CppcheckXml::BuildDirElementName) == 0)
temp.buildDir = joinRelativePath(path, empty_if_null(node->GetText()));
else if (strcmp(name, CppcheckXml::IncludeDirElementName) == 0)
temp.includePaths = readXmlStringList(node, path, CppcheckXml::DirElementName, CppcheckXml::DirNameAttrib);
temp.includePaths = readXmlStringList(node, path, CppcheckXml::DirElementName, CppcheckXml::DirNameAttrib); // TODO: append instead of overwrite
else if (strcmp(name, CppcheckXml::DefinesElementName) == 0)
temp.userDefines = join(readXmlStringList(node, "", CppcheckXml::DefineName, CppcheckXml::DefineNameAttrib), ";");
temp.userDefines = join(readXmlStringList(node, "", CppcheckXml::DefineName, CppcheckXml::DefineNameAttrib), ";"); // TODO: append instead of overwrite
else if (strcmp(name, CppcheckXml::UndefinesElementName) == 0) {
for (const std::string &u : readXmlStringList(node, "", CppcheckXml::UndefineName, nullptr))
temp.userUndefs.insert(u);
Expand All @@ -1306,15 +1306,15 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings &setti
else if (strcmp(name, CppcheckXml::PathsElementName) == 0)
paths = readXmlStringList(node, path, CppcheckXml::PathName, CppcheckXml::PathNameAttrib);
else if (strcmp(name, CppcheckXml::ExcludeElementName) == 0)
guiProject.excludedPaths = readXmlStringList(node, "", CppcheckXml::ExcludePathName, CppcheckXml::ExcludePathNameAttrib);
guiProject.excludedPaths = readXmlStringList(node, "", CppcheckXml::ExcludePathName, CppcheckXml::ExcludePathNameAttrib); // TODO: append instead of overwrite
else if (strcmp(name, CppcheckXml::FunctionContracts) == 0)
;
else if (strcmp(name, CppcheckXml::VariableContractsElementName) == 0)
;
else if (strcmp(name, CppcheckXml::IgnoreElementName) == 0)
guiProject.excludedPaths = readXmlStringList(node, "", CppcheckXml::IgnorePathName, CppcheckXml::IgnorePathNameAttrib);
guiProject.excludedPaths = readXmlStringList(node, "", CppcheckXml::IgnorePathName, CppcheckXml::IgnorePathNameAttrib); // TODO: append instead of overwrite
else if (strcmp(name, CppcheckXml::LibrariesElementName) == 0)
guiProject.libraries = readXmlStringList(node, "", CppcheckXml::LibraryElementName, nullptr);
guiProject.libraries = readXmlStringList(node, "", CppcheckXml::LibraryElementName, nullptr); // TODO: append instead of overwrite
else if (strcmp(name, CppcheckXml::SuppressionsElementName) == 0) {
for (const tinyxml2::XMLElement *child = node->FirstChildElement(); child; child = child->NextSiblingElement()) {
if (strcmp(child->Name(), CppcheckXml::SuppressionElementName) != 0)
Expand Down Expand Up @@ -1406,13 +1406,14 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings &setti
return false;
}
}
settings.basePaths = temp.basePaths;
settings.basePaths = temp.basePaths; // TODO: append instead of overwrite
settings.relativePaths |= temp.relativePaths;
settings.buildDir = temp.buildDir;
settings.includePaths = temp.includePaths;
settings.userDefines = temp.userDefines;
settings.userUndefs = temp.userUndefs;
settings.addons = temp.addons;
settings.includePaths = temp.includePaths; // TODO: append instead of overwrite
settings.userDefines = temp.userDefines; // TODO: append instead of overwrite
settings.userUndefs = temp.userUndefs; // TODO: append instead of overwrite
for (const std::string &addon : temp.addons)
settings.addons.emplace(addon);
settings.clang = temp.clang;
settings.clangTidy = temp.clangTidy;
settings.analyzeAllVsConfigs = temp.analyzeAllVsConfigs;
Expand Down
3 changes: 1 addition & 2 deletions test/cli/lookup_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,14 +668,13 @@ def test_addon_lookup_notfound(tmpdir):
]


@pytest.mark.xfail(strict=True) # TODO: no addon lookup is being performed at all
def test_addon_lookup_notfound_project(tmpdir): # #13940 / #13941
project_file, _ = __create_gui_project(tmpdir)

exitcode, stdout, _, exe = cppcheck_ex(['--debug-lookup=addon', '--addon=none', '--project={}'.format(project_file)])
exepath = os.path.dirname(exe)
exepath_sep = exepath + os.path.sep
assert exitcode == 0, stdout
assert exitcode == 1, stdout
lines = stdout.splitlines()
assert lines == [
# TODO: needs to look relative to the project file first
Expand Down
Loading