|
10 | 10 |
|
11 | 11 | // ignore-windows TempDir may cause IoError on windows: #10462
|
12 | 12 |
|
| 13 | +#![feature(convert)] |
| 14 | +#![cfg_attr(test, deny(warnings)] |
| 15 | + |
13 | 16 | extern crate glob;
|
14 | 17 | extern crate tempdir;
|
15 | 18 |
|
@@ -78,199 +81,199 @@ fn main() {
|
78 | 81 |
|
79 | 82 | // all recursive entities
|
80 | 83 | assert_eq!(glob_vec("r/**"), vec!(
|
81 |
| - PathBuf::new("r/another"), |
82 |
| - PathBuf::new("r/one"), |
83 |
| - PathBuf::new("r/one/another"), |
84 |
| - PathBuf::new("r/one/another/deep"), |
85 |
| - PathBuf::new("r/three"), |
86 |
| - PathBuf::new("r/two"))); |
| 84 | + PathBuf::from("r/another"), |
| 85 | + PathBuf::from("r/one"), |
| 86 | + PathBuf::from("r/one/another"), |
| 87 | + PathBuf::from("r/one/another/deep"), |
| 88 | + PathBuf::from("r/three"), |
| 89 | + PathBuf::from("r/two"))); |
87 | 90 |
|
88 | 91 | // collapse consecutive recursive patterns
|
89 | 92 | assert_eq!(glob_vec("r/**/**"), vec!(
|
90 |
| - PathBuf::new("r/another"), |
91 |
| - PathBuf::new("r/one"), |
92 |
| - PathBuf::new("r/one/another"), |
93 |
| - PathBuf::new("r/one/another/deep"), |
94 |
| - PathBuf::new("r/three"), |
95 |
| - PathBuf::new("r/two"))); |
| 93 | + PathBuf::from("r/another"), |
| 94 | + PathBuf::from("r/one"), |
| 95 | + PathBuf::from("r/one/another"), |
| 96 | + PathBuf::from("r/one/another/deep"), |
| 97 | + PathBuf::from("r/three"), |
| 98 | + PathBuf::from("r/two"))); |
96 | 99 |
|
97 | 100 | assert_eq!(glob_vec("r/**/*"), vec!(
|
98 |
| - PathBuf::new("r/another"), |
99 |
| - PathBuf::new("r/another/a.md"), |
100 |
| - PathBuf::new("r/current_dir.md"), |
101 |
| - PathBuf::new("r/one"), |
102 |
| - PathBuf::new("r/one/a.md"), |
103 |
| - PathBuf::new("r/one/another"), |
104 |
| - PathBuf::new("r/one/another/a.md"), |
105 |
| - PathBuf::new("r/one/another/deep"), |
106 |
| - PathBuf::new("r/one/another/deep/spelunking.md"), |
107 |
| - PathBuf::new("r/three"), |
108 |
| - PathBuf::new("r/three/c.md"), |
109 |
| - PathBuf::new("r/two"), |
110 |
| - PathBuf::new("r/two/b.md"))); |
| 101 | + PathBuf::from("r/another"), |
| 102 | + PathBuf::from("r/another/a.md"), |
| 103 | + PathBuf::from("r/current_dir.md"), |
| 104 | + PathBuf::from("r/one"), |
| 105 | + PathBuf::from("r/one/a.md"), |
| 106 | + PathBuf::from("r/one/another"), |
| 107 | + PathBuf::from("r/one/another/a.md"), |
| 108 | + PathBuf::from("r/one/another/deep"), |
| 109 | + PathBuf::from("r/one/another/deep/spelunking.md"), |
| 110 | + PathBuf::from("r/three"), |
| 111 | + PathBuf::from("r/three/c.md"), |
| 112 | + PathBuf::from("r/two"), |
| 113 | + PathBuf::from("r/two/b.md"))); |
111 | 114 |
|
112 | 115 | // followed by a wildcard
|
113 | 116 | assert_eq!(glob_vec("r/**/*.md"), vec!(
|
114 |
| - PathBuf::new("r/another/a.md"), |
115 |
| - PathBuf::new("r/current_dir.md"), |
116 |
| - PathBuf::new("r/one/a.md"), |
117 |
| - PathBuf::new("r/one/another/a.md"), |
118 |
| - PathBuf::new("r/one/another/deep/spelunking.md"), |
119 |
| - PathBuf::new("r/three/c.md"), |
120 |
| - PathBuf::new("r/two/b.md"))); |
| 117 | + PathBuf::from("r/another/a.md"), |
| 118 | + PathBuf::from("r/current_dir.md"), |
| 119 | + PathBuf::from("r/one/a.md"), |
| 120 | + PathBuf::from("r/one/another/a.md"), |
| 121 | + PathBuf::from("r/one/another/deep/spelunking.md"), |
| 122 | + PathBuf::from("r/three/c.md"), |
| 123 | + PathBuf::from("r/two/b.md"))); |
121 | 124 |
|
122 | 125 | // followed by a precise pattern
|
123 | 126 | assert_eq!(glob_vec("r/one/**/a.md"), vec!(
|
124 |
| - PathBuf::new("r/one/a.md"), |
125 |
| - PathBuf::new("r/one/another/a.md"))); |
| 127 | + PathBuf::from("r/one/a.md"), |
| 128 | + PathBuf::from("r/one/another/a.md"))); |
126 | 129 |
|
127 | 130 | // followed by another recursive pattern
|
128 | 131 | // collapses consecutive recursives into one
|
129 | 132 | assert_eq!(glob_vec("r/one/**/**/a.md"), vec!(
|
130 |
| - PathBuf::new("r/one/a.md"), |
131 |
| - PathBuf::new("r/one/another/a.md"))); |
| 133 | + PathBuf::from("r/one/a.md"), |
| 134 | + PathBuf::from("r/one/another/a.md"))); |
132 | 135 |
|
133 | 136 | // followed by two precise patterns
|
134 | 137 | assert_eq!(glob_vec("r/**/another/a.md"), vec!(
|
135 |
| - PathBuf::new("r/another/a.md"), |
136 |
| - PathBuf::new("r/one/another/a.md"))); |
| 138 | + PathBuf::from("r/another/a.md"), |
| 139 | + PathBuf::from("r/one/another/a.md"))); |
137 | 140 |
|
138 | 141 | assert_eq!(glob_vec(""), Vec::new());
|
139 |
| - assert_eq!(glob_vec("."), vec!(PathBuf::new("."))); |
140 |
| - assert_eq!(glob_vec(".."), vec!(PathBuf::new(".."))); |
| 142 | + assert_eq!(glob_vec("."), vec!(PathBuf::from("."))); |
| 143 | + assert_eq!(glob_vec(".."), vec!(PathBuf::from(".."))); |
141 | 144 |
|
142 |
| - assert_eq!(glob_vec("aaa"), vec!(PathBuf::new("aaa"))); |
143 |
| - assert_eq!(glob_vec("aaa/"), vec!(PathBuf::new("aaa"))); |
| 145 | + assert_eq!(glob_vec("aaa"), vec!(PathBuf::from("aaa"))); |
| 146 | + assert_eq!(glob_vec("aaa/"), vec!(PathBuf::from("aaa"))); |
144 | 147 | assert_eq!(glob_vec("a"), Vec::new());
|
145 | 148 | assert_eq!(glob_vec("aa"), Vec::new());
|
146 | 149 | assert_eq!(glob_vec("aaaa"), Vec::new());
|
147 | 150 |
|
148 |
| - assert_eq!(glob_vec("aaa/apple"), vec!(PathBuf::new("aaa/apple"))); |
| 151 | + assert_eq!(glob_vec("aaa/apple"), vec!(PathBuf::from("aaa/apple"))); |
149 | 152 | assert_eq!(glob_vec("aaa/apple/nope"), Vec::new());
|
150 | 153 |
|
151 | 154 | // windows should support both / and \ as directory separators
|
152 | 155 | if env::consts::FAMILY == "windows" {
|
153 |
| - assert_eq!(glob_vec("aaa\\apple"), vec!(PathBuf::new("aaa/apple"))); |
| 156 | + assert_eq!(glob_vec("aaa\\apple"), vec!(PathBuf::from("aaa/apple"))); |
154 | 157 | }
|
155 | 158 |
|
156 | 159 | assert_eq!(glob_vec("???/"), vec!(
|
157 |
| - PathBuf::new("aaa"), |
158 |
| - PathBuf::new("bbb"), |
159 |
| - PathBuf::new("ccc"), |
160 |
| - PathBuf::new("xyz"))); |
| 160 | + PathBuf::from("aaa"), |
| 161 | + PathBuf::from("bbb"), |
| 162 | + PathBuf::from("ccc"), |
| 163 | + PathBuf::from("xyz"))); |
161 | 164 |
|
162 | 165 | assert_eq!(glob_vec("aaa/tomato/tom?to.txt"), vec!(
|
163 |
| - PathBuf::new("aaa/tomato/tomato.txt"), |
164 |
| - PathBuf::new("aaa/tomato/tomoto.txt"))); |
| 166 | + PathBuf::from("aaa/tomato/tomato.txt"), |
| 167 | + PathBuf::from("aaa/tomato/tomoto.txt"))); |
165 | 168 |
|
166 | 169 | assert_eq!(glob_vec("xyz/?"), vec!(
|
167 |
| - PathBuf::new("xyz/x"), |
168 |
| - PathBuf::new("xyz/y"), |
169 |
| - PathBuf::new("xyz/z"))); |
170 |
| - |
171 |
| - assert_eq!(glob_vec("a*"), vec!(PathBuf::new("aaa"))); |
172 |
| - assert_eq!(glob_vec("*a*"), vec!(PathBuf::new("aaa"))); |
173 |
| - assert_eq!(glob_vec("a*a"), vec!(PathBuf::new("aaa"))); |
174 |
| - assert_eq!(glob_vec("aaa*"), vec!(PathBuf::new("aaa"))); |
175 |
| - assert_eq!(glob_vec("*aaa"), vec!(PathBuf::new("aaa"))); |
176 |
| - assert_eq!(glob_vec("*aaa*"), vec!(PathBuf::new("aaa"))); |
177 |
| - assert_eq!(glob_vec("*a*a*a*"), vec!(PathBuf::new("aaa"))); |
178 |
| - assert_eq!(glob_vec("aaa*/"), vec!(PathBuf::new("aaa"))); |
| 170 | + PathBuf::from("xyz/x"), |
| 171 | + PathBuf::from("xyz/y"), |
| 172 | + PathBuf::from("xyz/z"))); |
| 173 | + |
| 174 | + assert_eq!(glob_vec("a*"), vec!(PathBuf::from("aaa"))); |
| 175 | + assert_eq!(glob_vec("*a*"), vec!(PathBuf::from("aaa"))); |
| 176 | + assert_eq!(glob_vec("a*a"), vec!(PathBuf::from("aaa"))); |
| 177 | + assert_eq!(glob_vec("aaa*"), vec!(PathBuf::from("aaa"))); |
| 178 | + assert_eq!(glob_vec("*aaa"), vec!(PathBuf::from("aaa"))); |
| 179 | + assert_eq!(glob_vec("*aaa*"), vec!(PathBuf::from("aaa"))); |
| 180 | + assert_eq!(glob_vec("*a*a*a*"), vec!(PathBuf::from("aaa"))); |
| 181 | + assert_eq!(glob_vec("aaa*/"), vec!(PathBuf::from("aaa"))); |
179 | 182 |
|
180 | 183 | assert_eq!(glob_vec("aaa/*"), vec!(
|
181 |
| - PathBuf::new("aaa/apple"), |
182 |
| - PathBuf::new("aaa/orange"), |
183 |
| - PathBuf::new("aaa/tomato"))); |
| 184 | + PathBuf::from("aaa/apple"), |
| 185 | + PathBuf::from("aaa/orange"), |
| 186 | + PathBuf::from("aaa/tomato"))); |
184 | 187 |
|
185 | 188 | assert_eq!(glob_vec("aaa/*a*"), vec!(
|
186 |
| - PathBuf::new("aaa/apple"), |
187 |
| - PathBuf::new("aaa/orange"), |
188 |
| - PathBuf::new("aaa/tomato"))); |
| 189 | + PathBuf::from("aaa/apple"), |
| 190 | + PathBuf::from("aaa/orange"), |
| 191 | + PathBuf::from("aaa/tomato"))); |
189 | 192 |
|
190 | 193 | assert_eq!(glob_vec("*/*/*.txt"), vec!(
|
191 |
| - PathBuf::new("aaa/tomato/tomato.txt"), |
192 |
| - PathBuf::new("aaa/tomato/tomoto.txt"))); |
| 194 | + PathBuf::from("aaa/tomato/tomato.txt"), |
| 195 | + PathBuf::from("aaa/tomato/tomoto.txt"))); |
193 | 196 |
|
194 | 197 | assert_eq!(glob_vec("*/*/t[aob]m?to[.]t[!y]t"), vec!(
|
195 |
| - PathBuf::new("aaa/tomato/tomato.txt"), |
196 |
| - PathBuf::new("aaa/tomato/tomoto.txt"))); |
| 198 | + PathBuf::from("aaa/tomato/tomato.txt"), |
| 199 | + PathBuf::from("aaa/tomato/tomoto.txt"))); |
197 | 200 |
|
198 |
| - assert_eq!(glob_vec("./aaa"), vec!(PathBuf::new("aaa"))); |
| 201 | + assert_eq!(glob_vec("./aaa"), vec!(PathBuf::from("aaa"))); |
199 | 202 | assert_eq!(glob_vec("./*"), glob_vec("*"));
|
200 |
| - assert_eq!(glob_vec("*/..").pop().unwrap(), PathBuf::new("xyz/..")); |
201 |
| - assert_eq!(glob_vec("aaa/../bbb"), vec!(PathBuf::new("aaa/../bbb"))); |
| 203 | + assert_eq!(glob_vec("*/..").pop().unwrap(), PathBuf::from("xyz/..")); |
| 204 | + assert_eq!(glob_vec("aaa/../bbb"), vec!(PathBuf::from("aaa/../bbb"))); |
202 | 205 | assert_eq!(glob_vec("nonexistent/../bbb"), Vec::new());
|
203 | 206 | assert_eq!(glob_vec("aaa/tomato/tomato.txt/.."), Vec::new());
|
204 | 207 |
|
205 | 208 | assert_eq!(glob_vec("aaa/tomato/tomato.txt/"), Vec::new());
|
206 | 209 |
|
207 |
| - assert_eq!(glob_vec("aa[a]"), vec!(PathBuf::new("aaa"))); |
208 |
| - assert_eq!(glob_vec("aa[abc]"), vec!(PathBuf::new("aaa"))); |
209 |
| - assert_eq!(glob_vec("a[bca]a"), vec!(PathBuf::new("aaa"))); |
| 210 | + assert_eq!(glob_vec("aa[a]"), vec!(PathBuf::from("aaa"))); |
| 211 | + assert_eq!(glob_vec("aa[abc]"), vec!(PathBuf::from("aaa"))); |
| 212 | + assert_eq!(glob_vec("a[bca]a"), vec!(PathBuf::from("aaa"))); |
210 | 213 | assert_eq!(glob_vec("aa[b]"), Vec::new());
|
211 | 214 | assert_eq!(glob_vec("aa[xyz]"), Vec::new());
|
212 | 215 | assert_eq!(glob_vec("aa[]]"), Vec::new());
|
213 | 216 |
|
214 |
| - assert_eq!(glob_vec("aa[!b]"), vec!(PathBuf::new("aaa"))); |
215 |
| - assert_eq!(glob_vec("aa[!bcd]"), vec!(PathBuf::new("aaa"))); |
216 |
| - assert_eq!(glob_vec("a[!bcd]a"), vec!(PathBuf::new("aaa"))); |
| 217 | + assert_eq!(glob_vec("aa[!b]"), vec!(PathBuf::from("aaa"))); |
| 218 | + assert_eq!(glob_vec("aa[!bcd]"), vec!(PathBuf::from("aaa"))); |
| 219 | + assert_eq!(glob_vec("a[!bcd]a"), vec!(PathBuf::from("aaa"))); |
217 | 220 | assert_eq!(glob_vec("aa[!a]"), Vec::new());
|
218 | 221 | assert_eq!(glob_vec("aa[!abc]"), Vec::new());
|
219 | 222 |
|
220 |
| - assert_eq!(glob_vec("bbb/specials/[[]"), vec!(PathBuf::new("bbb/specials/["))); |
221 |
| - assert_eq!(glob_vec("bbb/specials/!"), vec!(PathBuf::new("bbb/specials/!"))); |
222 |
| - assert_eq!(glob_vec("bbb/specials/[]]"), vec!(PathBuf::new("bbb/specials/]"))); |
| 223 | + assert_eq!(glob_vec("bbb/specials/[[]"), vec!(PathBuf::from("bbb/specials/["))); |
| 224 | + assert_eq!(glob_vec("bbb/specials/!"), vec!(PathBuf::from("bbb/specials/!"))); |
| 225 | + assert_eq!(glob_vec("bbb/specials/[]]"), vec!(PathBuf::from("bbb/specials/]"))); |
223 | 226 |
|
224 | 227 | if env::consts::FAMILY != "windows" {
|
225 |
| - assert_eq!(glob_vec("bbb/specials/[*]"), vec!(PathBuf::new("bbb/specials/*"))); |
226 |
| - assert_eq!(glob_vec("bbb/specials/[?]"), vec!(PathBuf::new("bbb/specials/?"))); |
| 228 | + assert_eq!(glob_vec("bbb/specials/[*]"), vec!(PathBuf::from("bbb/specials/*"))); |
| 229 | + assert_eq!(glob_vec("bbb/specials/[?]"), vec!(PathBuf::from("bbb/specials/?"))); |
227 | 230 | }
|
228 | 231 |
|
229 | 232 | if env::consts::FAMILY == "windows" {
|
230 | 233 |
|
231 | 234 | assert_eq!(glob_vec("bbb/specials/[![]"), vec!(
|
232 |
| - PathBuf::new("bbb/specials/!"), |
233 |
| - PathBuf::new("bbb/specials/]"))); |
| 235 | + PathBuf::from("bbb/specials/!"), |
| 236 | + PathBuf::from("bbb/specials/]"))); |
234 | 237 |
|
235 | 238 | assert_eq!(glob_vec("bbb/specials/[!]]"), vec!(
|
236 |
| - PathBuf::new("bbb/specials/!"), |
237 |
| - PathBuf::new("bbb/specials/["))); |
| 239 | + PathBuf::from("bbb/specials/!"), |
| 240 | + PathBuf::from("bbb/specials/["))); |
238 | 241 |
|
239 | 242 | assert_eq!(glob_vec("bbb/specials/[!!]"), vec!(
|
240 |
| - PathBuf::new("bbb/specials/["), |
241 |
| - PathBuf::new("bbb/specials/]"))); |
| 243 | + PathBuf::from("bbb/specials/["), |
| 244 | + PathBuf::from("bbb/specials/]"))); |
242 | 245 |
|
243 | 246 | } else {
|
244 | 247 |
|
245 | 248 | assert_eq!(glob_vec("bbb/specials/[![]"), vec!(
|
246 |
| - PathBuf::new("bbb/specials/!"), |
247 |
| - PathBuf::new("bbb/specials/*"), |
248 |
| - PathBuf::new("bbb/specials/?"), |
249 |
| - PathBuf::new("bbb/specials/]"))); |
| 249 | + PathBuf::from("bbb/specials/!"), |
| 250 | + PathBuf::from("bbb/specials/*"), |
| 251 | + PathBuf::from("bbb/specials/?"), |
| 252 | + PathBuf::from("bbb/specials/]"))); |
250 | 253 |
|
251 | 254 | assert_eq!(glob_vec("bbb/specials/[!]]"), vec!(
|
252 |
| - PathBuf::new("bbb/specials/!"), |
253 |
| - PathBuf::new("bbb/specials/*"), |
254 |
| - PathBuf::new("bbb/specials/?"), |
255 |
| - PathBuf::new("bbb/specials/["))); |
| 255 | + PathBuf::from("bbb/specials/!"), |
| 256 | + PathBuf::from("bbb/specials/*"), |
| 257 | + PathBuf::from("bbb/specials/?"), |
| 258 | + PathBuf::from("bbb/specials/["))); |
256 | 259 |
|
257 | 260 | assert_eq!(glob_vec("bbb/specials/[!!]"), vec!(
|
258 |
| - PathBuf::new("bbb/specials/*"), |
259 |
| - PathBuf::new("bbb/specials/?"), |
260 |
| - PathBuf::new("bbb/specials/["), |
261 |
| - PathBuf::new("bbb/specials/]"))); |
| 261 | + PathBuf::from("bbb/specials/*"), |
| 262 | + PathBuf::from("bbb/specials/?"), |
| 263 | + PathBuf::from("bbb/specials/["), |
| 264 | + PathBuf::from("bbb/specials/]"))); |
262 | 265 |
|
263 | 266 | assert_eq!(glob_vec("bbb/specials/[!*]"), vec!(
|
264 |
| - PathBuf::new("bbb/specials/!"), |
265 |
| - PathBuf::new("bbb/specials/?"), |
266 |
| - PathBuf::new("bbb/specials/["), |
267 |
| - PathBuf::new("bbb/specials/]"))); |
| 267 | + PathBuf::from("bbb/specials/!"), |
| 268 | + PathBuf::from("bbb/specials/?"), |
| 269 | + PathBuf::from("bbb/specials/["), |
| 270 | + PathBuf::from("bbb/specials/]"))); |
268 | 271 |
|
269 | 272 | assert_eq!(glob_vec("bbb/specials/[!?]"), vec!(
|
270 |
| - PathBuf::new("bbb/specials/!"), |
271 |
| - PathBuf::new("bbb/specials/*"), |
272 |
| - PathBuf::new("bbb/specials/["), |
273 |
| - PathBuf::new("bbb/specials/]"))); |
| 273 | + PathBuf::from("bbb/specials/!"), |
| 274 | + PathBuf::from("bbb/specials/*"), |
| 275 | + PathBuf::from("bbb/specials/["), |
| 276 | + PathBuf::from("bbb/specials/]"))); |
274 | 277 |
|
275 | 278 | }
|
276 | 279 | }
|
0 commit comments