diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2022-11-29 18:39:10 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2022-12-06 15:39:29 (GMT) |
commit | 232467eb1c0dab9156cd8c4af56aad3959cbee4b (patch) | |
tree | 2772b01850c143598e642282966401cb976dd421 /Tests/RunCMake/ClangTidy | |
parent | 7ea665b74da322e96dd3e7f90075143c2957728c (diff) | |
download | CMake-232467eb1c0dab9156cd8c4af56aad3959cbee4b.zip CMake-232467eb1c0dab9156cd8c4af56aad3959cbee4b.tar.gz CMake-232467eb1c0dab9156cd8c4af56aad3959cbee4b.tar.bz2 |
clang-tidy: add <LANG>_CLANG_TIDY_EXPORT_FIXES_DIR property
Fixes: #21362
Diffstat (limited to 'Tests/RunCMake/ClangTidy')
-rw-r--r-- | Tests/RunCMake/ClangTidy/ExportFixesDir-Build-check.cmake | 35 | ||||
-rw-r--r-- | Tests/RunCMake/ClangTidy/ExportFixesDir.cmake | 6 | ||||
-rw-r--r-- | Tests/RunCMake/ClangTidy/ExportFixesDir2-Build-check.cmake | 35 | ||||
-rw-r--r-- | Tests/RunCMake/ClangTidy/ExportFixesDir2-check.cmake | 35 | ||||
-rw-r--r-- | Tests/RunCMake/ClangTidy/ExportFixesDir2.cmake | 6 | ||||
-rw-r--r-- | Tests/RunCMake/ClangTidy/RunCMakeTest.cmake | 52 | ||||
-rw-r--r-- | Tests/RunCMake/ClangTidy/export_fixes_subdir/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/ClangTidy/extra.c | 3 |
8 files changed, 173 insertions, 0 deletions
diff --git a/Tests/RunCMake/ClangTidy/ExportFixesDir-Build-check.cmake b/Tests/RunCMake/ClangTidy/ExportFixesDir-Build-check.cmake new file mode 100644 index 0000000..97ec52b --- /dev/null +++ b/Tests/RunCMake/ClangTidy/ExportFixesDir-Build-check.cmake @@ -0,0 +1,35 @@ +if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + assert_any_file_exists( + "${RunCMake_TEST_BINARY_DIR}/clang-tidy/CMakeFiles/main.dir/Debug/main.c.o.yaml" + "${RunCMake_TEST_BINARY_DIR}/clang-tidy/CMakeFiles/main.dir/Debug/main.c.obj.yaml" + ) + assert_any_file_exists( + "${RunCMake_TEST_BINARY_DIR}/clang-tidy/CMakeFiles/main.dir/Debug/extra.c.o.yaml" + "${RunCMake_TEST_BINARY_DIR}/clang-tidy/CMakeFiles/main.dir/Debug/extra.c.obj.yaml" + ) + assert_any_file_exists( + "${RunCMake_TEST_BINARY_DIR}/export_fixes_subdir/clang-tidy/export_fixes_subdir/CMakeFiles/subdir.dir/Debug/__/main.c.o.yaml" + "${RunCMake_TEST_BINARY_DIR}/export_fixes_subdir/clang-tidy/export_fixes_subdir/CMakeFiles/subdir.dir/Debug/__/main.c.obj.yaml" + ) + assert_any_file_exists( + "${RunCMake_TEST_BINARY_DIR}/export_fixes_subdir/clang-tidy/export_fixes_subdir/CMakeFiles/subdir.dir/Debug/__/extra.c.o.yaml" + "${RunCMake_TEST_BINARY_DIR}/export_fixes_subdir/clang-tidy/export_fixes_subdir/CMakeFiles/subdir.dir/Debug/__/extra.c.obj.yaml" + ) +else() + assert_any_file_exists( + "${RunCMake_TEST_BINARY_DIR}/clang-tidy/CMakeFiles/main.dir/main.c.o.yaml" + "${RunCMake_TEST_BINARY_DIR}/clang-tidy/CMakeFiles/main.dir/main.c.obj.yaml" + ) + assert_any_file_exists( + "${RunCMake_TEST_BINARY_DIR}/clang-tidy/CMakeFiles/main.dir/extra.c.o.yaml" + "${RunCMake_TEST_BINARY_DIR}/clang-tidy/CMakeFiles/main.dir/extra.c.obj.yaml" + ) + assert_any_file_exists( + "${RunCMake_TEST_BINARY_DIR}/export_fixes_subdir/clang-tidy/export_fixes_subdir/CMakeFiles/subdir.dir/__/main.c.o.yaml" + "${RunCMake_TEST_BINARY_DIR}/export_fixes_subdir/clang-tidy/export_fixes_subdir/CMakeFiles/subdir.dir/__/main.c.obj.yaml" + ) + assert_any_file_exists( + "${RunCMake_TEST_BINARY_DIR}/export_fixes_subdir/clang-tidy/export_fixes_subdir/CMakeFiles/subdir.dir/__/extra.c.o.yaml" + "${RunCMake_TEST_BINARY_DIR}/export_fixes_subdir/clang-tidy/export_fixes_subdir/CMakeFiles/subdir.dir/__/extra.c.obj.yaml" + ) +endif() diff --git a/Tests/RunCMake/ClangTidy/ExportFixesDir.cmake b/Tests/RunCMake/ClangTidy/ExportFixesDir.cmake new file mode 100644 index 0000000..2b278da --- /dev/null +++ b/Tests/RunCMake/ClangTidy/ExportFixesDir.cmake @@ -0,0 +1,6 @@ +enable_language(C) +set(CMAKE_C_CLANG_TIDY "${PSEUDO_TIDY}" -some -args) +set(CMAKE_C_CLANG_TIDY_EXPORT_FIXES_DIR clang-tidy) +set(files ${CMAKE_CURRENT_SOURCE_DIR}/main.c ${CMAKE_CURRENT_SOURCE_DIR}/extra.c) +add_executable(main ${files}) +add_subdirectory(export_fixes_subdir) diff --git a/Tests/RunCMake/ClangTidy/ExportFixesDir2-Build-check.cmake b/Tests/RunCMake/ClangTidy/ExportFixesDir2-Build-check.cmake new file mode 100644 index 0000000..f65d33c --- /dev/null +++ b/Tests/RunCMake/ClangTidy/ExportFixesDir2-Build-check.cmake @@ -0,0 +1,35 @@ +if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + assert_any_file_exists( + "${RunCMake_TEST_BINARY_DIR}/clang-tidy/CMakeFiles/main.dir/Debug/main.c.o.yaml" + "${RunCMake_TEST_BINARY_DIR}/clang-tidy/CMakeFiles/main.dir/Debug/main.c.obj.yaml" + ) + assert_no_file_exists( + "${RunCMake_TEST_BINARY_DIR}/clang-tidy/CMakeFiles/main.dir/Debug/extra.c.o.yaml" + "${RunCMake_TEST_BINARY_DIR}/clang-tidy/CMakeFiles/main.dir/Debug/extra.c.obj.yaml" + ) + assert_any_file_exists( + "${RunCMake_TEST_BINARY_DIR}/export_fixes_subdir/clang-tidy/export_fixes_subdir/CMakeFiles/subdir.dir/Debug/__/main.c.o.yaml" + "${RunCMake_TEST_BINARY_DIR}/export_fixes_subdir/clang-tidy/export_fixes_subdir/CMakeFiles/subdir.dir/Debug/__/main.c.obj.yaml" + ) + assert_no_file_exists( + "${RunCMake_TEST_BINARY_DIR}/export_fixes_subdir/clang-tidy/export_fixes_subdir/CMakeFiles/subdir.dir/Debug/__/extra.c.o.yaml" + "${RunCMake_TEST_BINARY_DIR}/export_fixes_subdir/clang-tidy/export_fixes_subdir/CMakeFiles/subdir.dir/Debug/__/extra.c.obj.yaml" + ) +else() + assert_any_file_exists( + "${RunCMake_TEST_BINARY_DIR}/clang-tidy/CMakeFiles/main.dir/main.c.o.yaml" + "${RunCMake_TEST_BINARY_DIR}/clang-tidy/CMakeFiles/main.dir/main.c.obj.yaml" + ) + assert_no_file_exists( + "${RunCMake_TEST_BINARY_DIR}/clang-tidy/CMakeFiles/main.dir/extra.c.o.yaml" + "${RunCMake_TEST_BINARY_DIR}/clang-tidy/CMakeFiles/main.dir/extra.c.obj.yaml" + ) + assert_any_file_exists( + "${RunCMake_TEST_BINARY_DIR}/export_fixes_subdir/clang-tidy/export_fixes_subdir/CMakeFiles/subdir.dir/__/main.c.o.yaml" + "${RunCMake_TEST_BINARY_DIR}/export_fixes_subdir/clang-tidy/export_fixes_subdir/CMakeFiles/subdir.dir/__/main.c.obj.yaml" + ) + assert_no_file_exists( + "${RunCMake_TEST_BINARY_DIR}/export_fixes_subdir/clang-tidy/export_fixes_subdir/CMakeFiles/subdir.dir/__/extra.c.o.yaml" + "${RunCMake_TEST_BINARY_DIR}/export_fixes_subdir/clang-tidy/export_fixes_subdir/CMakeFiles/subdir.dir/__/extra.c.obj.yaml" + ) +endif() diff --git a/Tests/RunCMake/ClangTidy/ExportFixesDir2-check.cmake b/Tests/RunCMake/ClangTidy/ExportFixesDir2-check.cmake new file mode 100644 index 0000000..f65d33c --- /dev/null +++ b/Tests/RunCMake/ClangTidy/ExportFixesDir2-check.cmake @@ -0,0 +1,35 @@ +if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + assert_any_file_exists( + "${RunCMake_TEST_BINARY_DIR}/clang-tidy/CMakeFiles/main.dir/Debug/main.c.o.yaml" + "${RunCMake_TEST_BINARY_DIR}/clang-tidy/CMakeFiles/main.dir/Debug/main.c.obj.yaml" + ) + assert_no_file_exists( + "${RunCMake_TEST_BINARY_DIR}/clang-tidy/CMakeFiles/main.dir/Debug/extra.c.o.yaml" + "${RunCMake_TEST_BINARY_DIR}/clang-tidy/CMakeFiles/main.dir/Debug/extra.c.obj.yaml" + ) + assert_any_file_exists( + "${RunCMake_TEST_BINARY_DIR}/export_fixes_subdir/clang-tidy/export_fixes_subdir/CMakeFiles/subdir.dir/Debug/__/main.c.o.yaml" + "${RunCMake_TEST_BINARY_DIR}/export_fixes_subdir/clang-tidy/export_fixes_subdir/CMakeFiles/subdir.dir/Debug/__/main.c.obj.yaml" + ) + assert_no_file_exists( + "${RunCMake_TEST_BINARY_DIR}/export_fixes_subdir/clang-tidy/export_fixes_subdir/CMakeFiles/subdir.dir/Debug/__/extra.c.o.yaml" + "${RunCMake_TEST_BINARY_DIR}/export_fixes_subdir/clang-tidy/export_fixes_subdir/CMakeFiles/subdir.dir/Debug/__/extra.c.obj.yaml" + ) +else() + assert_any_file_exists( + "${RunCMake_TEST_BINARY_DIR}/clang-tidy/CMakeFiles/main.dir/main.c.o.yaml" + "${RunCMake_TEST_BINARY_DIR}/clang-tidy/CMakeFiles/main.dir/main.c.obj.yaml" + ) + assert_no_file_exists( + "${RunCMake_TEST_BINARY_DIR}/clang-tidy/CMakeFiles/main.dir/extra.c.o.yaml" + "${RunCMake_TEST_BINARY_DIR}/clang-tidy/CMakeFiles/main.dir/extra.c.obj.yaml" + ) + assert_any_file_exists( + "${RunCMake_TEST_BINARY_DIR}/export_fixes_subdir/clang-tidy/export_fixes_subdir/CMakeFiles/subdir.dir/__/main.c.o.yaml" + "${RunCMake_TEST_BINARY_DIR}/export_fixes_subdir/clang-tidy/export_fixes_subdir/CMakeFiles/subdir.dir/__/main.c.obj.yaml" + ) + assert_no_file_exists( + "${RunCMake_TEST_BINARY_DIR}/export_fixes_subdir/clang-tidy/export_fixes_subdir/CMakeFiles/subdir.dir/__/extra.c.o.yaml" + "${RunCMake_TEST_BINARY_DIR}/export_fixes_subdir/clang-tidy/export_fixes_subdir/CMakeFiles/subdir.dir/__/extra.c.obj.yaml" + ) +endif() diff --git a/Tests/RunCMake/ClangTidy/ExportFixesDir2.cmake b/Tests/RunCMake/ClangTidy/ExportFixesDir2.cmake new file mode 100644 index 0000000..c81c49a --- /dev/null +++ b/Tests/RunCMake/ClangTidy/ExportFixesDir2.cmake @@ -0,0 +1,6 @@ +enable_language(C) +set(CMAKE_C_CLANG_TIDY "${PSEUDO_TIDY}" -some -args) +set(CMAKE_C_CLANG_TIDY_EXPORT_FIXES_DIR clang-tidy) +set(files ${CMAKE_CURRENT_SOURCE_DIR}/main.c) +add_executable(main ${files}) +add_subdirectory(export_fixes_subdir) diff --git a/Tests/RunCMake/ClangTidy/RunCMakeTest.cmake b/Tests/RunCMake/ClangTidy/RunCMakeTest.cmake index 5e3fbc4..01dbb61 100644 --- a/Tests/RunCMake/ClangTidy/RunCMakeTest.cmake +++ b/Tests/RunCMake/ClangTidy/RunCMakeTest.cmake @@ -30,3 +30,55 @@ if (NOT RunCMake_GENERATOR STREQUAL "Watcom WMake") endif() run_tidy(C-bad) run_tidy(compdb) + +function(any_file_exists varname) + foreach(filename IN LISTS ARGN) + if(EXISTS "${filename}") + set("${varname}" 1 PARENT_SCOPE) + return() + endif() + endforeach() + set("${varname}" 0 PARENT_SCOPE) +endfunction() + +function(assert_any_file_exists) + any_file_exists(exists ${ARGN}) + if(NOT exists) + string(APPEND RunCMake_TEST_FAILED "Expected one of the following files to exist but they do not:\n") + foreach(filename IN LISTS ARGN) + string(APPEND RunCMake_TEST_FAILED " ${filename}\n") + endforeach() + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) + endif() +endfunction() + +function(assert_no_file_exists) + any_file_exists(exists ${ARGN}) + if(exists) + string(APPEND RunCMake_TEST_FAILED "Expected none of the following files to exist but one of them does:\n") + foreach(filename IN LISTS ARGN) + string(APPEND RunCMake_TEST_FAILED " ${filename}\n") + endforeach() + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) + endif() +endfunction() + +function(run_tidy_export_fixes) + # Use a single build tree for tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ExportFixesDir-build) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(ExportFixesDir) + + set(RunCMake_TEST_OUTPUT_MERGE 1) + run_cmake_command(ExportFixesDir-Build ${CMAKE_COMMAND} --build . --config Debug) + unset(RunCMake_TEST_OUTPUT_MERGE) + + run_cmake(ExportFixesDir2) + + set(RunCMake_TEST_OUTPUT_MERGE 1) + run_cmake_command(ExportFixesDir2-Build ${CMAKE_COMMAND} --build . --config Debug) + unset(RunCMake_TEST_OUTPUT_MERGE) +endfunction() +run_tidy_export_fixes() diff --git a/Tests/RunCMake/ClangTidy/export_fixes_subdir/CMakeLists.txt b/Tests/RunCMake/ClangTidy/export_fixes_subdir/CMakeLists.txt new file mode 100644 index 0000000..af2db88 --- /dev/null +++ b/Tests/RunCMake/ClangTidy/export_fixes_subdir/CMakeLists.txt @@ -0,0 +1 @@ +add_executable(subdir ${files}) diff --git a/Tests/RunCMake/ClangTidy/extra.c b/Tests/RunCMake/ClangTidy/extra.c new file mode 100644 index 0000000..d235550 --- /dev/null +++ b/Tests/RunCMake/ClangTidy/extra.c @@ -0,0 +1,3 @@ +void extra(void) +{ +} |