summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorAsit Dhal <dhal.asitk@gmail.com>2020-12-13 02:58:25 (GMT)
committerAsit Dhal <dhal.asitk@gmail.com>2020-12-14 03:55:03 (GMT)
commit8851637e9fc1e2acbc953032cfdffd33a2548959 (patch)
tree72e8bb25bd56bbebbab537f3c4aa6f0f1db74f8d /Tests
parent4621ffb0285b32898fa7b8ddd8380d39c597642c (diff)
downloadCMake-8851637e9fc1e2acbc953032cfdffd33a2548959.zip
CMake-8851637e9fc1e2acbc953032cfdffd33a2548959.tar.gz
CMake-8851637e9fc1e2acbc953032cfdffd33a2548959.tar.bz2
cmake_policy: Implement test cases for cmake_policy VERSION
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/Policy/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/Policy/InvalidMaxVersion-result.txt1
-rw-r--r--Tests/RunCMake/Policy/InvalidMaxVersion-stderr.txt5
-rw-r--r--Tests/RunCMake/Policy/InvalidMaxVersion.cmake5
-rw-r--r--Tests/RunCMake/Policy/InvalidRangeMaxVersionNotGiven-result.txt0
-rw-r--r--Tests/RunCMake/Policy/InvalidRangeMaxVersionNotGiven-stderr.txt5
-rw-r--r--Tests/RunCMake/Policy/InvalidRangeMaxVersionNotGiven.cmake1
-rw-r--r--Tests/RunCMake/Policy/InvalidRangeMinVersionNotGiven-result.txt1
-rw-r--r--Tests/RunCMake/Policy/InvalidRangeMinVersionNotGiven-stderr.txt5
-rw-r--r--Tests/RunCMake/Policy/InvalidRangeMinVersionNotGiven.cmake1
-rw-r--r--Tests/RunCMake/Policy/InvalidVersion-result.txt0
-rw-r--r--Tests/RunCMake/Policy/InvalidVersion-stderr.txt5
-rw-r--r--Tests/RunCMake/Policy/InvalidVersion.cmake5
-rw-r--r--Tests/RunCMake/Policy/MinVersionLargerThanMax-result.txt1
-rw-r--r--Tests/RunCMake/Policy/MinVersionLargerThanMax-stderr.txt4
-rw-r--r--Tests/RunCMake/Policy/MinVersionLargerThanMax.cmake1
-rw-r--r--Tests/RunCMake/Policy/RunCMakeTest.cmake19
-rw-r--r--Tests/RunCMake/Policy/TooManyVersionsGiven-result.txt1
-rw-r--r--Tests/RunCMake/Policy/TooManyVersionsGiven-stderr.txt4
-rw-r--r--Tests/RunCMake/Policy/TooManyVersionsGiven.cmake1
-rw-r--r--Tests/RunCMake/Policy/VersionLowerThan2_4-result.txt1
-rw-r--r--Tests/RunCMake/Policy/VersionLowerThan2_4-stderr.txt6
-rw-r--r--Tests/RunCMake/Policy/VersionLowerThan2_4.cmake1
-rw-r--r--Tests/RunCMake/Policy/VersionNotGiven-result.txt1
-rw-r--r--Tests/RunCMake/Policy/VersionNotGiven-stderr.txt4
-rw-r--r--Tests/RunCMake/Policy/VersionNotGiven.cmake1
-rw-r--r--Tests/RunCMake/Policy/VeryHighVersion-result.txt1
-rw-r--r--Tests/RunCMake/Policy/VeryHighVersion-stderr.txt7
-rw-r--r--Tests/RunCMake/Policy/VeryHighVersion.cmake1
30 files changed, 92 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 0cab867..fdd842c 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -288,6 +288,7 @@ add_RunCMake_test(ToolchainFile)
add_RunCMake_test(find_dependency)
add_RunCMake_test(CompileDefinitions)
add_RunCMake_test(CompileFeatures)
+add_RunCMake_test(Policy)
add_RunCMake_test(PolicyScope)
add_RunCMake_test(WriteBasicConfigVersionFile)
add_RunCMake_test(WriteCompilerDetectionHeader)
diff --git a/Tests/RunCMake/Policy/CMakeLists.txt b/Tests/RunCMake/Policy/CMakeLists.txt
new file mode 100644
index 0000000..667561e
--- /dev/null
+++ b/Tests/RunCMake/Policy/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.8.12)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE)
diff --git a/Tests/RunCMake/Policy/InvalidMaxVersion-result.txt b/Tests/RunCMake/Policy/InvalidMaxVersion-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/Policy/InvalidMaxVersion-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Policy/InvalidMaxVersion-stderr.txt b/Tests/RunCMake/Policy/InvalidMaxVersion-stderr.txt
new file mode 100644
index 0000000..25d22f5
--- /dev/null
+++ b/Tests/RunCMake/Policy/InvalidMaxVersion-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at InvalidMaxVersion.cmake:[0-9]+ \(cmake_policy\):
+ Invalid policy max version value "[A-Za-z0-9]+.[A-Za-z0-9]*.[A-Za-z0-9]*.[A-Za-z0-9]*"\. A numeric
+ major.minor\[\.patch\[\.tweak\]\] must be given\.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/Policy/InvalidMaxVersion.cmake b/Tests/RunCMake/Policy/InvalidMaxVersion.cmake
new file mode 100644
index 0000000..be3270f
--- /dev/null
+++ b/Tests/RunCMake/Policy/InvalidMaxVersion.cmake
@@ -0,0 +1,5 @@
+if(NOT version)
+ message(SEND_ERROR "Vesrion string is empty: ${version}")
+endif()
+
+cmake_policy(VERSION 3.1...${version})
diff --git a/Tests/RunCMake/Policy/InvalidRangeMaxVersionNotGiven-result.txt b/Tests/RunCMake/Policy/InvalidRangeMaxVersionNotGiven-result.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/Policy/InvalidRangeMaxVersionNotGiven-result.txt
diff --git a/Tests/RunCMake/Policy/InvalidRangeMaxVersionNotGiven-stderr.txt b/Tests/RunCMake/Policy/InvalidRangeMaxVersionNotGiven-stderr.txt
new file mode 100644
index 0000000..a48feb3
--- /dev/null
+++ b/Tests/RunCMake/Policy/InvalidRangeMaxVersionNotGiven-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at InvalidRangeMaxVersionNotGiven.cmake:[0-9]+ \(cmake_policy\):
+ cmake_policy VERSION "3.15..." does not have a version on both sides of
+ "...".
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/Policy/InvalidRangeMaxVersionNotGiven.cmake b/Tests/RunCMake/Policy/InvalidRangeMaxVersionNotGiven.cmake
new file mode 100644
index 0000000..e55803c
--- /dev/null
+++ b/Tests/RunCMake/Policy/InvalidRangeMaxVersionNotGiven.cmake
@@ -0,0 +1 @@
+cmake_policy(VERSION 3.15...)
diff --git a/Tests/RunCMake/Policy/InvalidRangeMinVersionNotGiven-result.txt b/Tests/RunCMake/Policy/InvalidRangeMinVersionNotGiven-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/Policy/InvalidRangeMinVersionNotGiven-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Policy/InvalidRangeMinVersionNotGiven-stderr.txt b/Tests/RunCMake/Policy/InvalidRangeMinVersionNotGiven-stderr.txt
new file mode 100644
index 0000000..84e9b88
--- /dev/null
+++ b/Tests/RunCMake/Policy/InvalidRangeMinVersionNotGiven-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at InvalidRangeMinVersionNotGiven.cmake:[0-9]+ \(cmake_policy\):
+ cmake_policy VERSION "...3.15" does not have a version on both sides of
+ "...".
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/Policy/InvalidRangeMinVersionNotGiven.cmake b/Tests/RunCMake/Policy/InvalidRangeMinVersionNotGiven.cmake
new file mode 100644
index 0000000..60e7e25
--- /dev/null
+++ b/Tests/RunCMake/Policy/InvalidRangeMinVersionNotGiven.cmake
@@ -0,0 +1 @@
+cmake_policy(VERSION ...3.15)
diff --git a/Tests/RunCMake/Policy/InvalidVersion-result.txt b/Tests/RunCMake/Policy/InvalidVersion-result.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/Policy/InvalidVersion-result.txt
diff --git a/Tests/RunCMake/Policy/InvalidVersion-stderr.txt b/Tests/RunCMake/Policy/InvalidVersion-stderr.txt
new file mode 100644
index 0000000..783f4ed
--- /dev/null
+++ b/Tests/RunCMake/Policy/InvalidVersion-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at InvalidVersion.cmake:[0-9]+ \(cmake_policy\):
+ Invalid policy version value "[A-Za-z0-9]+.[A-Za-z0-9]*.[A-Za-z0-9]*.[A-Za-z0-9]*"\. A numeric
+ major\.minor\[\.patch\[\.tweak\]\] must be given\.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/Policy/InvalidVersion.cmake b/Tests/RunCMake/Policy/InvalidVersion.cmake
new file mode 100644
index 0000000..b135ba6
--- /dev/null
+++ b/Tests/RunCMake/Policy/InvalidVersion.cmake
@@ -0,0 +1,5 @@
+if(NOT version)
+ message(SEND_ERROR "Vesrion string is empty: ${version}")
+endif()
+
+cmake_policy(VERSION ${version})
diff --git a/Tests/RunCMake/Policy/MinVersionLargerThanMax-result.txt b/Tests/RunCMake/Policy/MinVersionLargerThanMax-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/Policy/MinVersionLargerThanMax-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Policy/MinVersionLargerThanMax-stderr.txt b/Tests/RunCMake/Policy/MinVersionLargerThanMax-stderr.txt
new file mode 100644
index 0000000..0b0308f
--- /dev/null
+++ b/Tests/RunCMake/Policy/MinVersionLargerThanMax-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at MinVersionLargerThanMax.cmake:[0-9]+ \(cmake_policy\):
+ Policy VERSION range "3.12...3.8" specifies a larger minimum than maximum.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/Policy/MinVersionLargerThanMax.cmake b/Tests/RunCMake/Policy/MinVersionLargerThanMax.cmake
new file mode 100644
index 0000000..67d5f85
--- /dev/null
+++ b/Tests/RunCMake/Policy/MinVersionLargerThanMax.cmake
@@ -0,0 +1 @@
+cmake_policy(VERSION 3.12...3.8)
diff --git a/Tests/RunCMake/Policy/RunCMakeTest.cmake b/Tests/RunCMake/Policy/RunCMakeTest.cmake
new file mode 100644
index 0000000..74c7d63
--- /dev/null
+++ b/Tests/RunCMake/Policy/RunCMakeTest.cmake
@@ -0,0 +1,19 @@
+include(RunCMake)
+
+run_cmake(VersionNotGiven)
+run_cmake(TooManyVersionsGiven)
+run_cmake(InvalidRangeMinVersionNotGiven)
+run_cmake(InvalidRangeMaxVersionNotGiven)
+
+set(RunCMake_TEST_OPTIONS "-Dversion=three")
+run_cmake(InvalidVersion)
+run_cmake(InvalidMaxVersion)
+unset(RunCMake_TEST_OPTIONS)
+set(RunCMake_TEST_OPTIONS "-Dversion=3.one")
+run_cmake(InvalidVersion)
+run_cmake(InvalidMaxVersion)
+unset(RunCMake_TEST_OPTIONS)
+
+run_cmake(VersionLowerThan2_4)
+run_cmake(MinVersionLargerThanMax)
+run_cmake(VeryHighVersion)
diff --git a/Tests/RunCMake/Policy/TooManyVersionsGiven-result.txt b/Tests/RunCMake/Policy/TooManyVersionsGiven-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/Policy/TooManyVersionsGiven-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Policy/TooManyVersionsGiven-stderr.txt b/Tests/RunCMake/Policy/TooManyVersionsGiven-stderr.txt
new file mode 100644
index 0000000..7a4f8c7
--- /dev/null
+++ b/Tests/RunCMake/Policy/TooManyVersionsGiven-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at TooManyVersionsGiven.cmake:[0-9]+ \(cmake_policy\):
+ cmake_policy VERSION given too many arguments
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/Policy/TooManyVersionsGiven.cmake b/Tests/RunCMake/Policy/TooManyVersionsGiven.cmake
new file mode 100644
index 0000000..6c99af2
--- /dev/null
+++ b/Tests/RunCMake/Policy/TooManyVersionsGiven.cmake
@@ -0,0 +1 @@
+cmake_policy(VERSION 1 2 3)
diff --git a/Tests/RunCMake/Policy/VersionLowerThan2_4-result.txt b/Tests/RunCMake/Policy/VersionLowerThan2_4-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/Policy/VersionLowerThan2_4-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Policy/VersionLowerThan2_4-stderr.txt b/Tests/RunCMake/Policy/VersionLowerThan2_4-stderr.txt
new file mode 100644
index 0000000..3f19192
--- /dev/null
+++ b/Tests/RunCMake/Policy/VersionLowerThan2_4-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at VersionLowerThan2_4.cmake:[0-9]+ \(cmake_policy\):
+ Compatibility with CMake < 2.4 is not supported by CMake >= 3.0. For
+ compatibility with older versions please use any CMake 2.8.x release or
+ lower.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/Policy/VersionLowerThan2_4.cmake b/Tests/RunCMake/Policy/VersionLowerThan2_4.cmake
new file mode 100644
index 0000000..f1a4fd9
--- /dev/null
+++ b/Tests/RunCMake/Policy/VersionLowerThan2_4.cmake
@@ -0,0 +1 @@
+cmake_policy(VERSION 2.2)
diff --git a/Tests/RunCMake/Policy/VersionNotGiven-result.txt b/Tests/RunCMake/Policy/VersionNotGiven-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/Policy/VersionNotGiven-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Policy/VersionNotGiven-stderr.txt b/Tests/RunCMake/Policy/VersionNotGiven-stderr.txt
new file mode 100644
index 0000000..8eeb177
--- /dev/null
+++ b/Tests/RunCMake/Policy/VersionNotGiven-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at VersionNotGiven.cmake:[0-9]+ \(cmake_policy\):
+ cmake_policy VERSION not given an argument
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/Policy/VersionNotGiven.cmake b/Tests/RunCMake/Policy/VersionNotGiven.cmake
new file mode 100644
index 0000000..53b3d7f
--- /dev/null
+++ b/Tests/RunCMake/Policy/VersionNotGiven.cmake
@@ -0,0 +1 @@
+cmake_policy(VERSION)
diff --git a/Tests/RunCMake/Policy/VeryHighVersion-result.txt b/Tests/RunCMake/Policy/VeryHighVersion-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/Policy/VeryHighVersion-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Policy/VeryHighVersion-stderr.txt b/Tests/RunCMake/Policy/VeryHighVersion-stderr.txt
new file mode 100644
index 0000000..7cca91b
--- /dev/null
+++ b/Tests/RunCMake/Policy/VeryHighVersion-stderr.txt
@@ -0,0 +1,7 @@
+CMake Error at VeryHighVersion.cmake:[0-9]+ \(cmake_policy\):
+ An attempt was made to set the policy version of CMake to "99.1" which is
+ greater than this version of CMake. This is not allowed because the
+ greater version may have new policies not known to this CMake. You may
+ need a newer CMake version to build this project.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/Policy/VeryHighVersion.cmake b/Tests/RunCMake/Policy/VeryHighVersion.cmake
new file mode 100644
index 0000000..3d4af8c
--- /dev/null
+++ b/Tests/RunCMake/Policy/VeryHighVersion.cmake
@@ -0,0 +1 @@
+cmake_policy(VERSION 99.1)