summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/pseudo_cppcheck.c
diff options
context:
space:
mode:
authorHarald Brinkmann <Harald.Brinkmann@detectomat.com>2018-10-09 06:18:29 (GMT)
committerBrad King <brad.king@kitware.com>2018-10-11 11:56:05 (GMT)
commit3b80cd77fb3e1d0ee6a77a590830e7dc620df1a5 (patch)
treec558af62c709189bd3714e346029dbcc42293c66 /Tests/RunCMake/pseudo_cppcheck.c
parent0ab5db035ed47182fb8551f9872045eeae1f9cec (diff)
downloadCMake-3b80cd77fb3e1d0ee6a77a590830e7dc620df1a5.zip
CMake-3b80cd77fb3e1d0ee6a77a590830e7dc620df1a5.tar.gz
CMake-3b80cd77fb3e1d0ee6a77a590830e7dc620df1a5.tar.bz2
Fail the build if cppcheck returns a non-zero exit code
This allows the build failure to be tuned with cppcheck's options --error-exitcode=<n> and --exitcode-suppressions=<file>.
Diffstat (limited to 'Tests/RunCMake/pseudo_cppcheck.c')
-rw-r--r--Tests/RunCMake/pseudo_cppcheck.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/Tests/RunCMake/pseudo_cppcheck.c b/Tests/RunCMake/pseudo_cppcheck.c
index 75f3cec..5b1531b 100644
--- a/Tests/RunCMake/pseudo_cppcheck.c
+++ b/Tests/RunCMake/pseudo_cppcheck.c
@@ -5,13 +5,16 @@
int main(int argc, char* argv[])
{
int i;
+ int result = 0;
for (i = 1; i < argc; ++i) {
- if (strcmp(argv[i], "-bad") == 0)
- if (strcmp(argv[i], "-bad") == 0) {
- fprintf(stdout, "stdout from bad command line arg '-bad'\n");
- fprintf(stderr, "stderr from bad command line arg '-bad'\n");
- return 1;
- }
+ if (strcmp(argv[i], "-bad") == 0) {
+ fprintf(stdout, "stdout from bad command line arg '-bad'\n");
+ fprintf(stderr, "stderr from bad command line arg '-bad'\n");
+ return 1;
+ } else if (strcmp(argv[i], "-error") == 0) {
+ // The real cppcheck allows to set the exitcode with --error-exitcode
+ result = 5;
+ }
}
fprintf(stderr,
"[/foo/bar.c:2]: (error) Array 'abc[10]' accessed at index 12,"
@@ -31,6 +34,6 @@ int main(int argc, char* argv[])
fprintf(stderr,
"[/foo/bar.c:2]: (information) cannot find all the include "
"files (use --check-config for details)\n");
- // we allow this to return 1 as we ignore it
- return 1;
+
+ return result;
}