| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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:io"; | 5 import "dart:io"; |
| 6 import "dart:isolate"; | 6 import "dart:isolate"; |
| 7 | 7 |
| 8 testJunctionTypeDelete() { | 8 testJunctionTypeDelete() { |
| 9 var temp = new Directory('').createTempSync(); | 9 var temp = new Directory('').createTempSync(); |
| 10 var x = '${temp.path}${Platform.pathSeparator}x'; | 10 var x = '${temp.path}${Platform.pathSeparator}x'; |
| 11 var y = '${temp.path}${Platform.pathSeparator}y'; | 11 var y = '${temp.path}${Platform.pathSeparator}y'; |
| 12 | 12 |
| 13 new Directory(x).createSync(); | 13 new Directory(x).createSync(); |
| 14 new Link(y).create(x).then((_) { | 14 new Link(y).create(x).then((_) { |
| 15 Expect.isTrue(new Directory(y).existsSync()); | 15 Expect.isTrue(new Directory(y).existsSync()); |
| 16 Expect.isTrue(new Directory(x).existsSync()); | 16 Expect.isTrue(new Directory(x).existsSync()); |
| 17 Expect.isTrue(FileSystemEntity.isLinkSync(y)); | 17 Expect.isTrue(FileSystemEntity.isLinkSync(y)); |
| 18 Expect.isFalse(FileSystemEntity.isLinkSync(x)); | 18 Expect.isFalse(FileSystemEntity.isLinkSync(x)); |
| 19 Expect.isTrue(FileSystemEntity.isDirectorySync(y)); | 19 Expect.isTrue(FileSystemEntity.isDirectorySync(y)); |
| 20 Expect.isTrue(FileSystemEntity.isDirectorySync(x)); | 20 Expect.isTrue(FileSystemEntity.isDirectorySync(x)); |
| 21 Expect.equals(FileSystemEntityType.DIRECTORY, | 21 Expect.equals(FileSystemEntityType.DIRECTORY, |
| 22 FileSystemEntity.typeSync(y)); | 22 FileSystemEntity.typeSync(y)); |
| 23 Expect.equals(FileSystemEntityType.DIRECTORY, | 23 Expect.equals(FileSystemEntityType.DIRECTORY, |
| 24 FileSystemEntity.typeSync(x)); | 24 FileSystemEntity.typeSync(x)); |
| 25 Expect.equals(FileSystemEntityType.LINK, | 25 Expect.equals(FileSystemEntityType.LINK, |
| 26 FileSystemEntity.typeSync(y, followLinks: false)); | 26 FileSystemEntity.typeSync(y, followLinks: false)); |
| 27 Expect.equals(FileSystemEntityType.DIRECTORY, | 27 Expect.equals(FileSystemEntityType.DIRECTORY, |
| 28 FileSystemEntity.typeSync(x, followLinks: false)); | 28 FileSystemEntity.typeSync(x, followLinks: false)); |
| 29 Expect.equals(x, new Link(y).targetSync()); |
| 30 |
| 29 // Test Junction pointing to a missing directory. | 31 // Test Junction pointing to a missing directory. |
| 30 new Directory(x).deleteSync(); | 32 new Directory(x).deleteSync(); |
| 31 Expect.isTrue(new Directory(y).existsSync()); | 33 Expect.isTrue(new Directory(y).existsSync()); |
| 32 Expect.isFalse(new Directory(x).existsSync()); | 34 Expect.isFalse(new Directory(x).existsSync()); |
| 33 Expect.isTrue(FileSystemEntity.isLinkSync(y)); | 35 Expect.isTrue(FileSystemEntity.isLinkSync(y)); |
| 34 Expect.isFalse(FileSystemEntity.isLinkSync(x)); | 36 Expect.isFalse(FileSystemEntity.isLinkSync(x)); |
| 35 Expect.isFalse(FileSystemEntity.isDirectorySync(y)); | 37 Expect.isFalse(FileSystemEntity.isDirectorySync(y)); |
| 36 Expect.isFalse(FileSystemEntity.isDirectorySync(x)); | 38 Expect.isFalse(FileSystemEntity.isDirectorySync(x)); |
| 37 Expect.equals(FileSystemEntityType.NOT_FOUND, | 39 Expect.equals(FileSystemEntityType.NOT_FOUND, |
| 38 FileSystemEntity.typeSync(y)); | 40 FileSystemEntity.typeSync(y)); |
| 39 Expect.equals(FileSystemEntityType.NOT_FOUND, | 41 Expect.equals(FileSystemEntityType.NOT_FOUND, |
| 40 FileSystemEntity.typeSync(x)); | 42 FileSystemEntity.typeSync(x)); |
| 41 Expect.equals(FileSystemEntityType.LINK, | 43 Expect.equals(FileSystemEntityType.LINK, |
| 42 FileSystemEntity.typeSync(y, followLinks: false)); | 44 FileSystemEntity.typeSync(y, followLinks: false)); |
| 43 Expect.equals(FileSystemEntityType.NOT_FOUND, | 45 Expect.equals(FileSystemEntityType.NOT_FOUND, |
| 44 FileSystemEntity.typeSync(x, followLinks: false)); | 46 FileSystemEntity.typeSync(x, followLinks: false)); |
| 47 Expect.equals(x, new Link(y).targetSync()); |
| 45 | 48 |
| 46 // Delete Junction pointing to a missing directory. | 49 // Delete Junction pointing to a missing directory. |
| 47 new Directory(y).deleteSync(); | 50 new Directory(y).deleteSync(); |
| 48 Expect.isFalse(FileSystemEntity.isLinkSync(y)); | 51 Expect.isFalse(FileSystemEntity.isLinkSync(y)); |
| 49 Expect.equals(FileSystemEntityType.NOT_FOUND, | 52 Expect.equals(FileSystemEntityType.NOT_FOUND, |
| 50 FileSystemEntity.typeSync(y)); | 53 FileSystemEntity.typeSync(y)); |
| 54 Expect.throws(() => new Link(y).targetSync()); |
| 51 | 55 |
| 52 new Directory(x).createSync(); | 56 new Directory(x).createSync(); |
| 53 new Link(y).create(x).then((_) { | 57 new Link(y).create(x).then((_) { |
| 54 Expect.equals(FileSystemEntityType.LINK, | 58 Expect.equals(FileSystemEntityType.LINK, |
| 55 FileSystemEntity.typeSync(y, followLinks: false)); | 59 FileSystemEntity.typeSync(y, followLinks: false)); |
| 56 Expect.equals(FileSystemEntityType.DIRECTORY, | 60 Expect.equals(FileSystemEntityType.DIRECTORY, |
| 57 FileSystemEntity.typeSync(x, followLinks: false)); | 61 FileSystemEntity.typeSync(x, followLinks: false)); |
| 62 Expect.equals(x, new Link(y).targetSync()); |
| 58 | 63 |
| 59 // Delete Junction pointing to an existing directory. | 64 // Delete Junction pointing to an existing directory. |
| 60 new Directory(y).deleteSync(); | 65 new Directory(y).deleteSync(); |
| 61 Expect.equals(FileSystemEntityType.NOT_FOUND, | 66 Expect.equals(FileSystemEntityType.NOT_FOUND, |
| 62 FileSystemEntity.typeSync(y)); | 67 FileSystemEntity.typeSync(y)); |
| 63 Expect.equals(FileSystemEntityType.NOT_FOUND, | 68 Expect.equals(FileSystemEntityType.NOT_FOUND, |
| 64 FileSystemEntity.typeSync(y, followLinks: false)); | 69 FileSystemEntity.typeSync(y, followLinks: false)); |
| 65 Expect.equals(FileSystemEntityType.DIRECTORY, | 70 Expect.equals(FileSystemEntityType.DIRECTORY, |
| 66 FileSystemEntity.typeSync(x)); | 71 FileSystemEntity.typeSync(x)); |
| 67 Expect.equals(FileSystemEntityType.DIRECTORY, | 72 Expect.equals(FileSystemEntityType.DIRECTORY, |
| 68 FileSystemEntity.typeSync(x, followLinks: false)); | 73 FileSystemEntity.typeSync(x, followLinks: false)); |
| 74 Expect.throws(() => new Link(y).targetSync()); |
| 75 |
| 69 temp.deleteSync(recursive: true); | 76 temp.deleteSync(recursive: true); |
| 70 }); | 77 }); |
| 71 }); | 78 }); |
| 72 } | 79 } |
| 73 | 80 |
| 74 | 81 |
| 75 main() { | 82 main() { |
| 76 if (Platform.operatingSystem == 'windows') { | 83 if (Platform.operatingSystem == 'windows') { |
| 77 testJunctionTypeDelete(); | 84 testJunctionTypeDelete(); |
| 78 } | 85 } |
| 79 } | 86 } |
| OLD | NEW |