Skip to content

Commit ba73164

Browse files
authored
refs #13617 - disallow using --debug --xml with multiple input files for now (#7280)
1 parent cdf9d6d commit ba73164

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

Diff for: cli/cmdlineparser.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -1600,6 +1600,12 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
16001600
mFileSettings = project.fileSettings;
16011601
}
16021602

1603+
if (mSettings.debugnormal && mSettings.outputFormat == Settings::OutputFormat::xml && (mPathNames.size() > 1 || mFileSettings.size() > 1))
1604+
{
1605+
mLogger.printError("printing debug output in XML format does not support multiple input files.");
1606+
return Result::Fail;
1607+
}
1608+
16031609
// Use paths _pathnames if no base paths for relative path output are given
16041610
if (mSettings.basePaths.empty() && mSettings.relativePaths)
16051611
mSettings.basePaths = mPathNames;

Diff for: test/testcmdlineparser.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,8 @@ class TestCmdlineParser : public TestFixture {
424424
TEST_CASE(maxTemplateRecursionMissingCount);
425425
TEST_CASE(emitDuplicates);
426426
TEST_CASE(debugClangOutput);
427+
TEST_CASE(debugXmlMultiple);
428+
TEST_CASE(debugNormalXmlMultiple);
427429

428430
TEST_CASE(ignorepaths1);
429431
TEST_CASE(ignorepaths2);
@@ -2926,6 +2928,20 @@ class TestCmdlineParser : public TestFixture {
29262928
ASSERT_EQUALS(true, settings->debugClangOutput);
29272929
}
29282930

2931+
void debugXmlMultiple() {
2932+
REDIRECT;
2933+
const char * const argv[] = {"cppcheck", "--debug", "--xml", "1.cpp", "2.cpp"};
2934+
ASSERT_EQUALS_ENUM(CmdLineParser::Result::Fail, parser->parseFromArgs(5, argv));
2935+
ASSERT_EQUALS("cppcheck: error: printing debug output in XML format does not support multiple input files.\n", logger->str());
2936+
}
2937+
2938+
void debugNormalXmlMultiple() {
2939+
REDIRECT;
2940+
const char * const argv[] = {"cppcheck", "--debug-normal", "--xml", "1.cpp", "2.cpp"};
2941+
ASSERT_EQUALS_ENUM(CmdLineParser::Result::Fail, parser->parseFromArgs(5, argv));
2942+
ASSERT_EQUALS("cppcheck: error: printing debug output in XML format does not support multiple input files.\n", logger->str());
2943+
}
2944+
29292945
void ignorepaths1() {
29302946
REDIRECT;
29312947
const char * const argv[] = {"cppcheck", "-isrc", "file.cpp"};

0 commit comments

Comments
 (0)