| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:io'; | 6 import 'dart:io'; |
| 7 | 7 |
| 8 import 'package:glob/glob.dart'; | 8 import 'package:glob/glob.dart'; |
| 9 import 'package:glob/src/utils.dart'; | 9 import 'package:glob/src/utils.dart'; |
| 10 import 'package:path/path.dart' as p; | 10 import 'package:path/path.dart' as p; |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 expect(schedule(() { | 244 expect(schedule(() { |
| 245 var pattern = separatorToForwardSlash( | 245 var pattern = separatorToForwardSlash( |
| 246 p.absolute(p.join(sandbox, 'foo/baz/**'))); | 246 p.absolute(p.join(sandbox, 'foo/baz/**'))); |
| 247 | 247 |
| 248 return list(pattern); | 248 return list(pattern); |
| 249 }), completion(unorderedEquals([ | 249 }), completion(unorderedEquals([ |
| 250 p.join("foo", "baz", "bang"), | 250 p.join("foo", "baz", "bang"), |
| 251 p.join("foo", "baz", "qux") | 251 p.join("foo", "baz", "qux") |
| 252 ]))); | 252 ]))); |
| 253 }); | 253 }); |
| 254 |
| 255 test("lists a subdirectory that sometimes exists", () { |
| 256 d.dir("top", [ |
| 257 d.dir("dir1", [ |
| 258 d.dir("subdir", [d.file("file")]) |
| 259 ]), |
| 260 d.dir("dir2", []) |
| 261 ]).create(); |
| 262 |
| 263 expect(list("top/*/subdir/**"), |
| 264 completion(equals([p.join("top", "dir1", "subdir", "file")]))); |
| 265 }); |
| 254 }); | 266 }); |
| 255 } | 267 } |
| 256 | 268 |
| 257 typedef Future<List<String>> ListFn(String glob, | 269 typedef Future<List<String>> ListFn(String glob, |
| 258 {bool recursive, bool followLinks}); | 270 {bool recursive, bool followLinks}); |
| 259 | 271 |
| 260 /// Runs [callback] in two groups with two values of [listFn]: one that uses | 272 /// Runs [callback] in two groups with two values of [listFn]: one that uses |
| 261 /// [Glob.list], one that uses [Glob.listSync]. | 273 /// [Glob.list], one that uses [Glob.listSync]. |
| 262 void syncAndAsync(callback(ListFn listFn)) { | 274 void syncAndAsync(callback(ListFn listFn)) { |
| 263 group("async", () { | 275 group("async", () { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 292 }, 'creating sandbox'); | 304 }, 'creating sandbox'); |
| 293 | 305 |
| 294 currentSchedule.onComplete.schedule(() { | 306 currentSchedule.onComplete.schedule(() { |
| 295 d.defaultRoot = null; | 307 d.defaultRoot = null; |
| 296 if (sandbox == null) return null; | 308 if (sandbox == null) return null; |
| 297 var oldSandbox = sandbox; | 309 var oldSandbox = sandbox; |
| 298 sandbox = null; | 310 sandbox = null; |
| 299 return new Directory(oldSandbox).delete(recursive: true); | 311 return new Directory(oldSandbox).delete(recursive: true); |
| 300 }); | 312 }); |
| 301 } | 313 } |
| OLD | NEW |