@@ -81,9 +81,9 @@ defmodule PathTest do
81
81
end
82
82
83
83
test :absname_with_binary do
84
- assert Path . absname ( "/foo/bar" ) == "/foo/bar"
85
- assert Path . absname ( "/foo/bar/" ) == "/foo/bar"
86
- assert Path . absname ( "/foo/bar/../bar" ) == "/foo/bar/../bar"
84
+ assert ( Path . absname ( "/foo/bar" ) |> strip_drive_letter_if_windows ) == "/foo/bar"
85
+ assert ( Path . absname ( "/foo/bar/" ) |> strip_drive_letter_if_windows ) == "/foo/bar"
86
+ assert ( Path . absname ( "/foo/bar/../bar" ) |> strip_drive_letter_if_windows ) == "/foo/bar/../bar"
87
87
88
88
assert Path . absname ( "bar" , "/foo" ) == "/foo/bar"
89
89
assert Path . absname ( "bar/" , "/foo" ) == "/foo/bar"
@@ -93,10 +93,10 @@ defmodule PathTest do
93
93
end
94
94
95
95
test :absname_with_list do
96
- assert Path . absname ( '/foo/bar' ) == '/foo/bar'
97
- assert Path . absname ( '/foo/bar/' ) == '/foo/bar'
98
- assert Path . absname ( '/foo/bar/.' ) == '/foo/bar/.'
99
- assert Path . absname ( '/foo/bar/../bar' ) == '/foo/bar/../bar'
96
+ assert ( Path . absname ( '/foo/bar' ) |> strip_drive_letter_if_windows ) == '/foo/bar'
97
+ assert ( Path . absname ( '/foo/bar/' ) |> strip_drive_letter_if_windows ) == '/foo/bar'
98
+ assert ( Path . absname ( '/foo/bar/.' ) |> strip_drive_letter_if_windows ) == '/foo/bar/.'
99
+ assert ( Path . absname ( '/foo/bar/../bar' ) |> strip_drive_letter_if_windows ) == '/foo/bar/../bar'
100
100
end
101
101
102
102
test :expand_path_with_user_home do
@@ -115,26 +115,26 @@ defmodule PathTest do
115
115
end
116
116
117
117
test :expand_path_with_binary do
118
- assert Path . expand ( "/foo/bar" ) == "/foo/bar"
119
- assert Path . expand ( "/foo/bar/" ) == "/foo/bar"
120
- assert Path . expand ( "/foo/bar/." ) == "/foo/bar"
121
- assert Path . expand ( "/foo/bar/../bar" ) == "/foo/bar"
118
+ assert ( Path . expand ( "/foo/bar" ) |> strip_drive_letter_if_windows ) == "/foo/bar"
119
+ assert ( Path . expand ( "/foo/bar/" ) |> strip_drive_letter_if_windows ) == "/foo/bar"
120
+ assert ( Path . expand ( "/foo/bar/." ) |> strip_drive_letter_if_windows ) == "/foo/bar"
121
+ assert ( Path . expand ( "/foo/bar/../bar" ) |> strip_drive_letter_if_windows ) == "/foo/bar"
122
122
123
- assert Path . expand ( "bar" , "/foo" ) == "/foo/bar"
124
- assert Path . expand ( "bar/" , "/foo" ) == "/foo/bar"
125
- assert Path . expand ( "bar/." , "/foo" ) == "/foo/bar"
126
- assert Path . expand ( "bar/../bar" , "/foo" ) == "/foo/bar"
127
- assert Path . expand ( "../bar/../bar" , "/foo/../foo/../foo" ) == "/bar"
123
+ assert ( Path . expand ( "bar" , "/foo" ) |> strip_drive_letter_if_windows ) == "/foo/bar"
124
+ assert ( Path . expand ( "bar/" , "/foo" ) |> strip_drive_letter_if_windows ) == "/foo/bar"
125
+ assert ( Path . expand ( "bar/." , "/foo" ) |> strip_drive_letter_if_windows ) == "/foo/bar"
126
+ assert ( Path . expand ( "bar/../bar" , "/foo" ) |> strip_drive_letter_if_windows ) == "/foo/bar"
127
+ assert ( Path . expand ( "../bar/../bar" , "/foo/../foo/../foo" ) |> strip_drive_letter_if_windows ) == "/bar"
128
128
129
129
full = Path . expand ( "foo/bar" )
130
130
assert Path . expand ( "bar/../bar" , "foo" ) == full
131
131
end
132
132
133
133
test :expand_path_with_list do
134
- assert Path . expand ( '/foo/bar' ) == '/foo/bar'
135
- assert Path . expand ( '/foo/bar/' ) == '/foo/bar'
136
- assert Path . expand ( '/foo/bar/.' ) == '/foo/bar'
137
- assert Path . expand ( '/foo/bar/../bar' ) == '/foo/bar'
134
+ assert ( Path . expand ( '/foo/bar' ) |> strip_drive_letter_if_windows ) == '/foo/bar'
135
+ assert ( Path . expand ( '/foo/bar/' ) |> strip_drive_letter_if_windows ) == '/foo/bar'
136
+ assert ( Path . expand ( '/foo/bar/.' ) |> strip_drive_letter_if_windows ) == '/foo/bar'
137
+ assert ( Path . expand ( '/foo/bar/../bar' ) |> strip_drive_letter_if_windows ) == '/foo/bar'
138
138
end
139
139
140
140
test :relative_to_with_binary do
@@ -250,4 +250,11 @@ defmodule PathTest do
250
250
assert Path . split ( 'foo' ) == [ 'foo' ]
251
251
assert Path . split ( '/foo/bar' ) == [ '/' , 'foo' , 'bar' ]
252
252
end
253
+
254
+ if match? { :win32 , _ } , :os . type do
255
+ defp strip_drive_letter_if_windows ( [ _d , ?: | rest ] ) , do: rest
256
+ defp strip_drive_letter_if_windows ( << _d , ?: , rest :: binary >> ) , do: rest
257
+ else
258
+ defp strip_drive_letter_if_windows ( path ) , do: path
259
+ end
253
260
end
0 commit comments