summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorDaniel Pfeifer <daniel@pfeifer-mail.de>2016-04-08 20:09:27 (GMT)
committerBrad King <brad.king@kitware.com>2016-04-13 13:56:10 (GMT)
commit5e62444cff5ead280a111c116a3fe810181379cf (patch)
tree83764d54d99f246c011defdd49e0ccfa658f8fd6 /Tests/RunCMake
parent9ac11bc25d6b9f5e7db786034f922d96613e6143 (diff)
downloadCMake-5e62444cff5ead280a111c116a3fe810181379cf.zip
CMake-5e62444cff5ead280a111c116a3fe810181379cf.tar.gz
CMake-5e62444cff5ead280a111c116a3fe810181379cf.tar.bz2
Add options to run clang-tidy with the compiler
Create a <LANG>_CLANG_TIDY target property (initialized by a CMAKE_<LANG>_CLANG_TIDY variable) to specify a clang-tidy command line to be run along with the compiler.
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/ClangTidy/C-Build-stdout.txt1
-rw-r--r--Tests/RunCMake/ClangTidy/C-launch-Build-stdout.txt1
-rw-r--r--Tests/RunCMake/ClangTidy/C-launch.cmake3
-rw-r--r--Tests/RunCMake/ClangTidy/C.cmake3
-rw-r--r--Tests/RunCMake/ClangTidy/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/ClangTidy/CXX-Build-stdout.txt1
-rw-r--r--Tests/RunCMake/ClangTidy/CXX-launch-Build-stdout.txt1
-rw-r--r--Tests/RunCMake/ClangTidy/CXX-launch.cmake3
-rw-r--r--Tests/RunCMake/ClangTidy/CXX.cmake3
-rw-r--r--Tests/RunCMake/ClangTidy/RunCMakeTest.cmake22
-rw-r--r--Tests/RunCMake/ClangTidy/main.c1
-rw-r--r--Tests/RunCMake/ClangTidy/main.cxx1
-rw-r--r--Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt2
-rw-r--r--Tests/RunCMake/pseudo_tidy.c16
15 files changed, 62 insertions, 1 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index d22c39c..02e14e6 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -301,7 +301,9 @@ if(CMAKE_OSX_ARCHITECTURES AND XCODE AND NOT "${XCODE_VERSION}" MATCHES "^[^12]"
endif()
if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja")
+ add_executable(pseudo_tidy pseudo_tidy.c)
add_executable(pseudo_iwyu pseudo_iwyu.c)
+ add_RunCMake_test(ClangTidy -DPSEUDO_TIDY=$<TARGET_FILE:pseudo_tidy>)
add_RunCMake_test(IncludeWhatYouUse -DPSEUDO_IWYU=$<TARGET_FILE:pseudo_iwyu>)
add_RunCMake_test(CompilerLauncher)
endif()
diff --git a/Tests/RunCMake/ClangTidy/C-Build-stdout.txt b/Tests/RunCMake/ClangTidy/C-Build-stdout.txt
new file mode 100644
index 0000000..a47a2de
--- /dev/null
+++ b/Tests/RunCMake/ClangTidy/C-Build-stdout.txt
@@ -0,0 +1 @@
+Tests[/\]RunCMake[/\]ClangTidy[/\]main\.c:0:0: warning: message \[checker\]
diff --git a/Tests/RunCMake/ClangTidy/C-launch-Build-stdout.txt b/Tests/RunCMake/ClangTidy/C-launch-Build-stdout.txt
new file mode 100644
index 0000000..a47a2de
--- /dev/null
+++ b/Tests/RunCMake/ClangTidy/C-launch-Build-stdout.txt
@@ -0,0 +1 @@
+Tests[/\]RunCMake[/\]ClangTidy[/\]main\.c:0:0: warning: message \[checker\]
diff --git a/Tests/RunCMake/ClangTidy/C-launch.cmake b/Tests/RunCMake/ClangTidy/C-launch.cmake
new file mode 100644
index 0000000..e66ca20
--- /dev/null
+++ b/Tests/RunCMake/ClangTidy/C-launch.cmake
@@ -0,0 +1,3 @@
+set(CTEST_USE_LAUNCHERS 1)
+include(CTestUseLaunchers)
+include(C.cmake)
diff --git a/Tests/RunCMake/ClangTidy/C.cmake b/Tests/RunCMake/ClangTidy/C.cmake
new file mode 100644
index 0000000..b8057b0
--- /dev/null
+++ b/Tests/RunCMake/ClangTidy/C.cmake
@@ -0,0 +1,3 @@
+enable_language(C)
+set(CMAKE_C_CLANG_TIDY "${PSEUDO_TIDY}" -some -args)
+add_executable(main main.c)
diff --git a/Tests/RunCMake/ClangTidy/CMakeLists.txt b/Tests/RunCMake/ClangTidy/CMakeLists.txt
new file mode 100644
index 0000000..93ee9df
--- /dev/null
+++ b/Tests/RunCMake/ClangTidy/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.5)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/ClangTidy/CXX-Build-stdout.txt b/Tests/RunCMake/ClangTidy/CXX-Build-stdout.txt
new file mode 100644
index 0000000..47e43af
--- /dev/null
+++ b/Tests/RunCMake/ClangTidy/CXX-Build-stdout.txt
@@ -0,0 +1 @@
+Tests[/\]RunCMake[/\]ClangTidy[/\]main\.cxx:0:0: warning: message \[checker\]
diff --git a/Tests/RunCMake/ClangTidy/CXX-launch-Build-stdout.txt b/Tests/RunCMake/ClangTidy/CXX-launch-Build-stdout.txt
new file mode 100644
index 0000000..47e43af
--- /dev/null
+++ b/Tests/RunCMake/ClangTidy/CXX-launch-Build-stdout.txt
@@ -0,0 +1 @@
+Tests[/\]RunCMake[/\]ClangTidy[/\]main\.cxx:0:0: warning: message \[checker\]
diff --git a/Tests/RunCMake/ClangTidy/CXX-launch.cmake b/Tests/RunCMake/ClangTidy/CXX-launch.cmake
new file mode 100644
index 0000000..3002c9d
--- /dev/null
+++ b/Tests/RunCMake/ClangTidy/CXX-launch.cmake
@@ -0,0 +1,3 @@
+set(CTEST_USE_LAUNCHERS 1)
+include(CTestUseLaunchers)
+include(CXX.cmake)
diff --git a/Tests/RunCMake/ClangTidy/CXX.cmake b/Tests/RunCMake/ClangTidy/CXX.cmake
new file mode 100644
index 0000000..2d22325
--- /dev/null
+++ b/Tests/RunCMake/ClangTidy/CXX.cmake
@@ -0,0 +1,3 @@
+enable_language(CXX)
+set(CMAKE_CXX_CLANG_TIDY "${PSEUDO_TIDY}" -some -args)
+add_executable(main main.cxx)
diff --git a/Tests/RunCMake/ClangTidy/RunCMakeTest.cmake b/Tests/RunCMake/ClangTidy/RunCMakeTest.cmake
new file mode 100644
index 0000000..27cd922
--- /dev/null
+++ b/Tests/RunCMake/ClangTidy/RunCMakeTest.cmake
@@ -0,0 +1,22 @@
+include(RunCMake)
+
+set(RunCMake_TEST_OPTIONS "-DPSEUDO_TIDY=${PSEUDO_TIDY}")
+
+function(run_tidy lang)
+ # Use a single build tree for tests without cleaning.
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${lang}-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ run_cmake(${lang})
+
+ set(RunCMake_TEST_OUTPUT_MERGE 1)
+ run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build .)
+endfunction()
+
+run_tidy(C)
+run_tidy(CXX)
+if (NOT RunCMake_GENERATOR STREQUAL "Watcom WMake")
+ run_tidy(C-launch)
+ run_tidy(CXX-launch)
+endif()
diff --git a/Tests/RunCMake/ClangTidy/main.c b/Tests/RunCMake/ClangTidy/main.c
new file mode 100644
index 0000000..78f2de1
--- /dev/null
+++ b/Tests/RunCMake/ClangTidy/main.c
@@ -0,0 +1 @@
+int main(void) { return 0; }
diff --git a/Tests/RunCMake/ClangTidy/main.cxx b/Tests/RunCMake/ClangTidy/main.cxx
new file mode 100644
index 0000000..76e8197
--- /dev/null
+++ b/Tests/RunCMake/ClangTidy/main.cxx
@@ -0,0 +1 @@
+int main() { return 0; }
diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt b/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt
index 0024097..0d0d899 100644
--- a/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt
+++ b/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt
@@ -1 +1 @@
-^__run_iwyu missing --iwyu=$
+^__run_iwyu missing --tidy= or --iwyu=$
diff --git a/Tests/RunCMake/pseudo_tidy.c b/Tests/RunCMake/pseudo_tidy.c
new file mode 100644
index 0000000..766c990
--- /dev/null
+++ b/Tests/RunCMake/pseudo_tidy.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+int main(int argc, char* argv[])
+{
+ int i;
+ for (i = 1; i < argc; ++i)
+ {
+ if (argv[i][0] != '-')
+ {
+ fprintf(stdout, "%s:0:0: warning: message [checker]\n", argv[i]);
+ break;
+ }
+ }
+ fprintf(stderr, "1 warning generated.\n");
+ return 0;
+}