diff --git a/cli/filelister.cpp b/cli/filelister.cpp index 2c7093fcc..2caf0ea98 100644 --- a/cli/filelister.cpp +++ b/cli/filelister.cpp @@ -182,6 +182,9 @@ static std::string addFiles2(std::map &files, const PathMatch& ignored ) { + if (ignored.match(path)) + return ""; + struct stat file_stat; if (stat(path.c_str(), &file_stat) != -1) { if ((file_stat.st_mode & S_IFMT) == S_IFDIR) { diff --git a/test/testfilelister.cpp b/test/testfilelister.cpp index 44fb779ce..ddd464578 100644 --- a/test/testfilelister.cpp +++ b/test/testfilelister.cpp @@ -43,6 +43,7 @@ private: TEST_CASE(isDirectory); TEST_CASE(recursiveAddFiles); + TEST_CASE(excludeFile); TEST_CASE(fileExists); } @@ -78,6 +79,15 @@ private: ASSERT(files.find("lib/tokenize.h") == files.end()); } + void excludeFile() const { + std::map files; + std::vector ignored{"lib/token.cpp"}; + PathMatch matcher(ignored); + std::string err = FileLister::recursiveAddFiles(files, "lib/token.cpp", matcher); + ASSERT(err.empty()); + ASSERT(files.empty()); + } + void fileExists() const { ASSERT_EQUALS(false, FileLister::fileExists("lib")); ASSERT_EQUALS(true, FileLister::fileExists("readme.txt"));