Skip to content

Commit 9f3f41d

Browse files
authored
fixed #13941 - do not overwrite addons from CLI in GUI project import (#7603)
also added some TODOs
1 parent 8833e3e commit 9f3f41d

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

lib/importproject.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,9 +1325,9 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings &setti
13251325
} else if (strcmp(name, CppcheckXml::BuildDirElementName) == 0)
13261326
temp.buildDir = joinRelativePath(path, empty_if_null(node->GetText()));
13271327
else if (strcmp(name, CppcheckXml::IncludeDirElementName) == 0)
1328-
temp.includePaths = readXmlStringList(node, path, CppcheckXml::DirElementName, CppcheckXml::DirNameAttrib);
1328+
temp.includePaths = readXmlStringList(node, path, CppcheckXml::DirElementName, CppcheckXml::DirNameAttrib); // TODO: append instead of overwrite
13291329
else if (strcmp(name, CppcheckXml::DefinesElementName) == 0)
1330-
temp.userDefines = join(readXmlStringList(node, "", CppcheckXml::DefineName, CppcheckXml::DefineNameAttrib), ";");
1330+
temp.userDefines = join(readXmlStringList(node, "", CppcheckXml::DefineName, CppcheckXml::DefineNameAttrib), ";"); // TODO: append instead of overwrite
13311331
else if (strcmp(name, CppcheckXml::UndefinesElementName) == 0) {
13321332
for (const std::string &u : readXmlStringList(node, "", CppcheckXml::UndefineName, nullptr))
13331333
temp.userUndefs.insert(u);
@@ -1339,15 +1339,15 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings &setti
13391339
else if (strcmp(name, CppcheckXml::PathsElementName) == 0)
13401340
paths = readXmlStringList(node, path, CppcheckXml::PathName, CppcheckXml::PathNameAttrib);
13411341
else if (strcmp(name, CppcheckXml::ExcludeElementName) == 0)
1342-
guiProject.excludedPaths = readXmlStringList(node, "", CppcheckXml::ExcludePathName, CppcheckXml::ExcludePathNameAttrib);
1342+
guiProject.excludedPaths = readXmlStringList(node, "", CppcheckXml::ExcludePathName, CppcheckXml::ExcludePathNameAttrib); // TODO: append instead of overwrite
13431343
else if (strcmp(name, CppcheckXml::FunctionContracts) == 0)
13441344
;
13451345
else if (strcmp(name, CppcheckXml::VariableContractsElementName) == 0)
13461346
;
13471347
else if (strcmp(name, CppcheckXml::IgnoreElementName) == 0)
1348-
guiProject.excludedPaths = readXmlStringList(node, "", CppcheckXml::IgnorePathName, CppcheckXml::IgnorePathNameAttrib);
1348+
guiProject.excludedPaths = readXmlStringList(node, "", CppcheckXml::IgnorePathName, CppcheckXml::IgnorePathNameAttrib); // TODO: append instead of overwrite
13491349
else if (strcmp(name, CppcheckXml::LibrariesElementName) == 0)
1350-
guiProject.libraries = readXmlStringList(node, "", CppcheckXml::LibraryElementName, nullptr);
1350+
guiProject.libraries = readXmlStringList(node, "", CppcheckXml::LibraryElementName, nullptr); // TODO: append instead of overwrite
13511351
else if (strcmp(name, CppcheckXml::SuppressionsElementName) == 0) {
13521352
for (const tinyxml2::XMLElement *child = node->FirstChildElement(); child; child = child->NextSiblingElement()) {
13531353
if (strcmp(child->Name(), CppcheckXml::SuppressionElementName) != 0)
@@ -1439,13 +1439,14 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings &setti
14391439
return false;
14401440
}
14411441
}
1442-
settings.basePaths = temp.basePaths;
1442+
settings.basePaths = temp.basePaths; // TODO: append instead of overwrite
14431443
settings.relativePaths |= temp.relativePaths;
14441444
settings.buildDir = temp.buildDir;
1445-
settings.includePaths = temp.includePaths;
1446-
settings.userDefines = temp.userDefines;
1447-
settings.userUndefs = temp.userUndefs;
1448-
settings.addons = temp.addons;
1445+
settings.includePaths = temp.includePaths; // TODO: append instead of overwrite
1446+
settings.userDefines = temp.userDefines; // TODO: append instead of overwrite
1447+
settings.userUndefs = temp.userUndefs; // TODO: append instead of overwrite
1448+
for (const std::string &addon : temp.addons)
1449+
settings.addons.emplace(addon);
14491450
settings.clang = temp.clang;
14501451
settings.clangTidy = temp.clangTidy;
14511452
settings.analyzeAllVsConfigs = temp.analyzeAllVsConfigs;

test/cli/lookup_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,14 +675,13 @@ def test_addon_lookup_notfound(tmpdir):
675675
]
676676

677677

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

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

0 commit comments

Comments
 (0)