summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2011-01-27 20:34:07 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2011-01-27 20:34:07 (GMT)
commit182eb7c7eff70bc5af6ca77adf15b59e87400f2f (patch)
treed4a2bd71cb9993e6d354e8913444baf0d3a9255f /Tests
parent451c5f61c26fc1db154605dc5e4b1c07d584b24b (diff)
parentdd2f81491e6e17681dd18882a8ccfa01fa32a3f7 (diff)
downloadCMake-182eb7c7eff70bc5af6ca77adf15b59e87400f2f.zip
CMake-182eb7c7eff70bc5af6ca77adf15b59e87400f2f.tar.gz
CMake-182eb7c7eff70bc5af6ca77adf15b59e87400f2f.tar.bz2
Merge topic 'dev/strict-mode'
dd2f814 Merge branch 'dev/add_test-working-directory' into dev/strict-mode 949d32c Unwatch manual variables upon removal in cmake-gui 3939032 Unwatch manual variables upon removal in ccmake 8354413 Add method to unwatch a manual variable 8ed3c85 Give a better message for unused variables 729db48 Fix ArgumentExpansion test expected results 89c2544 Checking for a definition is a usage 5625dee Don't output to stderr in the GUI ad25a96 Merge branch 'ImprovedDotSupport2' into dev/strict-mode c128abe Merge branch 'AddCMAKE_CURRENT_LIST_DIR' into dev/strict-mode 9bcaff0 Merge branch 'cmake-guiRememberAdvancedCheckbox' into dev/strict-mode 544d0c3 Fix expected output for WarnUninitialized test 4e3bea4 Update expected messages to new format 8e8c9e4 Don't check at destruction for usage 668e005 Use cmake::IssueMessage for warnings 88cd4c1 Use 'CMake Warning' versus 'warning' for CDash 3c3b98d Initialize the class before setting warn flags cf8b15a Ignore files under the CMakeFiles directory fd50f06 Don't check for unused vars at configure time 447a04c Don't warn during configure when doing everything b97ee21 Check for unused variables at the end of generate c18c977 When checking for variables, specify a reason 3f1121f Use a long int since Line is a long as well 2507f93 Change the failure case string to 'Unexpected' fe390a2 Add 'ArgumentExpansion' test 8dbb209 Wrong boolean value for CLI warnings d4ee998 Hard-code the --no-warn-unused-cli flag a267b99 Fix line lengths 82ed104 Flag that the directories have been set 5aa535b Add argument to arg parsing to not set directories 367e5c3 Revert "Revert "When calling CMake, set the args and the cache"" ab5d4e4 Revert "When calling CMake, set the args and the cache" 9b90040 When calling CMake, set the args and the cache fe56002 Fix long lines for KWStyle 5d30cfc Set a watch on variables added through the gui 33c63b1 Add a method to put a watch for variables 535253f Initialize the warning variables earlier cbb286c Fix the path detection to work for top-level 62be1f7 Initialize the usage stack earlier c6e7fab Factor out the checks for unused variables 5e41ba8 When using the API, check for Add vs. Remove dee1976 Fix typo in VariableUnusedViaUnset test f231ce5 Remove old false positive avoidance code a117e02 Revert "Add test for unused warnings at the end of scope" 2c82f2b Exempt CMAKE(CURRENT|PARENT)_LIST_FILE from usage 6d7d449 Ignore CLI warnings for ABI determination 7740a73 Only return local keys that are defined bef3aee Use the API so that warnings can be tracked 05cb0f4 Check for unused variables in the dtor 91c4c99 Add test for unused warnings at the end of scope ca90f67 Fix detection of unused variables when setting f7438ca Add test for unused detection via setting it 995cfb0 Don't warn if the variable wasn't defined aefc91d Add test for usage checks via unset a8e97f8 Remove VarRemoved code since it's been superceded 59463ef Rework CheckVariableForUnused usage f117423 Fix line lengths to be no more than 78 e49a935 Improve unused warning logic e01e40c Mark ARGC, ARGV*, and ARGN as used a17aff7 Ignore CMAKE_MATCH_* variables for usage 02a114d Add method to allow variables to be marked as used a0b0d23 CMAKE_DO_TRY_COMPILE is no longer used ae3eff3 Fix the path used for ignoring system warnings 056b441 Fix missing case for usage of a variable 980e048 Factor out checks for unused variables 83acb0a Remove now unused variables 3801463 Use built-ins for readability and maintainability 8b52015 Push the initialize and unused states when copying 439877f Be consistent with single and double quotes 4cf1706 Add documentation for check-system-vars b74777f Fix the spelling of the flag for warn-unused-vars b948120 Change logic of flag to turn off cli unused checks f047a17 Add test for uninitialized variables 75bda38 Add tests for unused command line variables 300fc15 Fix detection of system files d784e6a Run the unused variables check on the final pass 9efc057 VariableWatch is not available when bootstrapping 2e78224 Add a missing comma to the warning message 7499700 Add a flag to warn about system files fff9f6d Rename flags again and use variablewatch for cli 786e269 Add warn-unused to the Qt interface 636e6c4 Default to marking things as used 4ff0340 Rename find-unused to warn-unused d7999e9 Rename strict-mode to warn-uninitialized e141bc9 Detect unused variables d3e8eb5 Add flags to detect unused variables f332e14 Complete strict-mode checks for uninitialized vars 52f9637 Add method to get the local scope variables f794d58 Make --strict-mode option, and integrate with cmake-gui 48b5b85 Add a warning when variables are used uninitialized. cd626ea For macros make sure the FilePath points to a valid pointer in the args.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/ArgumentExpansion/CMakeLists.txt60
-rw-r--r--Tests/CMakeLists.txt84
-rw-r--r--Tests/VariableUnusedViaSet/CMakeLists.txt4
-rw-r--r--Tests/VariableUnusedViaUnset/CMakeLists.txt8
-rw-r--r--Tests/VariableUsage/CMakeLists.txt1
5 files changed, 157 insertions, 0 deletions
diff --git a/Tests/ArgumentExpansion/CMakeLists.txt b/Tests/ArgumentExpansion/CMakeLists.txt
new file mode 100644
index 0000000..a24636f
--- /dev/null
+++ b/Tests/ArgumentExpansion/CMakeLists.txt
@@ -0,0 +1,60 @@
+cmake_minimum_required(VERSION 2.8)
+
+project(ArgumentExpansion)
+
+function (argument_tester expected expected_len)
+ list(LENGTH ARGN argn_len)
+ list(LENGTH ${expected} expected_received_len)
+
+ if (NOT ${expected_received_len} EQUAL ${expected_len})
+ message(STATUS "Unexpected: Expanding expected values isn't working")
+ endif (NOT ${expected_received_len} EQUAL ${expected_len})
+
+ if (${argn_len} EQUAL ${expected_len})
+ set(i 0)
+ while (i LESS ${argn_len})
+ list(GET ARGN ${i} argn_value)
+ list(GET ${expected} ${i} expected_value)
+
+ if (NOT "${argn_value}" STREQUAL "${expected_value}")
+ message(STATUS "Unexpected: Argument ${i} doesn't match")
+ message(STATUS " Expected: ${expected_value}")
+ message(STATUS " Received: ${argn_value}")
+ endif ()
+
+ math(EXPR i "${i} + 1")
+ endwhile (i LESS ${argn_len})
+ else (${argn_len} EQUAL ${expected_len})
+ message(STATUS "Unexpected: Lengths of arguments don't match")
+ message(STATUS " Expected: ${expected_len}")
+ message(STATUS " Received: ${argn_len}")
+ endif (${argn_len} EQUAL ${expected_len})
+endfunction (argument_tester expected)
+
+set(empty_test)
+message(STATUS "Test: Empty arguments")
+argument_tester(empty_test 0 ${empty_test})
+
+set(single_arg_test
+ "single arg")
+message(STATUS "Test: Single argument")
+argument_tester(single_arg_test 1 ${single_arg_test})
+
+set(multiple_arg_test
+ "first arg"
+ "second arg")
+message(STATUS "Test: Multiple arguments")
+argument_tester(multiple_arg_test 2 ${multiple_arg_test})
+
+set(nested_list_arg_test
+ "${multiple_arg_test}"
+ "first arg"
+ "second arg")
+message(STATUS "Test: Nested list argument flattens")
+argument_tester(nested_list_arg_test 4 ${nested_list_arg_test})
+
+set(semicolon_arg_test
+ "pre\;post")
+set(semicolon_arg_test_flat "pre;post")
+message(STATUS "Test: Semicolon argument flattens")
+argument_tester(semicolon_arg_test_flat 2 ${semicolon_arg_test})
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index adef084..959413d 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -391,6 +391,19 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
)
LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustComDepend")
+ ADD_TEST(ArgumentExpansion ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/ArgumentExpansion"
+ "${CMake_BINARY_DIR}/Tests/ArgumentExpansion"
+ --build-generator ${CMAKE_TEST_GENERATOR}
+ --build-project ArgumentExpansion
+ --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
+ --build-exe-dir "${CMake_BINARY_DIR}/Tests/ArgumentExpansion/bin"
+ )
+ SET_TESTS_PROPERTIES(ArgumentExpansion PROPERTIES
+ FAIL_REGULAR_EXPRESSION "Unexpected: ")
+ LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ArgumentExpansion")
+
ADD_TEST(CustomCommand ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/CustomCommand"
@@ -1139,6 +1152,77 @@ ${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(WarnUnusedUnusedViaSet ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/VariableUnusedViaSet"
+ "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaSet"
+ --build-generator ${CMAKE_TEST_GENERATOR}
+ --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
+ --build-noclean
+ --build-project WarnUnusedUnusedViaSet
+ --build-options "--warn-unused-vars")
+ SET_TESTS_PROPERTIES(WarnUnusedUnusedViaSet PROPERTIES
+ PASS_REGULAR_EXPRESSION "unused variable \\(changing definition\\) 'UNUSED_VARIABLE'")
+ SET_TESTS_PROPERTIES(WarnUnusedUnusedViaSet PROPERTIES
+ FAIL_REGULAR_EXPRESSION "unused variable \\(unsetting\\) 'UNUSED_VARIABLE'")
+ LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaSet")
+
+ 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 "CMake Warning .*:7 \\(set\\):")
+ SET_TESTS_PROPERTIES(WarnUnusedUnusedViaUnset PROPERTIES
+ FAIL_REGULAR_EXPRESSION "CMake Warning .*:5 \\(set\\):")
+ LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset")
+
+ ADD_TEST(WarnUnusedCliUnused ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/VariableUsage"
+ "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused"
+ --build-generator ${CMAKE_TEST_GENERATOR}
+ --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
+ --build-noclean
+ --build-project WarnUnusedCliUnused
+ --build-options "-DUNUSED_CLI_VARIABLE=Unused")
+ SET_TESTS_PROPERTIES(WarnUnusedCliUnused PROPERTIES
+ PASS_REGULAR_EXPRESSION "CMake Warning: The variable, 'UNUSED_CLI_VARIABLE'")
+ LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused")
+
+ ADD_TEST(WarnUnusedCliUsed ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/VariableUsage"
+ "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUsed"
+ --build-generator ${CMAKE_TEST_GENERATOR}
+ --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
+ --build-noclean
+ --build-project WarnUnusedCliUsed
+ --build-options "-DUSED_VARIABLE=Usage proven")
+ SET_TESTS_PROPERTIES(WarnUnusedCliUsed PROPERTIES
+ PASS_REGULAR_EXPRESSION "Usage proven")
+ SET_TESTS_PROPERTIES(WarnUnusedCliUsed PROPERTIES
+ FAIL_REGULAR_EXPRESSION "CMake Warning: The variable, 'USED_VARIABLE'")
+ LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUsed")
+
+ ADD_TEST(WarnUninitialized ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/VariableUsage"
+ "${CMake_BINARY_DIR}/Tests/WarnUninitialized"
+ --build-generator ${CMAKE_TEST_GENERATOR}
+ --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
+ --build-noclean
+ --build-project WarnUninitialized
+ --build-options "--warn-uninitialized")
+ SET_TESTS_PROPERTIES(WarnUninitialized PROPERTIES
+ PASS_REGULAR_EXPRESSION "uninitialized variable 'USED_VARIABLE'")
+ LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUninitialized")
+
ADD_TEST(TestsWorkingDirectory ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/TestsWorkingDirectory"
diff --git a/Tests/VariableUnusedViaSet/CMakeLists.txt b/Tests/VariableUnusedViaSet/CMakeLists.txt
new file mode 100644
index 0000000..0123ab2
--- /dev/null
+++ b/Tests/VariableUnusedViaSet/CMakeLists.txt
@@ -0,0 +1,4 @@
+set(UNUSED_VARIABLE)
+# Warning should occur here
+set(UNUSED_VARIABLE "Usage")
+message(STATUS "${UNUSED_VARIABLE}")
diff --git a/Tests/VariableUnusedViaUnset/CMakeLists.txt b/Tests/VariableUnusedViaUnset/CMakeLists.txt
new file mode 100644
index 0000000..4b4031d
--- /dev/null
+++ b/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 be issued for this line:
+set(UNUSED_VARIABLE)
+# Warning should occur here:
+set(UNUSED_VARIABLE)
+message(STATUS "${UNUSED_VARIABLE}")
diff --git a/Tests/VariableUsage/CMakeLists.txt b/Tests/VariableUsage/CMakeLists.txt
new file mode 100644
index 0000000..4da1f56
--- /dev/null
+++ b/Tests/VariableUsage/CMakeLists.txt
@@ -0,0 +1 @@
+message(STATUS "${USED_VARIABLE}")