parent
8dee551cad
commit
3ba53c6b6a
|
@ -665,7 +665,6 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
ImportProject::Type projType = mSettings.project.import(projectFile, &mSettings);
|
||||
mSettings.project.projectType = projType;
|
||||
if (projType == ImportProject::Type::CPPCHECK_GUI) {
|
||||
mPathNames = mSettings.project.guiProject.pathNames;
|
||||
for (const std::string &lib : mSettings.project.guiProject.libraries)
|
||||
mSettings.libraries.emplace_back(lib);
|
||||
|
||||
|
@ -1032,12 +1031,20 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
return true;
|
||||
}
|
||||
|
||||
if (!mPathNames.empty() && mSettings.project.projectType != ImportProject::Type::NONE) {
|
||||
mLogger.printError("--project cannot be used in conjunction with source files.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Print error only if we have "real" command and expect files
|
||||
if (!mExitAfterPrint && mPathNames.empty() && mSettings.project.fileSettings.empty()) {
|
||||
if (!mExitAfterPrint && mPathNames.empty() && mSettings.project.guiProject.pathNames.empty() && mSettings.project.fileSettings.empty()) {
|
||||
mLogger.printError("no C or C++ source files found.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mSettings.project.guiProject.pathNames.empty())
|
||||
mPathNames = mSettings.project.guiProject.pathNames;
|
||||
|
||||
// Use paths _pathnames if no base paths for relative path output are given
|
||||
if (mSettings.basePaths.empty() && mSettings.relativePaths)
|
||||
mSettings.basePaths = mPathNames;
|
||||
|
|
|
@ -20,4 +20,5 @@ Other:
|
|||
- The undocumented and deprecated command-line options `--template <template>` and `--template-format <template>` has been removed. Please use `--template=` and `--template-format=` instead.
|
||||
- "--showtime=summary" will now show a single summary at the end instead of showing it after each file when using the thread execution (default on Windows)
|
||||
- added "--showtime=none" to disable any previously specified showtime report. "--showtime=" without parameter is no longer valid.
|
||||
- Multiple "--project" options are now prohibited. These would have overlapped each other and leads to unexpected behavior. Please use separate runs with a single "--project" option instead.
|
||||
- Multiple "--project" options are now prohibited. These would have overlapped each other and lead to unexpected behavior. Please use separate runs with a single "--project" option instead.
|
||||
- "--project" can also no longer be used in conjunction with additional source files.
|
||||
|
|
|
@ -283,8 +283,10 @@ private:
|
|||
TEST_CASE(templateMaxTime);
|
||||
TEST_CASE(project);
|
||||
TEST_CASE(projectMultiple);
|
||||
TEST_CASE(projectAndSource);
|
||||
TEST_CASE(projectEmpty);
|
||||
TEST_CASE(projectMissing);
|
||||
TEST_CASE(projectNoPaths);
|
||||
|
||||
TEST_CASE(ignorepaths1);
|
||||
TEST_CASE(ignorepaths2);
|
||||
|
@ -1952,10 +1954,18 @@ private:
|
|||
|
||||
void project() {
|
||||
REDIRECT;
|
||||
ScopedFile file("project.cppcheck", "<project></project>");
|
||||
const char * const argv[] = {"cppcheck", "--project=project.cppcheck", "file.cpp"};
|
||||
ASSERT(parser->parseFromArgs(3, argv));
|
||||
ScopedFile file("project.cppcheck",
|
||||
"<project>\n"
|
||||
"<paths>\n"
|
||||
"<dir name=\"dir\"/>\n"
|
||||
"</paths>\n"
|
||||
"</project>");
|
||||
const char * const argv[] = {"cppcheck", "--project=project.cppcheck"};
|
||||
ASSERT(parser->parseFromArgs(2, argv));
|
||||
ASSERT_EQUALS(static_cast<int>(ImportProject::Type::CPPCHECK_GUI), static_cast<int>(settings->project.projectType));
|
||||
ASSERT_EQUALS(1, parser->getPathNames().size());
|
||||
auto it = parser->getPathNames().cbegin();
|
||||
ASSERT_EQUALS("dir", *it);
|
||||
ASSERT_EQUALS("", logger->str());
|
||||
}
|
||||
|
||||
|
@ -1967,6 +1977,14 @@ private:
|
|||
ASSERT_EQUALS("cppcheck: error: multiple --project options are not supported.\n", logger->str());
|
||||
}
|
||||
|
||||
void projectAndSource() {
|
||||
REDIRECT;
|
||||
ScopedFile file("project.cppcheck", "<project></project>");
|
||||
const char * const argv[] = {"cppcheck", "--project=project.cppcheck", "file.cpp"};
|
||||
ASSERT(!parser->parseFromArgs(3, argv));
|
||||
ASSERT_EQUALS("cppcheck: error: --project cannot be used in conjunction with source files.\n", logger->str());
|
||||
}
|
||||
|
||||
void projectEmpty() {
|
||||
REDIRECT;
|
||||
const char * const argv[] = {"cppcheck", "--project=", "file.cpp"};
|
||||
|
@ -1981,6 +1999,13 @@ private:
|
|||
ASSERT_EQUALS("cppcheck: error: failed to open project 'project.cppcheck'. The file does not exist.\n", logger->str());
|
||||
}
|
||||
|
||||
void projectNoPaths() {
|
||||
ScopedFile file("project.cppcheck", "<project></project>");
|
||||
const char * const argv[] = {"cppcheck", "--project=project.cppcheck"};
|
||||
ASSERT(!parser->parseFromArgs(2, argv));
|
||||
ASSERT_EQUALS("cppcheck: error: no C or C++ source files found.\n", logger->str());
|
||||
}
|
||||
|
||||
void ignorepaths1() {
|
||||
REDIRECT;
|
||||
const char * const argv[] = {"cppcheck", "-isrc", "file.cpp"};
|
||||
|
|
Loading…
Reference in New Issue