summaryrefslogtreecommitdiff
path: root/Tests/RunCMake/CMP0150/CMP0150-NEW-resolve.cmake
blob: f43f3d5f7ba0fb1a4883d57cb45d0cab6e5153cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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"
)