summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorAshish Sadanandan <asadanan@qti.qualcomm.com>2023-04-01 04:41:48 (GMT)
committerBrad King <brad.king@kitware.com>2023-04-25 15:18:36 (GMT)
commitfcacc319d9e1a3ea89b33d58c495f32199f6ec91 (patch)
treead24130e5248add80048e78691658d618d585d2d /Tests
parente256e35daa79732a200883cef398fcd0f8227a3d (diff)
downloadCMake-fcacc319d9e1a3ea89b33d58c495f32199f6ec91.zip
CMake-fcacc319d9e1a3ea89b33d58c495f32199f6ec91.tar.gz
CMake-fcacc319d9e1a3ea89b33d58c495f32199f6ec91.tar.bz2
IWYU: Return error code if user enables error reporting
Previously CMake ignored the return code from iwyu because old versions of the tool would exit with an error code even when no header include violations were detected. The iwyu project has since changed this behavior, so the tool no longer returns an error code unless the user enables error reporting via command line arguments. Behavior seen with iwyu version 0.19 Source file with missing includes: - Case 1: iwyu arguments: - return code: 0 - output: <report of all missing includes> - Case 2: iwyu arguments: `-Xiwyu --error` - return code: 1 - output: <report of all missing includes> Source file with no missing includes: - Case 1: iwyu arguments: - return code: 0 - output: `(/path/to/file.cc has correct #includes/fwd-decls)` - Case 2: iwyu arguments: `-Xiwyu --error` - return code: 0 - output: `(/path/to/file.cc has correct #includes/fwd-decls)` Teach CMake to return the iwyu return code if the user has invoked the tool with any of these command line arguments included: - `--error[=N]` - `--error_always[=N]` Fixes: #24066
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/IncludeWhatYouUse/C-error-Build-result.txt1
-rw-r--r--Tests/RunCMake/IncludeWhatYouUse/C-error-Build-stdout.txt4
-rw-r--r--Tests/RunCMake/IncludeWhatYouUse/C-error.cmake3
-rw-r--r--Tests/RunCMake/IncludeWhatYouUse/CXX-error-Build-result.txt1
-rw-r--r--Tests/RunCMake/IncludeWhatYouUse/CXX-error-Build-stdout.txt4
-rw-r--r--Tests/RunCMake/IncludeWhatYouUse/CXX-error.cmake3
-rw-r--r--Tests/RunCMake/IncludeWhatYouUse/RunCMakeTest.cmake2
7 files changed, 18 insertions, 0 deletions
diff --git a/Tests/RunCMake/IncludeWhatYouUse/C-error-Build-result.txt b/Tests/RunCMake/IncludeWhatYouUse/C-error-Build-result.txt
new file mode 100644
index 0000000..d197c91
--- /dev/null
+++ b/Tests/RunCMake/IncludeWhatYouUse/C-error-Build-result.txt
@@ -0,0 +1 @@
+[^0]
diff --git a/Tests/RunCMake/IncludeWhatYouUse/C-error-Build-stdout.txt b/Tests/RunCMake/IncludeWhatYouUse/C-error-Build-stdout.txt
new file mode 100644
index 0000000..cb74677
--- /dev/null
+++ b/Tests/RunCMake/IncludeWhatYouUse/C-error-Build-stdout.txt
@@ -0,0 +1,4 @@
+Warning: include-what-you-use reported diagnostics:
+should add these lines:
+*
+#include <\.\.\.>
diff --git a/Tests/RunCMake/IncludeWhatYouUse/C-error.cmake b/Tests/RunCMake/IncludeWhatYouUse/C-error.cmake
new file mode 100644
index 0000000..d5230bb
--- /dev/null
+++ b/Tests/RunCMake/IncludeWhatYouUse/C-error.cmake
@@ -0,0 +1,3 @@
+enable_language(C)
+set(CMAKE_C_INCLUDE_WHAT_YOU_USE "${PSEUDO_IWYU}" -Xiwyu --error)
+add_executable(main main.c)
diff --git a/Tests/RunCMake/IncludeWhatYouUse/CXX-error-Build-result.txt b/Tests/RunCMake/IncludeWhatYouUse/CXX-error-Build-result.txt
new file mode 100644
index 0000000..d197c91
--- /dev/null
+++ b/Tests/RunCMake/IncludeWhatYouUse/CXX-error-Build-result.txt
@@ -0,0 +1 @@
+[^0]
diff --git a/Tests/RunCMake/IncludeWhatYouUse/CXX-error-Build-stdout.txt b/Tests/RunCMake/IncludeWhatYouUse/CXX-error-Build-stdout.txt
new file mode 100644
index 0000000..cb74677
--- /dev/null
+++ b/Tests/RunCMake/IncludeWhatYouUse/CXX-error-Build-stdout.txt
@@ -0,0 +1,4 @@
+Warning: include-what-you-use reported diagnostics:
+should add these lines:
+*
+#include <\.\.\.>
diff --git a/Tests/RunCMake/IncludeWhatYouUse/CXX-error.cmake b/Tests/RunCMake/IncludeWhatYouUse/CXX-error.cmake
new file mode 100644
index 0000000..1d10a55
--- /dev/null
+++ b/Tests/RunCMake/IncludeWhatYouUse/CXX-error.cmake
@@ -0,0 +1,3 @@
+enable_language(CXX)
+set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "$<1:${PSEUDO_IWYU}>" -Xiwyu --error)
+add_executable(main main.cxx)
diff --git a/Tests/RunCMake/IncludeWhatYouUse/RunCMakeTest.cmake b/Tests/RunCMake/IncludeWhatYouUse/RunCMakeTest.cmake
index 8f99eb1..8ec24be 100644
--- a/Tests/RunCMake/IncludeWhatYouUse/RunCMakeTest.cmake
+++ b/Tests/RunCMake/IncludeWhatYouUse/RunCMakeTest.cmake
@@ -16,6 +16,8 @@ endfunction()
run_iwyu(C)
run_iwyu(CXX)
+run_iwyu(C-error)
+run_iwyu(CXX-error)
if (NOT RunCMake_GENERATOR STREQUAL "Watcom WMake")
run_iwyu(C-launch)
run_iwyu(CXX-launch)