diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index fcf01fc0ac2..7cc42b6a54c 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -933,8 +933,6 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string if (!hasValidConfig && currCfg == *configurations.rbegin()) { // If there is no valid configuration then report error.. - mExitCode = 1; - std::string file = Path::fromNativeSeparators(o.location.file()); if (mSettings.relativePaths) file = Path::getRelativePath(file, mSettings.basePaths); diff --git a/test/cli/test-other.py b/test/cli/test-other.py index f89c63b630f..fcdf7539295 100644 --- a/test/cli/test-other.py +++ b/test/cli/test-other.py @@ -75,8 +75,9 @@ def test_preprocessor_error(tmpdir): test_file = os.path.join(tmpdir, '10866.c') with open(test_file, 'wt') as f: f.write('#error test\nx=1;\n') - _, _, stderr = cppcheck([test_file]) + exitcode, _, stderr = cppcheck(['--error-exitcode=1', test_file]) assert 'preprocessorErrorDirective' in stderr + assert exitcode != 0 def test_invalid_library(tmpdir):