Merge pull request #43 from makulik/master
#3244 'Get include pathes from file'
This commit is contained in:
commit
a381581a8b
|
@ -63,6 +63,26 @@ static void AddFilesToList(const std::string& FileList, std::vector<std::string>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void AddInclPathsToList(const std::string& FileList, std::list<std::string>& PathNames)
|
||||||
|
{
|
||||||
|
// to keep things initially simple, if the file can't be opened, just be
|
||||||
|
// silent and move on
|
||||||
|
std::ifstream Files(FileList.c_str());
|
||||||
|
if (Files)
|
||||||
|
{
|
||||||
|
std::string PathName;
|
||||||
|
while (std::getline(Files, PathName)) // next line
|
||||||
|
{
|
||||||
|
if (!PathName.empty())
|
||||||
|
{
|
||||||
|
PathName = Path::fromNativeSeparators(PathName);
|
||||||
|
PathName = Path::removeQuotationMarks(PathName);
|
||||||
|
PathNames.push_back(PathName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CmdLineParser::CmdLineParser(Settings *settings)
|
CmdLineParser::CmdLineParser(Settings *settings)
|
||||||
: _settings(settings)
|
: _settings(settings)
|
||||||
, _showHelp(false)
|
, _showHelp(false)
|
||||||
|
@ -330,6 +350,11 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
|
||||||
|
|
||||||
_settings->_includePaths.push_back(path);
|
_settings->_includePaths.push_back(path);
|
||||||
}
|
}
|
||||||
|
else if (strncmp(argv[i], "--includes-file=", 16) == 0)
|
||||||
|
{
|
||||||
|
// open this file and read every input file (1 file name per line)
|
||||||
|
AddInclPathsToList(16 + argv[i], _settings->_includePaths);
|
||||||
|
}
|
||||||
|
|
||||||
// file list specified
|
// file list specified
|
||||||
else if (strncmp(argv[i], "--file-list=", 12) == 0) {
|
else if (strncmp(argv[i], "--file-list=", 12) == 0) {
|
||||||
|
|
|
@ -56,6 +56,7 @@ private:
|
||||||
TEST_CASE(includesbackslash);
|
TEST_CASE(includesbackslash);
|
||||||
TEST_CASE(includesnospace);
|
TEST_CASE(includesnospace);
|
||||||
TEST_CASE(includes2);
|
TEST_CASE(includes2);
|
||||||
|
TEST_CASE(includesFile);
|
||||||
TEST_CASE(enabledAll);
|
TEST_CASE(enabledAll);
|
||||||
TEST_CASE(enabledStyle);
|
TEST_CASE(enabledStyle);
|
||||||
TEST_CASE(enabledPerformance);
|
TEST_CASE(enabledPerformance);
|
||||||
|
@ -365,6 +366,16 @@ private:
|
||||||
ASSERT_EQUALS("framework/", settings._includePaths.front());
|
ASSERT_EQUALS("framework/", settings._includePaths.front());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void includesFile()
|
||||||
|
{
|
||||||
|
// TODO: Fails since cannot open the file
|
||||||
|
REDIRECT;
|
||||||
|
const char *argv[] = {"cppcheck", "--includes-file=inclpaths.txt", "file.cpp"};
|
||||||
|
Settings settings;
|
||||||
|
CmdLineParser parser(&settings);
|
||||||
|
TODO_ASSERT_EQUALS(true, false, parser.ParseFromArgs(3, argv));
|
||||||
|
}
|
||||||
|
|
||||||
void enabledAll() {
|
void enabledAll() {
|
||||||
REDIRECT;
|
REDIRECT;
|
||||||
const char *argv[] = {"cppcheck", "--enable=all", "file.cpp"};
|
const char *argv[] = {"cppcheck", "--enable=all", "file.cpp"};
|
||||||
|
|
Loading…
Reference in New Issue