Fixed #2099 (Show an error if none of the given paths was found)
This commit is contained in:
parent
8bc12c204f
commit
91e66e74d0
4
Makefile
4
Makefile
|
@ -94,8 +94,8 @@ cppcheck: $(LIBOBJ) $(CLIOBJ)
|
||||||
|
|
||||||
all: cppcheck testrunner
|
all: cppcheck testrunner
|
||||||
|
|
||||||
testrunner: $(TESTOBJ) $(LIBOBJ) cli/threadexecutor.o cli/cmdlineparser.o
|
testrunner: $(TESTOBJ) $(LIBOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o
|
||||||
$(CXX) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) cli/threadexecutor.o cli/cmdlineparser.o $(LDFLAGS)
|
$(CXX) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o $(LDFLAGS)
|
||||||
|
|
||||||
test: all
|
test: all
|
||||||
./testrunner
|
./testrunner
|
||||||
|
|
|
@ -70,8 +70,16 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
|
||||||
cppcheck->addFile(*iter);
|
cppcheck->addFile(*iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(filenames.empty())
|
||||||
|
{
|
||||||
|
std::cout << "cppcheck: error: could not find or open any of the paths given." << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int CppCheckExecutor::check(int argc, const char* const argv[])
|
int CppCheckExecutor::check(int argc, const char* const argv[])
|
||||||
{
|
{
|
||||||
|
|
|
@ -238,6 +238,10 @@
|
||||||
RelativePath="..\lib\cppcheck.cpp"
|
RelativePath="..\lib\cppcheck.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\cli\cppcheckexecutor.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\lib\errorlogger.cpp"
|
RelativePath="..\lib\errorlogger.cpp"
|
||||||
>
|
>
|
||||||
|
@ -484,6 +488,10 @@
|
||||||
RelativePath="..\lib\cppcheck.h"
|
RelativePath="..\lib\cppcheck.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\cli\cppcheckexecutor.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\lib\errorlogger.h"
|
RelativePath="..\lib\errorlogger.h"
|
||||||
>
|
>
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include "cppcheck.h"
|
#include "cppcheck.h"
|
||||||
|
#include "cppcheckexecutor.h"
|
||||||
#include "testsuite.h"
|
#include "testsuite.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
|
||||||
|
@ -55,6 +56,7 @@ private:
|
||||||
|
|
||||||
void run()
|
void run()
|
||||||
{
|
{
|
||||||
|
TEST_CASE(nonexistingpath);
|
||||||
TEST_CASE(linenumbers);
|
TEST_CASE(linenumbers);
|
||||||
// TEST_CASE(linenumbers2);
|
// TEST_CASE(linenumbers2);
|
||||||
|
|
||||||
|
@ -342,6 +344,15 @@ private:
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void nonexistingpath()
|
||||||
|
{
|
||||||
|
CppCheckExecutor exec;
|
||||||
|
char *argv[] = { "", "idontexist" };
|
||||||
|
int retval = exec.check(2, argv);
|
||||||
|
|
||||||
|
ASSERT_EQUALS(retval, EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
void linenumbers()
|
void linenumbers()
|
||||||
{
|
{
|
||||||
const char filedata[] = "void f()\n"
|
const char filedata[] = "void f()\n"
|
||||||
|
|
|
@ -221,8 +221,8 @@ int main(int argc, char **argv)
|
||||||
fout << "cppcheck:\t$(LIBOBJ)\t$(CLIOBJ)\n";
|
fout << "cppcheck:\t$(LIBOBJ)\t$(CLIOBJ)\n";
|
||||||
fout << "\t$(CXX) $(CXXFLAGS) -o cppcheck $(CLIOBJ) $(LIBOBJ) $(LDFLAGS)\n\n";
|
fout << "\t$(CXX) $(CXXFLAGS) -o cppcheck $(CLIOBJ) $(LIBOBJ) $(LDFLAGS)\n\n";
|
||||||
fout << "all:\tcppcheck\ttestrunner\n\n";
|
fout << "all:\tcppcheck\ttestrunner\n\n";
|
||||||
fout << "testrunner:\t$(TESTOBJ)\t$(LIBOBJ)\tcli/threadexecutor.o\tcli/cmdlineparser.o\n";
|
fout << "testrunner:\t$(TESTOBJ)\t$(LIBOBJ)\tcli/threadexecutor.o\tcli/cmdlineparser.o\tcli/cppcheckexecutor.o\n";
|
||||||
fout << "\t$(CXX) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) cli/threadexecutor.o cli/cmdlineparser.o $(LDFLAGS)\n\n";
|
fout << "\t$(CXX) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o $(LDFLAGS)\n\n";
|
||||||
fout << "test:\tall\n";
|
fout << "test:\tall\n";
|
||||||
fout << "\t./testrunner\n\n";
|
fout << "\t./testrunner\n\n";
|
||||||
fout << "check:\tall\n";
|
fout << "check:\tall\n";
|
||||||
|
|
Loading…
Reference in New Issue