Browse Source

Add test for usage checks via unset

Ben Boeckel 15 years ago
parent
commit
aefc91dd37
2 changed files with 23 additions and 0 deletions
  1. 15 0
      Tests/CMakeLists.txt
  2. 8 0
      Tests/VariableUnusedViaUnset/CMakeLists.txt

+ 15 - 0
Tests/CMakeLists.txt

@@ -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"

+ 8 - 0
Tests/VariableUnusedViaUnset/CMakeLists.txt

@@ -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}")