summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2017-08-28 22:25:13 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2017-09-13 21:44:49 (GMT)
commit3bbe95f58a8fb83e56ca9023ef01b9e70b391b05 (patch)
tree786b5d6a10a78bff00f6daee00271bdfac3e570f /Tests
parent3ea87bce69d1b6120b227fed3838f1bc9ab45db1 (diff)
downloadCMake-3bbe95f58a8fb83e56ca9023ef01b9e70b391b05.zip
CMake-3bbe95f58a8fb83e56ca9023ef01b9e70b391b05.tar.gz
CMake-3bbe95f58a8fb83e56ca9023ef01b9e70b391b05.tar.bz2
Clean up iwyu code to not be one big if statement.
This commit changes the internal -E__run_iwyu to be -E__run_co_compile. This is used for co-compile commands. These are tools that want to mirror the compiler. For each compiler invocation the tool will be invoked first. This started as a way to implement include what you use (iwyu), but has expanded to include cpplint, cppcheck and others. Likely there will be more in the future as well. This commit implements each one in its own function and provides a way to add additional ones in the future with less work.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/CommandLine/E___run_co_compile-bad-iwyu-result.txt (renamed from Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-result.txt)0
-rw-r--r--Tests/RunCMake/CommandLine/E___run_co_compile-bad-iwyu-stderr.txt (renamed from Tests/RunCMake/CommandLine/E___run_iwyu-bad-iwyu-stderr.txt)0
-rw-r--r--Tests/RunCMake/CommandLine/E___run_co_compile-no----result.txt (renamed from Tests/RunCMake/CommandLine/E___run_iwyu-no-cc-result.txt)0
-rw-r--r--Tests/RunCMake/CommandLine/E___run_co_compile-no----stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E___run_co_compile-no-cc-result.txt (renamed from Tests/RunCMake/CommandLine/E___run_iwyu-no----result.txt)0
-rw-r--r--Tests/RunCMake/CommandLine/E___run_co_compile-no-cc-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E___run_co_compile-no-iwyu-result.txt (renamed from Tests/RunCMake/CommandLine/E___run_iwyu-bad-iwyu-result.txt)0
-rw-r--r--Tests/RunCMake/CommandLine/E___run_co_compile-no-iwyu-stderr.txt5
-rw-r--r--Tests/RunCMake/CommandLine/E___run_iwyu-no----stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E___run_iwyu-no-cc-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/RunCMakeTest.cmake8
-rw-r--r--Tests/RunCMake/Cppcheck/C-bad-Build-result.txt1
-rw-r--r--Tests/RunCMake/Cppcheck/C-bad-Build-stdout.txt2
-rw-r--r--Tests/RunCMake/Cppcheck/C-bad.cmake3
-rw-r--r--Tests/RunCMake/Cppcheck/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/pseudo_cppcheck.c13
17 files changed, 30 insertions, 8 deletions
diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-result.txt b/Tests/RunCMake/CommandLine/E___run_co_compile-bad-iwyu-result.txt
index d00491f..d00491f 100644
--- a/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-result.txt
+++ b/Tests/RunCMake/CommandLine/E___run_co_compile-bad-iwyu-result.txt
diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-bad-iwyu-stderr.txt b/Tests/RunCMake/CommandLine/E___run_co_compile-bad-iwyu-stderr.txt
index 338f7c4..338f7c4 100644
--- a/Tests/RunCMake/CommandLine/E___run_iwyu-bad-iwyu-stderr.txt
+++ b/Tests/RunCMake/CommandLine/E___run_co_compile-bad-iwyu-stderr.txt
diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no-cc-result.txt b/Tests/RunCMake/CommandLine/E___run_co_compile-no----result.txt
index d00491f..d00491f 100644
--- a/Tests/RunCMake/CommandLine/E___run_iwyu-no-cc-result.txt
+++ b/Tests/RunCMake/CommandLine/E___run_co_compile-no----result.txt
diff --git a/Tests/RunCMake/CommandLine/E___run_co_compile-no----stderr.txt b/Tests/RunCMake/CommandLine/E___run_co_compile-no----stderr.txt
new file mode 100644
index 0000000..f0597d2
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E___run_co_compile-no----stderr.txt
@@ -0,0 +1 @@
+^__run_co_compile given unknown argument: command-does-not-exist$
diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no----result.txt b/Tests/RunCMake/CommandLine/E___run_co_compile-no-cc-result.txt
index d00491f..d00491f 100644
--- a/Tests/RunCMake/CommandLine/E___run_iwyu-no----result.txt
+++ b/Tests/RunCMake/CommandLine/E___run_co_compile-no-cc-result.txt
diff --git a/Tests/RunCMake/CommandLine/E___run_co_compile-no-cc-stderr.txt b/Tests/RunCMake/CommandLine/E___run_co_compile-no-cc-stderr.txt
new file mode 100644
index 0000000..bba846e
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E___run_co_compile-no-cc-stderr.txt
@@ -0,0 +1 @@
+^__run_co_compile missing compile command after --$
diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-bad-iwyu-result.txt b/Tests/RunCMake/CommandLine/E___run_co_compile-no-iwyu-result.txt
index d00491f..d00491f 100644
--- a/Tests/RunCMake/CommandLine/E___run_iwyu-bad-iwyu-result.txt
+++ b/Tests/RunCMake/CommandLine/E___run_co_compile-no-iwyu-result.txt
diff --git a/Tests/RunCMake/CommandLine/E___run_co_compile-no-iwyu-stderr.txt b/Tests/RunCMake/CommandLine/E___run_co_compile-no-iwyu-stderr.txt
new file mode 100644
index 0000000..ffa1da8
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E___run_co_compile-no-iwyu-stderr.txt
@@ -0,0 +1,5 @@
+^__run_co_compile missing command to run. Looking for one of the following:
+.*--cppcheck=
+.*--cpplint=
+.*--iwyu=
+.*--tidy=
diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no----stderr.txt b/Tests/RunCMake/CommandLine/E___run_iwyu-no----stderr.txt
deleted file mode 100644
index c251adf..0000000
--- a/Tests/RunCMake/CommandLine/E___run_iwyu-no----stderr.txt
+++ /dev/null
@@ -1 +0,0 @@
-^__run_iwyu given unknown argument: command-does-not-exist$
diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no-cc-stderr.txt b/Tests/RunCMake/CommandLine/E___run_iwyu-no-cc-stderr.txt
deleted file mode 100644
index 1998abb..0000000
--- a/Tests/RunCMake/CommandLine/E___run_iwyu-no-cc-stderr.txt
+++ /dev/null
@@ -1 +0,0 @@
-^__run_iwyu missing compile command after --$
diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt b/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt
deleted file mode 100644
index 9db95f8..0000000
--- a/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt
+++ /dev/null
@@ -1 +0,0 @@
-^__run_iwyu missing --cpplint=, --iwyu=, --lwyu=, --cppcheck= and/or --tidy=$
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index 6efcc12..55eac5e 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -21,10 +21,10 @@ run_cmake_command(E_touch_nocreate-no-arg ${CMAKE_COMMAND} -E touch_nocreate)
run_cmake_command(E_time ${CMAKE_COMMAND} -E time ${CMAKE_COMMAND} -E echo "hello world")
run_cmake_command(E_time-no-arg ${CMAKE_COMMAND} -E time)
-run_cmake_command(E___run_iwyu-no-iwyu ${CMAKE_COMMAND} -E __run_iwyu -- command-does-not-exist)
-run_cmake_command(E___run_iwyu-bad-iwyu ${CMAKE_COMMAND} -E __run_iwyu --iwyu=iwyu-does-not-exist -- command-does-not-exist)
-run_cmake_command(E___run_iwyu-no--- ${CMAKE_COMMAND} -E __run_iwyu --iwyu=iwyu-does-not-exist command-does-not-exist)
-run_cmake_command(E___run_iwyu-no-cc ${CMAKE_COMMAND} -E __run_iwyu --iwyu=iwyu-does-not-exist --)
+run_cmake_command(E___run_co_compile-no-iwyu ${CMAKE_COMMAND} -E __run_co_compile -- command-does-not-exist)
+run_cmake_command(E___run_co_compile-bad-iwyu ${CMAKE_COMMAND} -E __run_co_compile --iwyu=iwyu-does-not-exist -- command-does-not-exist)
+run_cmake_command(E___run_co_compile-no--- ${CMAKE_COMMAND} -E __run_co_compile --iwyu=iwyu-does-not-exist command-does-not-exist)
+run_cmake_command(E___run_co_compile-no-cc ${CMAKE_COMMAND} -E __run_co_compile --iwyu=iwyu-does-not-exist --)
run_cmake_command(G_no-arg ${CMAKE_COMMAND} -G)
run_cmake_command(G_bad-arg ${CMAKE_COMMAND} -G NoSuchGenerator)
diff --git a/Tests/RunCMake/Cppcheck/C-bad-Build-result.txt b/Tests/RunCMake/Cppcheck/C-bad-Build-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/C-bad-Build-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/Cppcheck/C-bad-Build-stdout.txt b/Tests/RunCMake/Cppcheck/C-bad-Build-stdout.txt
new file mode 100644
index 0000000..2370ce1
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/C-bad-Build-stdout.txt
@@ -0,0 +1,2 @@
+stdout from bad command line arg '-bad'
+stderr from bad command line arg '-bad'
diff --git a/Tests/RunCMake/Cppcheck/C-bad.cmake b/Tests/RunCMake/Cppcheck/C-bad.cmake
new file mode 100644
index 0000000..920e4b4
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/C-bad.cmake
@@ -0,0 +1,3 @@
+enable_language(C)
+set(CMAKE_C_CPPCHECK "${PSEUDO_CPPCHECK}" -bad)
+add_executable(main main.c)
diff --git a/Tests/RunCMake/Cppcheck/RunCMakeTest.cmake b/Tests/RunCMake/Cppcheck/RunCMakeTest.cmake
index ae14f8c..5fd4ead 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-bad)
if(NOT RunCMake_GENERATOR STREQUAL "Watcom WMake")
run_cppcheck(C-launch)
diff --git a/Tests/RunCMake/pseudo_cppcheck.c b/Tests/RunCMake/pseudo_cppcheck.c
index 32e6e28..8667e5e 100644
--- a/Tests/RunCMake/pseudo_cppcheck.c
+++ b/Tests/RunCMake/pseudo_cppcheck.c
@@ -1,7 +1,18 @@
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
-int main(void)
+int main(int argc, char* argv[])
{
+ int i;
+ 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;
+ }
+ }
fprintf(stderr,
"[/foo/bar.c:2]: (error) Array 'abc[10]' accessed at index 12,"
" which is out of bounds.\n");