summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/Cppcheck/C-bad-Build-result.txt2
-rw-r--r--Tests/RunCMake/Cppcheck/C-error-Build-result.txt1
-rw-r--r--Tests/RunCMake/Cppcheck/C-error-Build-stdout.txt1
-rw-r--r--Tests/RunCMake/Cppcheck/C-error.cmake3
-rw-r--r--Tests/RunCMake/Cppcheck/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/pseudo_cppcheck.c19
6 files changed, 18 insertions, 9 deletions
diff --git a/Tests/RunCMake/Cppcheck/C-bad-Build-result.txt b/Tests/RunCMake/Cppcheck/C-bad-Build-result.txt
index 573541a..d197c91 100644
--- a/Tests/RunCMake/Cppcheck/C-bad-Build-result.txt
+++ b/Tests/RunCMake/Cppcheck/C-bad-Build-result.txt
@@ -1 +1 @@
-0
+[^0]
diff --git a/Tests/RunCMake/Cppcheck/C-error-Build-result.txt b/Tests/RunCMake/Cppcheck/C-error-Build-result.txt
new file mode 100644
index 0000000..d197c91
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/C-error-Build-result.txt
@@ -0,0 +1 @@
+[^0]
diff --git a/Tests/RunCMake/Cppcheck/C-error-Build-stdout.txt b/Tests/RunCMake/Cppcheck/C-error-Build-stdout.txt
new file mode 100644
index 0000000..4a24c0c
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/C-error-Build-stdout.txt
@@ -0,0 +1 @@
+.*Error: cppcheck reported failure.*error.*warning.*style.*performance.*information.*
diff --git a/Tests/RunCMake/Cppcheck/C-error.cmake b/Tests/RunCMake/Cppcheck/C-error.cmake
new file mode 100644
index 0000000..2254d75
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/C-error.cmake
@@ -0,0 +1,3 @@
+enable_language(C)
+set(CMAKE_C_CPPCHECK "${PSEUDO_CPPCHECK}" -error)
+add_executable(main main.c)
diff --git a/Tests/RunCMake/Cppcheck/RunCMakeTest.cmake b/Tests/RunCMake/Cppcheck/RunCMakeTest.cmake
index 5fd4ead..e395f36 100644
--- a/Tests/RunCMake/Cppcheck/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Cppcheck/RunCMakeTest.cmake
@@ -15,6 +15,7 @@ endfunction()
run_cppcheck(C)
run_cppcheck(CXX)
+run_cppcheck(C-error)
run_cppcheck(C-bad)
if(NOT RunCMake_GENERATOR STREQUAL "Watcom WMake")
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;
}