Add test for usage checks via unset

This commit is contained in:
Ben Boeckel 2010-09-16 13:51:51 -04:00
parent a8e97f8a08
commit aefc91dd37
2 changed files with 23 additions and 0 deletions

View File

@ -1074,6 +1074,21 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleGeneratorTest")
ENDIF(APPLE AND CTEST_TEST_CPACK)
ADD_TEST(WarnUnusedUnusedViaUnset ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/VariableUnusedViaUnset"
"${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset"
--build-generator ${CMAKE_TEST_GENERATOR}
--build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
--build-noclean
--build-project WarnUnusedUnusedViaUnset
--build-options "--warn-unused-vars")
SET_TESTS_PROPERTIES(WarnUnusedUnusedViaUnset PROPERTIES
PASS_REGULAR_EXPRESSION ":7: warning: \\(unsetting\\) unused variable 'UNUSED_VARIABLE'")
SET_TESTS_PROPERTIES(WarnUnusedUnusedViaUnset PROPERTIES
FAIL_REGULAR_EXPRESSION ":5: warning: \\(unsetting\\) unused variable 'UNUSED_VARIABLE'")
LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset")
ADD_TEST(WarnUnusedCliUnused ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/VariableUsage"

View File

@ -0,0 +1,8 @@
# NOTE: Changing lines in here changes the test results since the first
# instance shouldn't warn, but the second should and they have the same message
# A warning should NOT ne issued for this line:
set(UNUSED_VARIABLE)
# Warning should occur here:
set(UNUSED_VARIABLE)
message(STATUS "${UNUSED_VARIABLE}")