diff --git a/Makefile b/Makefile
index 956c7e030..ebb6cc345 100644
--- a/Makefile
+++ b/Makefile
@@ -94,8 +94,8 @@ cppcheck: $(LIBOBJ) $(CLIOBJ)
all: cppcheck testrunner
-testrunner: $(TESTOBJ) $(LIBOBJ) cli/threadexecutor.o cli/cmdlineparser.o
- $(CXX) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) cli/threadexecutor.o cli/cmdlineparser.o $(LDFLAGS)
+testrunner: $(TESTOBJ) $(LIBOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o
+ $(CXX) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o $(LDFLAGS)
test: all
./testrunner
diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp
index a87fcc365..a5dd7f3ee 100644
--- a/cli/cppcheckexecutor.cpp
+++ b/cli/cppcheckexecutor.cpp
@@ -70,7 +70,15 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
cppcheck->addFile(*iter);
}
- return true;
+ if(filenames.empty())
+ {
+ std::cout << "cppcheck: error: could not find or open any of the paths given." << std::endl;
+ return false;
+ }
+ else
+ {
+ return true;
+ }
}
int CppCheckExecutor::check(int argc, const char* const argv[])
diff --git a/test/test.vcproj b/test/test.vcproj
index f235d6fd8..ddde4713c 100755
--- a/test/test.vcproj
+++ b/test/test.vcproj
@@ -238,6 +238,10 @@
RelativePath="..\lib\cppcheck.cpp"
>
+
+
@@ -484,6 +488,10 @@
RelativePath="..\lib\cppcheck.h"
>
+
+
diff --git a/test/testcppcheck.cpp b/test/testcppcheck.cpp
index fec19ae85..f8a878cf4 100644
--- a/test/testcppcheck.cpp
+++ b/test/testcppcheck.cpp
@@ -22,6 +22,7 @@
#include "cppcheck.h"
+#include "cppcheckexecutor.h"
#include "testsuite.h"
#include "path.h"
@@ -55,6 +56,7 @@ private:
void run()
{
+ TEST_CASE(nonexistingpath);
TEST_CASE(linenumbers);
// TEST_CASE(linenumbers2);
@@ -342,6 +344,15 @@ private:
}
#endif
+ void nonexistingpath()
+ {
+ CppCheckExecutor exec;
+ char *argv[] = { "", "idontexist" };
+ int retval = exec.check(2, argv);
+
+ ASSERT_EQUALS(retval, EXIT_FAILURE);
+ }
+
void linenumbers()
{
const char filedata[] = "void f()\n"
diff --git a/tools/dmake.cpp b/tools/dmake.cpp
index 84a252b42..1ee466e05 100644
--- a/tools/dmake.cpp
+++ b/tools/dmake.cpp
@@ -221,8 +221,8 @@ int main(int argc, char **argv)
fout << "cppcheck:\t$(LIBOBJ)\t$(CLIOBJ)\n";
fout << "\t$(CXX) $(CXXFLAGS) -o cppcheck $(CLIOBJ) $(LIBOBJ) $(LDFLAGS)\n\n";
fout << "all:\tcppcheck\ttestrunner\n\n";
- fout << "testrunner:\t$(TESTOBJ)\t$(LIBOBJ)\tcli/threadexecutor.o\tcli/cmdlineparser.o\n";
- fout << "\t$(CXX) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) cli/threadexecutor.o cli/cmdlineparser.o $(LDFLAGS)\n\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 cli/cppcheckexecutor.o $(LDFLAGS)\n\n";
fout << "test:\tall\n";
fout << "\t./testrunner\n\n";
fout << "check:\tall\n";