Diagnostics: Fix tests

Apply necessary manual updates to tests to account for changes made by
the introduction of the new diagnostic system. These mainly take three
forms. First, expected output changes that were not caught by the
automated changes made by the previous commit. Second, deprecation
warnings from -Wno-dev which are remedied by replacing uses thereof with
the new -Wno-author form. Third, manipulations of diagnostic state via
the old variables, which are replaced with use of the `cmake_diagnostic`
command.

We have not yet implemented backwards compatibility for the deprecated
`CMAKE_{WARN,ERROR}_DEPRECATED` variables. Once that is done, some of
the tests in the third category will likely reappear in some form.
This commit is contained in:
Matthew Woehlke
2026-04-16 15:10:35 -04:00
parent b0f9852990
commit 025fb87237
18 changed files with 39 additions and 47 deletions
+1 -1
View File
@@ -2465,7 +2465,7 @@ if(BUILD_TESTING)
--build-options
"-DUNUSED_CLI_VARIABLE=Unused")
set_tests_properties(WarnUnusedCliUnused PROPERTIES
PASS_REGULAR_EXPRESSION "CMake Warning:.*Manually-specified variables were not used by the project:.* UNUSED_CLI_VARIABLE")
PASS_REGULAR_EXPRESSION "CMake Warning \\(unused-cli\\):.*Manually-specified variables were not used by the project:.* UNUSED_CLI_VARIABLE")
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused")
add_test(WarnUnusedCliUsed ${CMAKE_CTEST_COMMAND}
+1 -1
View File
@@ -25,6 +25,6 @@ if(NOT "${err}" MATCHES "CMake Warning at[^\n]*:\r?\n message-warning")
message(FATAL_ERROR "message(WARNING) did not appear properly")
endif()
if(NOT "${err}" MATCHES "CMake Warning \\(dev\\) at[^\n]*:\r?\n message-author")
if(NOT "${err}" MATCHES "CMake Warning \\(author\\) at[^\n]*:\r?\n message-author")
message(FATAL_ERROR "message(AUTHOR_WARNING) did not appear properly")
endif()
+3 -2
View File
@@ -435,9 +435,10 @@ if(EP_TEST_GIT)
set_property(TARGET ${proj} PROPERTY FOLDER "GIT")
set(proj TS1-GIT-all-GIT_SUBMODULES-via-CMP0097-OLD)
set(CMAKE_WARN_DEPRECATED FALSE) # we are testing CMP0097 OLD behavior
cmake_diagnostic(PUSH)
cmake_diagnostic(SET CMD_DEPRECATED IGNORE)
cmake_policy(SET CMP0097 OLD)
unset(CMAKE_WARN_DEPRECATED)
cmake_diagnostic(POP)
ExternalProject_Add(${proj}
GIT_REPOSITORY "${local_git_repo}"
GIT_SUBMODULES ""
@@ -1,4 +1,4 @@
^CMake Deprecation Error at [^
^CMake Error \(deprecated\) at [^
]*/Tests/RunCMake/CMakePresets/WarningsBase\.cmake:[0-9]+ \(message\):
Deprecation warning
Call Stack \(most recent call first\):
@@ -1,13 +1,13 @@
^CMake Error \(dev\) at [^
^CMake Error \(author\) at [^
]*/Tests/RunCMake/CMakePresets/WarningsBase\.cmake:[0-9]+ \(message\):
Dev warning
Call Stack \(most recent call first\):
[^
]*/Tests/RunCMake/CMakePresets/ErrorDev\.cmake:[0-9]+ \(include\)
CMakeLists\.txt:[0-9]+ \(include\)
This error is for project developers\. Use -Wno-error=dev to suppress it\.
This error is for project developers\. Use -Wno-error=author to suppress it\.
CMake Deprecation Error at [^
CMake Error \(deprecated\) at [^
]*/Tests/RunCMake/CMakePresets/WarningsBase\.cmake:[0-9]+ \(message\):
Deprecation warning
Call Stack \(most recent call first\):
@@ -1,4 +1,4 @@
CMake Warning:
CMake Warning \(unused-cli\):
Manually-specified variables were not used by the project:
RunCMake_GENERATOR
@@ -1,4 +1,4 @@
CMake Error:
CMake Error \(unused-cli\):
Manually-specified variables were not used by the project:
RunCMake_GENERATOR
@@ -16,7 +16,7 @@ Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)
CMake Warning:
CMake Warning \(unused-cli\):
Manually-specified variables were not used by the project:
RunCMake_GENERATOR
@@ -1,11 +1,11 @@
^CMake Warning \(author\) at [^
^CMake Warning \(uninitialized\) at [^
]*/Modules/[^/
]*:[0-9]+ \([a-zA-Z_][a-zA-Z0-9_]*\):
uninitialized variable '[^
]*'
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(project\)
This warning is for project developers\. Use -Wno-author to suppress it\..*
CMakeLists\.txt:[0-9]+ \(project\)(
This warning is for project developers\. Use -Wno-author to suppress it\.)?.*
CMake Warning \(author\) at [^
]*/Tests/RunCMake/CMakePresets/WarningsBase\.cmake:[0-9]+ \(message\):
Dev warning
@@ -24,11 +24,11 @@ Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)
CMake Warning \(author\) at [^
CMake Warning \(uninitialized\) at [^
]*/Tests/RunCMake/CMakePresets/WarningsBase\.cmake:[0-9]+ \(set\):
uninitialized variable 'UNINITIALIZED_VARIABLE'
Call Stack \(most recent call first\):
[^
]*/Tests/RunCMake/CMakePresets/WarningFlags\.cmake:[0-9]+ \(include\)
CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers\. Use -Wno-author to suppress it\.$
CMakeLists\.txt:[0-9]+ \(include\)(
This warning is for project developers\. Use -Wno-author to suppress it\.)?$
@@ -1,11 +1,11 @@
^CMake Error \(dev\) at Werror_author\.cmake:4 \(include\):
^CMake Error \(author\) at Werror_author\.cmake:4 \(include\):
include\(\) given empty file name \(ignored\)\.
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)
This error is for project developers\. Use -Wno-error=dev to suppress it\.
This error is for project developers\. Use -Wno-error=author to suppress it\.
CMake Error \(dev\) at Werror_author\.cmake:7 \(message\):
CMake Error \(author\) at Werror_author\.cmake:7 \(message\):
Some author warning
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)
This error is for project developers\. Use -Wno-error=dev to suppress it\.$
This error is for project developers\. Use -Wno-error=author to suppress it\.$
@@ -1,4 +1,4 @@
^CMake Deprecation Error at Werror_deprecated\.cmake:1 \(message\):
^CMake Error \(deprecated\) at Werror_deprecated\.cmake:1 \(message\):
Some deprecated warning
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)
@@ -1,23 +1,23 @@
CMake Warning \(author\) at Wuninitialized\.cmake:1 \(set\):
CMake Warning \(uninitialized\) at Wuninitialized\.cmake:1 \(set\):
uninitialized variable 'NEW_WARN_FROM_NORMAL_CMAKE_FILE_INSIDE_BRACES'
Call Stack \(most recent call first\):
CMakeLists\.txt:3 \(include\)
This warning is for project developers\. Use -Wno-author to suppress it\.
(This warning is for project developers\. Use -Wno-author to suppress it\.)?
CMake Warning \(author\) at Wuninitialized\.cmake:2 \(string\):
CMake Warning \(uninitialized\) at Wuninitialized\.cmake:2 \(string\):
uninitialized variable 'NEW_WARN_FROM_STRING_CONFIGURE_INSIDE_BRACES'
Call Stack \(most recent call first\):
CMakeLists\.txt:3 \(include\)
This warning is for project developers\. Use -Wno-author to suppress it\.
(This warning is for project developers\. Use -Wno-author to suppress it\.)?
CMake Warning \(author\) at Wuninitialized\.cmake:4 \(configure_file\):
CMake Warning \(uninitialized\) at Wuninitialized\.cmake:4 \(configure_file\):
uninitialized variable 'NEW_WARN_FROM_CONFIGURE_FILE_INSIDE_AT'
Call Stack \(most recent call first\):
CMakeLists\.txt:3 \(include\)
This warning is for project developers\. Use -Wno-author to suppress it\.
(This warning is for project developers\. Use -Wno-author to suppress it\.)?
CMake Warning \(author\) at Wuninitialized\.cmake:5 \(string\):
CMake Warning \(uninitialized\) at Wuninitialized\.cmake:5 \(string\):
uninitialized variable 'NEW_WARN_FROM_STRING_CONFIGURE_INSIDE_AT'
Call Stack \(most recent call first\):
CMakeLists\.txt:3 \(include\)
This warning is for project developers\. Use -Wno-author to suppress it\.$
CMakeLists\.txt:3 \(include\)(
This warning is for project developers\. Use -Wno-author to suppress it\.)?$
@@ -1,7 +1,7 @@
find_package(Qt4 REQUIRED)
set(CMAKE_WARN_DEPRECATED 1)
cmake_diagnostic(SET CMD_DEPRECATED WARN)
add_library(foo SHARED empty.cpp)
qt4_automoc(foo_moc_srcs empty.cpp)
@@ -1,7 +1,7 @@
find_package(Qt4 REQUIRED)
set(CMAKE_WARN_DEPRECATED 1)
cmake_diagnostic(SET CMD_DEPRECATED WARN)
add_library(foo SHARED empty.cpp)
qt4_use_modules(foo LINK_PRIVATE Core)
+1 -10
View File
@@ -7,17 +7,8 @@ run_cmake(ConfigureLog)
run_cmake(defaultmessage)
run_cmake(nomessage)
run_cmake(message-internal-warning)
# run_cmake(nomessage-internal-warning)
run_cmake(warnmessage)
# TODO: We currently do not have a way to change diagnostic state in a way that
# is visible to internally issued diagnostic. This will be remedied when we
# switch to the new methods for issuing diagnostics, but for a brief window,
# this test will only pass if author warnings are disabled by command-line
# option.
set(RunCMake_TEST_OPTIONS -Wno-author)
run_cmake(nomessage-internal-warning)
unset(RunCMake_TEST_OPTIONS)
run_cmake(warnmessage)
# Have to explicitly give the command for the working dir to be honored
set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY /)
@@ -1,4 +1,4 @@
^CMake Deprecation Error at errormessage_deprecated\.cmake:3 \(message\):
^CMake Error \(deprecated\) at errormessage_deprecated\.cmake:3 \(message\):
This is a deprecation error
Call Stack \(most recent call first\):
CMakeLists\.txt:3 \(include\)$
@@ -1,5 +1,5 @@
^CMake Error \(dev\) at errormessage_dev\.cmake:3 \(message\):
^CMake Error \(author\) at errormessage_dev\.cmake:3 \(message\):
This is a author error
Call Stack \(most recent call first\):
CMakeLists\.txt:3 \(include\)
This error is for project developers\. Use -Wno-error=dev to suppress it\.$
This error is for project developers\. Use -Wno-error=author to suppress it\.$
+1 -1
View File
@@ -1,6 +1,6 @@
# Prevent deprecated warnings from new UseSWIG module
set (CMAKE_WARN_DEPRECATED FALSE)
cmake_diagnostic(SET CMD_DEPRECATED IGNORE)
find_package(SWIG REQUIRED)
include(${SWIG_USE_FILE})