diff options
author | Brad King <brad.king@kitware.com> | 2015-05-21 13:03:40 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2015-05-21 13:03:40 (GMT) |
commit | 03a65dab30a0ef34ec900126c03a01cc9da55f36 (patch) | |
tree | 184d1376213fdf132e22c5f083faa05d8531a1de /Tests | |
parent | 41d833e1e9decb422c019f16626fe61e38c03eec (diff) | |
parent | ada5ffce7bad40c56e5d0dd76b9a7b30c96a9e92 (diff) | |
download | CMake-03a65dab30a0ef34ec900126c03a01cc9da55f36.zip CMake-03a65dab30a0ef34ec900126c03a01cc9da55f36.tar.gz CMake-03a65dab30a0ef34ec900126c03a01cc9da55f36.tar.bz2 |
Merge topic 'run-include-what-you-use'
ada5ffce Add options to run include-what-you-use with the compiler
67fa3da9 cmake: Add internal -E mode to run include-what-you-use with the compiler
Diffstat (limited to 'Tests')
19 files changed, 63 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 16fb056..2100b55 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -241,3 +241,8 @@ if(CMAKE_OSX_ARCHITECTURES AND XCODE AND NOT "${XCODE_VERSION}" MATCHES "^[^12]" PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CFG_INTDIR}" ) endif() + +if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") + add_executable(pseudo_iwyu pseudo_iwyu.c) + add_RunCMake_test(IncludeWhatYouUse -DPSEUDO_IWYU=$<TARGET_FILE:pseudo_iwyu>) +endif() diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-bad-iwyu-result.txt b/Tests/RunCMake/CommandLine/E___run_iwyu-bad-iwyu-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E___run_iwyu-bad-iwyu-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-bad-iwyu-stderr.txt b/Tests/RunCMake/CommandLine/E___run_iwyu-bad-iwyu-stderr.txt new file mode 100644 index 0000000..338f7c4 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E___run_iwyu-bad-iwyu-stderr.txt @@ -0,0 +1,2 @@ +^Error running 'iwyu-does-not-exist': [^ +]+$ diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no----result.txt b/Tests/RunCMake/CommandLine/E___run_iwyu-no----result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E___run_iwyu-no----result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no----stderr.txt b/Tests/RunCMake/CommandLine/E___run_iwyu-no----stderr.txt new file mode 100644 index 0000000..c251adf --- /dev/null +++ b/Tests/RunCMake/CommandLine/E___run_iwyu-no----stderr.txt @@ -0,0 +1 @@ +^__run_iwyu given unknown argument: command-does-not-exist$ diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no-cc-result.txt b/Tests/RunCMake/CommandLine/E___run_iwyu-no-cc-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E___run_iwyu-no-cc-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no-cc-stderr.txt b/Tests/RunCMake/CommandLine/E___run_iwyu-no-cc-stderr.txt new file mode 100644 index 0000000..1998abb --- /dev/null +++ b/Tests/RunCMake/CommandLine/E___run_iwyu-no-cc-stderr.txt @@ -0,0 +1 @@ +^__run_iwyu missing compile command after --$ diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-result.txt b/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt b/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt new file mode 100644 index 0000000..0024097 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt @@ -0,0 +1 @@ +^__run_iwyu missing --iwyu=$ diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index 644e5ae..69beed9 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -12,6 +12,11 @@ run_cmake_command(E_echo_append ${CMAKE_COMMAND} -E echo_append) run_cmake_command(E_rename-no-arg ${CMAKE_COMMAND} -E rename) run_cmake_command(E_touch_nocreate-no-arg ${CMAKE_COMMAND} -E touch_nocreate) +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(G_no-arg ${CMAKE_COMMAND} -G) run_cmake_command(G_bad-arg ${CMAKE_COMMAND} -G NoSuchGenerator) run_cmake_command(P_no-arg ${CMAKE_COMMAND} -P) diff --git a/Tests/RunCMake/IncludeWhatYouUse/C-Build-stdout.txt b/Tests/RunCMake/IncludeWhatYouUse/C-Build-stdout.txt new file mode 100644 index 0000000..cb74677 --- /dev/null +++ b/Tests/RunCMake/IncludeWhatYouUse/C-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.cmake b/Tests/RunCMake/IncludeWhatYouUse/C.cmake new file mode 100644 index 0000000..f400e86 --- /dev/null +++ b/Tests/RunCMake/IncludeWhatYouUse/C.cmake @@ -0,0 +1,3 @@ +enable_language(C) +set(CMAKE_C_INCLUDE_WHAT_YOU_USE "${PSEUDO_IWYU}" -some -args) +add_executable(main main.c) diff --git a/Tests/RunCMake/IncludeWhatYouUse/CMakeLists.txt b/Tests/RunCMake/IncludeWhatYouUse/CMakeLists.txt new file mode 100644 index 0000000..18dfd26 --- /dev/null +++ b/Tests/RunCMake/IncludeWhatYouUse/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.2) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/IncludeWhatYouUse/CXX-Build-stdout.txt b/Tests/RunCMake/IncludeWhatYouUse/CXX-Build-stdout.txt new file mode 100644 index 0000000..cb74677 --- /dev/null +++ b/Tests/RunCMake/IncludeWhatYouUse/CXX-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.cmake b/Tests/RunCMake/IncludeWhatYouUse/CXX.cmake new file mode 100644 index 0000000..896930c --- /dev/null +++ b/Tests/RunCMake/IncludeWhatYouUse/CXX.cmake @@ -0,0 +1,3 @@ +enable_language(CXX) +set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "${PSEUDO_IWYU}" -some -args) +add_executable(main main.cxx) diff --git a/Tests/RunCMake/IncludeWhatYouUse/RunCMakeTest.cmake b/Tests/RunCMake/IncludeWhatYouUse/RunCMakeTest.cmake new file mode 100644 index 0000000..68c6bd7 --- /dev/null +++ b/Tests/RunCMake/IncludeWhatYouUse/RunCMakeTest.cmake @@ -0,0 +1,18 @@ +include(RunCMake) + +set(RunCMake_TEST_OPTIONS "-DPSEUDO_IWYU=${PSEUDO_IWYU}") + +function(run_iwyu 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_iwyu(C) +run_iwyu(CXX) diff --git a/Tests/RunCMake/IncludeWhatYouUse/main.c b/Tests/RunCMake/IncludeWhatYouUse/main.c new file mode 100644 index 0000000..78f2de1 --- /dev/null +++ b/Tests/RunCMake/IncludeWhatYouUse/main.c @@ -0,0 +1 @@ +int main(void) { return 0; } diff --git a/Tests/RunCMake/IncludeWhatYouUse/main.cxx b/Tests/RunCMake/IncludeWhatYouUse/main.cxx new file mode 100644 index 0000000..76e8197 --- /dev/null +++ b/Tests/RunCMake/IncludeWhatYouUse/main.cxx @@ -0,0 +1 @@ +int main() { return 0; } diff --git a/Tests/RunCMake/pseudo_iwyu.c b/Tests/RunCMake/pseudo_iwyu.c new file mode 100644 index 0000000..1e25de7 --- /dev/null +++ b/Tests/RunCMake/pseudo_iwyu.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(void) +{ + fprintf(stderr, "should add these lines:\n#include <...>\n"); + return 0; +} |