@@ -522,6 +522,10 @@ class TestCmdlineParser : public TestFixture {
522522 TEST_CASE (ignoreUnused1);
523523 TEST_CASE (ignoreUnused2);
524524 TEST_CASE (ignoreUsed);
525+ TEST_CASE (ignoreUsedInExcludedDir1);
526+ TEST_CASE (ignoreUsedInExcludedDir2);
527+ TEST_CASE (ignoreUsedInExcludedDir3);
528+ TEST_CASE (ignoreUnusedExcludedDir);
525529 TEST_CASE (ignoreUnusedProject);
526530 TEST_CASE (ignoreUsedProject);
527531
@@ -3682,6 +3686,47 @@ class TestCmdlineParser : public TestFixture {
36823686 ASSERT_EQUALS (" file2.cpp" , parser->getFiles ().cbegin ()->path ());
36833687 }
36843688
3689+ // the files in an excluded directory are not listed, a pattern that matches them is still used
3690+ void ignoreUsedInExcludedDir1 () {
3691+ REDIRECT ;
3692+ ScopedFile file1 (" a.cpp" , " " , " iued1" );
3693+ ScopedFile file2 (" b.cpp" , " " , " iued1/sub" );
3694+ const char * const argv[] = {" cppcheck" , " -iiued1/sub/" , " -ib.cpp" , " iued1" };
3695+ ASSERT (fillSettingsFromArgs (argv));
3696+ ASSERT_EQUALS (" " , logger->str ());
3697+ ASSERT_EQUALS (1 , parser->getFiles ().size ());
3698+ ASSERT_EQUALS (" iued1/a.cpp" , parser->getFiles ().cbegin ()->path ());
3699+ }
3700+
3701+ void ignoreUsedInExcludedDir2 () {
3702+ REDIRECT ;
3703+ ScopedFile file1 (" a.cpp" , " " , " iued2" );
3704+ ScopedFile file2 (" b.cpp" , " " , " iued2/sub" );
3705+ const char * const argv[] = {" cppcheck" , " -iiued2/sub/" , " -isub/b.cpp" , " iued2" };
3706+ ASSERT (fillSettingsFromArgs (argv));
3707+ ASSERT_EQUALS (" " , logger->str ());
3708+ ASSERT_EQUALS (1 , parser->getFiles ().size ());
3709+ }
3710+
3711+ void ignoreUsedInExcludedDir3 () {
3712+ REDIRECT ;
3713+ ScopedFile file1 (" a.cpp" , " " , " iued3" );
3714+ ScopedFile file2 (" b.pb.cc" , " " , " iued3/third_party" );
3715+ const char * const argv[] = {" cppcheck" , " -iiued3/third_party/" , " -i*.pb.cc" , " iued3" };
3716+ ASSERT (fillSettingsFromArgs (argv));
3717+ ASSERT_EQUALS (" " , logger->str ());
3718+ ASSERT_EQUALS (1 , parser->getFiles ().size ());
3719+ }
3720+
3721+ void ignoreUnusedExcludedDir () {
3722+ REDIRECT ;
3723+ ScopedFile file1 (" a.cpp" , " " , " iued4" );
3724+ ScopedFile file2 (" b.cpp" , " " , " iued4/sub" );
3725+ const char * const argv[] = {" cppcheck" , " -iiued4/sub/" , " -ic.cpp" , " iued4" };
3726+ ASSERT (!fillSettingsFromArgs (argv));
3727+ ASSERT_EQUALS (" cppcheck: error: unused ignore/exclude path 'c.cpp'. To hide warnings in certain files use suppressions instead.\n " , logger->str ());
3728+ }
3729+
36853730 void ignoreUnusedProject () {
36863731 REDIRECT ;
36873732 ScopedFile file (" compile_commands.json" ,
0 commit comments