TestCmdLineParser: Add tests for ignored paths

This commit is contained in:
Daniel Marjamäki 2023-01-01 15:32:37 +01:00
parent cac86ada2b
commit bf11cdf299
1 changed files with 49 additions and 55 deletions

View File

@ -159,15 +159,12 @@ private:
TEST_CASE(valueFlowMaxIterationsInvalid2); TEST_CASE(valueFlowMaxIterationsInvalid2);
TEST_CASE(valueFlowMaxIterationsInvalid3); TEST_CASE(valueFlowMaxIterationsInvalid3);
// TODO TEST_CASE(ignorepaths1);
// Disabling these tests since they use relative paths to the TEST_CASE(ignorepaths2);
// testrunner executable. TEST_CASE(ignorepaths3);
//TEST_CASE(ignorepaths1); TEST_CASE(ignorepaths4);
//TEST_CASE(ignorepaths2); TEST_CASE(ignorefilepaths1);
//TEST_CASE(ignorepaths3); TEST_CASE(ignorefilepaths2);
//TEST_CASE(ignorepaths4);
//TEST_CASE(ignorefilepaths1);
//TEST_CASE(ignorefilepaths2);
TEST_CASE(checkconfig); TEST_CASE(checkconfig);
TEST_CASE(unknownParam); TEST_CASE(unknownParam);
@ -1303,15 +1300,13 @@ private:
ASSERT(!defParser.parseFromArgs(2, argv)); ASSERT(!defParser.parseFromArgs(2, argv));
ASSERT_EQUALS("cppcheck: error: argument to '--valueflow-max-iteration' needs to be at least 0.\n", GET_REDIRECT_OUTPUT); ASSERT_EQUALS("cppcheck: error: argument to '--valueflow-max-iteration' needs to be at least 0.\n", GET_REDIRECT_OUTPUT);
} }
/*
void ignorepaths1() { void ignorepaths1() {
REDIRECT; REDIRECT;
const char * const argv[] = {"cppcheck", "-isrc", "file.cpp"}; const char * const argv[] = {"cppcheck", "-isrc", "file.cpp"};
CmdLineParser parser(&settings); CmdLineParser parser(&settings);
ASSERT(parser.parseFromArgs(3, argv)); ASSERT(parser.parseFromArgs(3, argv));
ASSERT_EQUALS(1, parser.getIgnoredPaths().size()); ASSERT_EQUALS(1, parser.getIgnoredPaths().size());
ASSERT_EQUALS("src/", parser.getIgnoredPaths()[0]); ASSERT_EQUALS("src", parser.getIgnoredPaths()[0]);
ASSERT_EQUALS("", GET_REDIRECT_OUTPUT); ASSERT_EQUALS("", GET_REDIRECT_OUTPUT);
} }
@ -1321,7 +1316,7 @@ private:
CmdLineParser parser(&settings); CmdLineParser parser(&settings);
ASSERT(parser.parseFromArgs(4, argv)); ASSERT(parser.parseFromArgs(4, argv));
ASSERT_EQUALS(1, parser.getIgnoredPaths().size()); ASSERT_EQUALS(1, parser.getIgnoredPaths().size());
ASSERT_EQUALS("src/", parser.getIgnoredPaths()[0]); ASSERT_EQUALS("src", parser.getIgnoredPaths()[0]);
ASSERT_EQUALS("", GET_REDIRECT_OUTPUT); ASSERT_EQUALS("", GET_REDIRECT_OUTPUT);
} }
@ -1331,8 +1326,8 @@ private:
CmdLineParser parser(&settings); CmdLineParser parser(&settings);
ASSERT(parser.parseFromArgs(4, argv)); ASSERT(parser.parseFromArgs(4, argv));
ASSERT_EQUALS(2, parser.getIgnoredPaths().size()); ASSERT_EQUALS(2, parser.getIgnoredPaths().size());
ASSERT_EQUALS("src/", parser.getIgnoredPaths()[0]); ASSERT_EQUALS("src", parser.getIgnoredPaths()[0]);
ASSERT_EQUALS("module/", parser.getIgnoredPaths()[1]); ASSERT_EQUALS("module", parser.getIgnoredPaths()[1]);
ASSERT_EQUALS("", GET_REDIRECT_OUTPUT); ASSERT_EQUALS("", GET_REDIRECT_OUTPUT);
} }
@ -1342,8 +1337,8 @@ private:
CmdLineParser parser(&settings); CmdLineParser parser(&settings);
ASSERT(parser.parseFromArgs(6, argv)); ASSERT(parser.parseFromArgs(6, argv));
ASSERT_EQUALS(2, parser.getIgnoredPaths().size()); ASSERT_EQUALS(2, parser.getIgnoredPaths().size());
ASSERT_EQUALS("src/", parser.getIgnoredPaths()[0]); ASSERT_EQUALS("src", parser.getIgnoredPaths()[0]);
ASSERT_EQUALS("module/", parser.getIgnoredPaths()[1]); ASSERT_EQUALS("module", parser.getIgnoredPaths()[1]);
ASSERT_EQUALS("", GET_REDIRECT_OUTPUT); ASSERT_EQUALS("", GET_REDIRECT_OUTPUT);
} }
@ -1366,7 +1361,6 @@ private:
ASSERT_EQUALS("src/foo.cpp", parser.getIgnoredPaths()[0]); ASSERT_EQUALS("src/foo.cpp", parser.getIgnoredPaths()[0]);
ASSERT_EQUALS("", GET_REDIRECT_OUTPUT); ASSERT_EQUALS("", GET_REDIRECT_OUTPUT);
} }
*/
void checkconfig() { void checkconfig() {
REDIRECT; REDIRECT;