Skip to content

Commit 4b750fe

Browse files
committed
fixed #13941 - do not overwrite addons from CLI in GUI project import
also added some TODOs
1 parent 8605900 commit 4b750fe

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
@@ -1292,9 +1292,9 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings &setti
12921292
} else if (strcmp(name, CppcheckXml::BuildDirElementName) == 0)
12931293
temp.buildDir = joinRelativePath(path, empty_if_null(node->GetText()));
12941294
else if (strcmp(name, CppcheckXml::IncludeDirElementName) == 0)
1295-
temp.includePaths = readXmlStringList(node, path, CppcheckXml::DirElementName, CppcheckXml::DirNameAttrib);
1295+
temp.includePaths = readXmlStringList(node, path, CppcheckXml::DirElementName, CppcheckXml::DirNameAttrib); // TODO: append instead of overwrite
12961296
else if (strcmp(name, CppcheckXml::DefinesElementName) == 0)
1297-
temp.userDefines = join(readXmlStringList(node, "", CppcheckXml::DefineName, CppcheckXml::DefineNameAttrib), ";");
1297+
temp.userDefines = join(readXmlStringList(node, "", CppcheckXml::DefineName, CppcheckXml::DefineNameAttrib), ";"); // TODO: append instead of overwrite
12981298
else if (strcmp(name, CppcheckXml::UndefinesElementName) == 0) {
12991299
for (const std::string &u : readXmlStringList(node, "", CppcheckXml::UndefineName, nullptr))
13001300
temp.userUndefs.insert(u);
@@ -1306,15 +1306,15 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings &setti
13061306
else if (strcmp(name, CppcheckXml::PathsElementName) == 0)
13071307
paths = readXmlStringList(node, path, CppcheckXml::PathName, CppcheckXml::PathNameAttrib);
13081308
else if (strcmp(name, CppcheckXml::ExcludeElementName) == 0)
1309-
guiProject.excludedPaths = readXmlStringList(node, "", CppcheckXml::ExcludePathName, CppcheckXml::ExcludePathNameAttrib);
1309+
guiProject.excludedPaths = readXmlStringList(node, "", CppcheckXml::ExcludePathName, CppcheckXml::ExcludePathNameAttrib); // TODO: append instead of overwrite
13101310
else if (strcmp(name, CppcheckXml::FunctionContracts) == 0)
13111311
;
13121312
else if (strcmp(name, CppcheckXml::VariableContractsElementName) == 0)
13131313
;
13141314
else if (strcmp(name, CppcheckXml::IgnoreElementName) == 0)
1315-
guiProject.excludedPaths = readXmlStringList(node, "", CppcheckXml::IgnorePathName, CppcheckXml::IgnorePathNameAttrib);
1315+
guiProject.excludedPaths = readXmlStringList(node, "", CppcheckXml::IgnorePathName, CppcheckXml::IgnorePathNameAttrib); // TODO: append instead of overwrite
13161316
else if (strcmp(name, CppcheckXml::LibrariesElementName) == 0)
1317-
guiProject.libraries = readXmlStringList(node, "", CppcheckXml::LibraryElementName, nullptr);
1317+
guiProject.libraries = readXmlStringList(node, "", CppcheckXml::LibraryElementName, nullptr); // TODO: append instead of overwrite
13181318
else if (strcmp(name, CppcheckXml::SuppressionsElementName) == 0) {
13191319
for (const tinyxml2::XMLElement *child = node->FirstChildElement(); child; child = child->NextSiblingElement()) {
13201320
if (strcmp(child->Name(), CppcheckXml::SuppressionElementName) != 0)
@@ -1406,13 +1406,14 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings &setti
14061406
return false;
14071407
}
14081408
}
1409-
settings.basePaths = temp.basePaths;
1409+
settings.basePaths = temp.basePaths; // TODO: append instead of overwrite
14101410
settings.relativePaths |= temp.relativePaths;
14111411
settings.buildDir = temp.buildDir;
1412-
settings.includePaths = temp.includePaths;
1413-
settings.userDefines = temp.userDefines;
1414-
settings.userUndefs = temp.userUndefs;
1415-
settings.addons = temp.addons;
1412+
settings.includePaths = temp.includePaths; // TODO: append instead of overwrite
1413+
settings.userDefines = temp.userDefines; // TODO: append instead of overwrite
1414+
settings.userUndefs = temp.userUndefs; // TODO: append instead of overwrite
1415+
for (const std::string &addon : temp.addons)
1416+
settings.addons.emplace(addon);
14161417
settings.clang = temp.clang;
14171418
settings.clangTidy = temp.clangTidy;
14181419
settings.analyzeAllVsConfigs = temp.analyzeAllVsConfigs;

test/cli/lookup_test.py

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

670670

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

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

0 commit comments

Comments
 (0)