| 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 library test.physical_file_system; | 5 library test.physical_file_system; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io' as io; | 8 import 'dart:io' as io; |
| 9 | 9 |
| 10 import 'package:analyzer/file_system/file_system.dart'; | 10 import 'package:analyzer/file_system/file_system.dart'; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 tearDown(() { | 34 tearDown(() { |
| 35 tempDirectory.deleteSync(recursive: true); | 35 tempDirectory.deleteSync(recursive: true); |
| 36 }); | 36 }); |
| 37 | 37 |
| 38 group('Watch', () { | 38 group('Watch', () { |
| 39 | 39 |
| 40 Future delayed(computation()) { | 40 Future delayed(computation()) { |
| 41 // Give the tests 1 second to detect the changes. While it may only | 41 // Give the tests 1 second to detect the changes. While it may only |
| 42 // take up to a few hundred ms, a whole second gives a good margin | 42 // take up to a few hundred ms, a whole second gives a good margin |
| 43 // for when running tests. | 43 // for when running tests. |
| 44 return new Future.delayed( | 44 return new Future.delayed(new Duration(seconds: 1), computation); |
| 45 new Duration(seconds: 1), computation); | |
| 46 } | 45 } |
| 47 | 46 |
| 48 watchingFolder(String path, test(List<WatchEvent> changesReceived)) { | 47 watchingFolder(String path, test(List<WatchEvent> changesReceived)) { |
| 49 // Delay before we start watching the folder. This is necessary | 48 // Delay before we start watching the folder. This is necessary |
| 50 // because on MacOS, file modifications that occur just before we | 49 // because on MacOS, file modifications that occur just before we |
| 51 // start watching are sometimes misclassified as happening just after | 50 // start watching are sometimes misclassified as happening just after |
| 52 // we start watching. | 51 // we start watching. |
| 53 return delayed(() { | 52 return delayed(() { |
| 54 Folder folder = PhysicalResourceProvider.INSTANCE.getResource(path); | 53 Folder folder = PhysicalResourceProvider.INSTANCE.getResource(path); |
| 55 var changesReceived = <WatchEvent>[]; | 54 var changesReceived = <WatchEvent>[]; |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 parent = grandParent; | 312 parent = grandParent; |
| 314 } | 313 } |
| 315 }); | 314 }); |
| 316 | 315 |
| 317 test('canonicalizePath', () { | 316 test('canonicalizePath', () { |
| 318 String path2 = join(tempPath, 'folder2'); | 317 String path2 = join(tempPath, 'folder2'); |
| 319 String path3 = join(tempPath, 'folder3'); | 318 String path3 = join(tempPath, 'folder3'); |
| 320 expect(folder.canonicalizePath('baz'), equals(join(path, 'baz'))); | 319 expect(folder.canonicalizePath('baz'), equals(join(path, 'baz'))); |
| 321 expect(folder.canonicalizePath(path2), equals(path2)); | 320 expect(folder.canonicalizePath(path2), equals(path2)); |
| 322 expect(folder.canonicalizePath(join('..', 'folder2')), equals(path2)); | 321 expect(folder.canonicalizePath(join('..', 'folder2')), equals(path2)); |
| 323 expect(folder.canonicalizePath(join(path2, '..', 'folder3')), equals(pat
h3)); | 322 expect( |
| 324 expect(folder.canonicalizePath(join('.', 'baz')), equals(join(path, 'baz
'))); | 323 folder.canonicalizePath(join(path2, '..', 'folder3')), |
| 325 expect(folder.canonicalizePath(join(path2, '.', 'baz')), equals(join(pat
h2, 'baz'))); | 324 equals(path3)); |
| 325 expect( |
| 326 folder.canonicalizePath(join('.', 'baz')), |
| 327 equals(join(path, 'baz'))); |
| 328 expect( |
| 329 folder.canonicalizePath(join(path2, '.', 'baz')), |
| 330 equals(join(path2, 'baz'))); |
| 326 }); | 331 }); |
| 327 }); | 332 }); |
| 328 }); | 333 }); |
| 329 } | 334 } |
| OLD | NEW |