Suppressions: Handle comment in file that starts with #

This commit is contained in:
Daniel Marjamäki 2019-01-12 15:21:47 +01:00
parent c334d959ce
commit 1cd16cf94f
2 changed files with 15 additions and 0 deletions

View File

@ -74,6 +74,8 @@ std::string Suppressions::parseFile(std::istream &istr)
continue; continue;
// Skip comments // Skip comments
if (line.length() > 1 && line[0] == '#')
continue;
if (line.length() >= 2 && line[0] == '/' && line[1] == '/') if (line.length() >= 2 && line[0] == '/' && line[1] == '/')
continue; continue;

View File

@ -48,6 +48,7 @@ private:
TEST_CASE(suppressionsMultiFile); TEST_CASE(suppressionsMultiFile);
TEST_CASE(suppressionsPathSeparator); TEST_CASE(suppressionsPathSeparator);
TEST_CASE(suppressionsLine0); TEST_CASE(suppressionsLine0);
TEST_CASE(suppressionsFileComment);
TEST_CASE(inlinesuppress); TEST_CASE(inlinesuppress);
TEST_CASE(inlinesuppress_symbolname); TEST_CASE(inlinesuppress_symbolname);
@ -411,6 +412,18 @@ private:
ASSERT_EQUALS(true, suppressions.isSuppressed(errorMessage("syntaxError", "test.cpp", 0))); ASSERT_EQUALS(true, suppressions.isSuppressed(errorMessage("syntaxError", "test.cpp", 0)));
} }
void suppressionsFileComment() {
std::istringstream file1("# comment\nabc");
Suppressions suppressions1;
suppressions1.parseFile(file1);
ASSERT_EQUALS(true, suppressions1.isSuppressed(errorMessage("abc", "test.cpp", 123)));
std::istringstream file2("// comment\nabc");
Suppressions suppressions2;
suppressions2.parseFile(file2);
ASSERT_EQUALS(true, suppressions2.isSuppressed(errorMessage("abc", "test.cpp", 123)));
}
void inlinesuppress() { void inlinesuppress() {
Suppressions::Suppression s; Suppressions::Suppression s;
std::string msg; std::string msg;