summaryrefslogtreecommitdiff
path: root/Tests/RunCMake/CMP0150/CMP0150-NEW-resolve.cmake
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2023-04-27 13:12:03 +0000
committerKitware Robot <kwrobot@kitware.com>2023-04-27 09:12:26 -0400
commit0ca98beb5747de97040227695732f660b7b91fc0 (patch)
treef97d62a34b926e8464bf1d60c8f969b059202211 /Tests/RunCMake/CMP0150/CMP0150-NEW-resolve.cmake
parent2fbcc81440343bdb1bca4e164fdefec98eaa1196 (diff)
parent550f63447d4c7d2db6ccbeaf1f6378aa6f7af4ed (diff)
downloadcmake-0ca98beb5747de97040227695732f660b7b91fc0.tar.gz
Merge topic 'ExternalProject-relative-git-urls'
550f63447d ExternalProject/FetchContent: Support relative remote URLs Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !7988
Diffstat (limited to 'Tests/RunCMake/CMP0150/CMP0150-NEW-resolve.cmake')
-rw-r--r--Tests/RunCMake/CMP0150/CMP0150-NEW-resolve.cmake107
1 files changed, 107 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMP0150/CMP0150-NEW-resolve.cmake b/Tests/RunCMake/CMP0150/CMP0150-NEW-resolve.cmake
new file mode 100644
index 0000000000..f43f3d5f7b
--- /dev/null
+++ b/Tests/RunCMake/CMP0150/CMP0150-NEW-resolve.cmake
@@ -0,0 +1,107 @@
+include(ExternalProject/shared_internal_commands)
+
+function(test_resolve parentUrl relativeUrl expectedResult)
+ _ep_resolve_relative_git_remote(result "${parentUrl}" "${relativeUrl}")
+ if(NOT result STREQUAL expectedResult)
+ message(SEND_ERROR "URL resolved to unexpected result:\n"
+ " Expected: ${expectedResult}\n"
+ " Actual : ${result}"
+ )
+ endif()
+endfunction()
+
+test_resolve(
+ "https://example.com/group/parent"
+ "../other"
+ "https://example.com/group/other"
+)
+test_resolve(
+ "https://example.com/group/parent"
+ "../../alt/other"
+ "https://example.com/alt/other"
+)
+
+test_resolve(
+ "git@example.com:group/parent"
+ "../other"
+ "git@example.com:group/other"
+)
+test_resolve(
+ "git@example.com:group/parent"
+ "../../alt/other"
+ "git@example.com:alt/other"
+)
+test_resolve(
+ "git@example.com:/group/parent"
+ "../other"
+ "git@example.com:/group/other"
+)
+test_resolve(
+ "git@example.com:/group/parent"
+ "../../alt/other"
+ "git@example.com:/alt/other"
+)
+test_resolve(
+ "git+ssh://git@example.com:group/parent"
+ "../other"
+ "git+ssh://git@example.com:group/other"
+)
+test_resolve(
+ "ssh://git@example.com:1234/group/parent"
+ "../../alt/other"
+ "ssh://git@example.com:1234/alt/other"
+)
+
+test_resolve(
+ "file:///group/parent"
+ "../other"
+ "file:///group/other"
+)
+test_resolve(
+ "file:///group/parent"
+ "../../alt/other"
+ "file:///alt/other"
+)
+test_resolve(
+ "file:///~/group/parent"
+ "../../other"
+ "file:///~/other"
+)
+test_resolve(
+ "/group/parent"
+ "../other"
+ "/group/other"
+)
+test_resolve(
+ "/group/parent"
+ "../../alt/other"
+ "/alt/other"
+)
+test_resolve(
+ "C:/group/parent"
+ "../other"
+ "C:/group/other"
+)
+test_resolve(
+ "C:/group/parent"
+ "../../alt/other"
+ "C:/alt/other"
+)
+
+test_resolve(
+ "x-Test+v1.0://example.com/group/parent"
+ "../other"
+ "x-Test+v1.0://example.com/group/other"
+)
+
+# IPv6 literals
+test_resolve(
+ "http://[::1]/group/parent"
+ "../../alt/other"
+ "http://[::1]/alt/other"
+)
+test_resolve(
+ "git@[::1]:group/parent"
+ "../../alt/other"
+ "git@[::1]:alt/other"
+)