From 8855978f8aef6a4748fa0a371ecfc2385666993c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 12 Sep 2019 09:32:24 +0200 Subject: [PATCH] Import project: Ignoring paths better --- lib/importproject.cpp | 9 +++++++-- test/cli/test-helloworld.py | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 79fbb299a..0c786cffa 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -39,12 +39,17 @@ void ImportProject::ignorePaths(const std::vector &ipaths) for (std::list::iterator it = fileSettings.begin(); it != fileSettings.end();) { bool ignore = false; for (std::string i : ipaths) { - if (!Path::isAbsolute(i)) - i = mPath + i; if (it->filename.size() > i.size() && it->filename.compare(0,i.size(),i)==0) { ignore = true; break; } + if (!Path::isAbsolute(i)) { + i = mPath + i; + if (it->filename.size() > i.size() && it->filename.compare(0,i.size(),i)==0) { + ignore = true; + break; + } + } } if (ignore) fileSettings.erase(it++); diff --git a/test/cli/test-helloworld.py b/test/cli/test-helloworld.py index 798502589..f6a767bc3 100644 --- a/test/cli/test-helloworld.py +++ b/test/cli/test-helloworld.py @@ -179,3 +179,9 @@ def test_suppress_project(): assert stderr == '' +def test_exclude(): + prjpath = getRelativeProjectPath() + ret, stdout, stderr = cppcheck(['-i' + prjpath, '--platform=win64', '--project=' + os.path.join(prjpath, 'helloworld.cppcheck')]) + assert stdout == 'cppcheck: No C or C++ source files found.\n' + +