diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2022-11-04 15:02:47 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2022-11-04 15:02:47 (GMT) |
commit | 01d83084062d2dd0c94ecdf9dee4d2bacaf83674 (patch) | |
tree | dc098db26ece7a96c0106bcae0b9b149e79944c0 /Utilities | |
parent | 182ef53d3d6779db09be196f5be245ffb5d57640 (diff) | |
download | CMake-01d83084062d2dd0c94ecdf9dee4d2bacaf83674.zip CMake-01d83084062d2dd0c94ecdf9dee4d2bacaf83674.tar.gz CMake-01d83084062d2dd0c94ecdf9dee4d2bacaf83674.tar.bz2 |
Tests: remove stderr from clang-tidy module tests
The stderr has the potential to count warnings from system header
files, which are very platform-specific and not reliable, and they
are simply a count of all the warnings that were emitted on stdout,
which we already have. Remove stderr and only look at stdout.
Diffstat (limited to 'Utilities')
-rw-r--r-- | Utilities/ClangTidyModule/Tests/RunClangTidy.cmake | 28 | ||||
-rw-r--r-- | Utilities/ClangTidyModule/Tests/cmake-use-cmstrlen-stderr.txt | 2 |
2 files changed, 12 insertions, 18 deletions
diff --git a/Utilities/ClangTidyModule/Tests/RunClangTidy.cmake b/Utilities/ClangTidyModule/Tests/RunClangTidy.cmake index 486d592..7fd7cdd 100644 --- a/Utilities/ClangTidyModule/Tests/RunClangTidy.cmake +++ b/Utilities/ClangTidyModule/Tests/RunClangTidy.cmake @@ -3,14 +3,12 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${CHECK_NAME}.clang-tidy") set(config_arg "--config-file=${CMAKE_CURRENT_LIST_DIR}/${CHECK_NAME}.clang-tidy") endif() -foreach(o out err) - if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${CHECK_NAME}-std${o}.txt") - file(READ "${CMAKE_CURRENT_LIST_DIR}/${CHECK_NAME}-std${o}.txt" expect_std${o}) - string(REGEX REPLACE "\n+$" "" expect_std${o} "${expect_std${o}}") - else() - set(expect_std${o} "") - endif() -endforeach() +if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${CHECK_NAME}-stdout.txt") + file(READ "${CMAKE_CURRENT_LIST_DIR}/${CHECK_NAME}-stdout.txt" expect_stdout) + string(REGEX REPLACE "\n+$" "" expect_stdout "${expect_stdout}") +else() + set(expect_stdout "") +endif() set(source_file "${RunClangTidy_BINARY_DIR}/${CHECK_NAME}.cxx") configure_file("${CMAKE_CURRENT_LIST_DIR}/${CHECK_NAME}.cxx" "${source_file}" COPYONLY) @@ -39,14 +37,12 @@ if(NOT result EQUAL 0) string(APPEND RunClangTidy_TEST_FAILED "Expected result: 0, actual result: ${result}\n") endif() -foreach(o out err) - string(REGEX REPLACE "\n+$" "" actual_std${o} "${actual_std${o}}") - if(NOT actual_std${o} STREQUAL expect_std${o}) - string(REPLACE "\n" "\n " expect_std${o}_formatted " ${expect_std${o}}") - string(REPLACE "\n" "\n " actual_std${o}_formatted " ${actual_std${o}}") - string(APPEND RunClangTidy_TEST_FAILED "Expected std${o}:\n${expect_std${o}_formatted}\nActual std${o}:\n${actual_std${o}_formatted}\n") - endif() -endforeach() +string(REGEX REPLACE "\n+$" "" actual_stdout "${actual_stdout}") +if(NOT actual_stdout STREQUAL expect_stdout) + string(REPLACE "\n" "\n " expect_stdout_formatted " ${expect_stdout}") + string(REPLACE "\n" "\n " actual_stdout_formatted " ${actual_stdout}") + string(APPEND RunClangTidy_TEST_FAILED "Expected stdout:\n${expect_stdout_formatted}\nActual stdout:\n${actual_stdout_formatted}\n") +endif() if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${CHECK_NAME}-fixit.cxx") set(expect_fixit_file "${CMAKE_CURRENT_LIST_DIR}/${CHECK_NAME}-fixit.cxx") diff --git a/Utilities/ClangTidyModule/Tests/cmake-use-cmstrlen-stderr.txt b/Utilities/ClangTidyModule/Tests/cmake-use-cmstrlen-stderr.txt deleted file mode 100644 index 9d9d2ed..0000000 --- a/Utilities/ClangTidyModule/Tests/cmake-use-cmstrlen-stderr.txt +++ /dev/null @@ -1,2 +0,0 @@ -4 warnings generated. -clang-tidy applied 4 of 4 suggested fixes. |