Index: tests/standalone/io/link_async_test.dart |
diff --git a/tests/standalone/io/link_async_test.dart b/tests/standalone/io/link_async_test.dart |
index d468a31133278f4f8c0a36c0fbcb4c9c1a6e15e4..60569c9d889b0983d87b287375dc5050f064cead 100644 |
--- a/tests/standalone/io/link_async_test.dart |
+++ b/tests/standalone/io/link_async_test.dart |
@@ -140,7 +140,7 @@ Future testCreate() { |
} |
-Future testCreateLoopingLink() { |
+Future testCreateLoopingLink(_) { |
return new Directory('').createTemp() |
.then((dir) => dir.path) |
.then((String base) => |
@@ -163,7 +163,7 @@ Future testCreateLoopingLink() { |
} |
-Future testRename() { |
+Future testRename(_) { |
Future testRename(String base , String target) { |
Link link1; |
Link link2; |
@@ -271,10 +271,45 @@ Future testDirectoryListing(String base, Directory baseDir) { |
return Future.wait(futures); |
} |
+Future checkExists(String filePath) => |
+ new File(filePath).exists().then((exists) => Expect.isTrue(exists)); |
Søren Gjesse
2013/09/17 11:55:30
(exists) => Expect.isTrue(exists) can be written j
|
+ |
+Future testRelativeLinks(_) { |
+ return new Directory('').createTemp().then((tempDirectory) { |
+ String temp = tempDirectory.path; |
+ String oldWorkingDirectory = Directory.current.path; |
+ // Make directories and files to test links. |
+ return new Directory(join(temp, 'dir1', 'dir2')).create(recursive: true) |
+ .then((_) => new File(join(temp, 'dir1', 'file1')).create()) |
+ .then((_) => new File(join(temp, 'dir1', 'dir2', 'file2')).create()) |
+ // Make links whose path and/or target is given by a relative path. |
+ .then((_) => new Link(join(temp, 'dir1', 'link1_2')).create('dir2')) |
+ .then((_) => Directory.current = temp) |
+ .then((_) => new Link('link0_2').create(join('dir1', 'dir2'))) |
+ .then((_) => new Link(join('dir1', 'link1_0')).create('..')) |
+ .then((_) => Directory.current = 'dir1') |
+ .then((_) => new Link(join('..', 'link0_1')).create('dir1')) |
+ .then((_) => new Link(join('dir2', 'link2_1')).create(join(temp, 'dir1'))) |
+ .then((_) => new Link(join(temp, 'dir1', 'dir2', 'link2_0')) |
+ .create(join('..', '..'))) |
+ // Test that the links go to the right targets. |
+ .then((_) => checkExists(join('..', 'link0_1', 'file1'))) |
+ .then((_) => checkExists(join('..', 'link0_2', 'file2'))) |
+ .then((_) => checkExists(join('link1_0', 'dir1', 'file1'))) |
+ .then((_) => checkExists(join('link1_2', 'file2'))) |
+ .then((_) => checkExists(join('dir2', 'link2_0', 'dir1', 'file1'))) |
+ .then((_) => checkExists(join('dir2', 'link2_1', 'file1'))) |
+ // Clean up |
+ .whenComplete(() => Directory.current = oldWorkingDirectory) |
+ .whenComplete(() => tempDirectory.delete(recursive: true)); |
+ }); |
+} |
+ |
main() { |
asyncStart(); |
testCreate() |
- .then((_) => testCreateLoopingLink()) |
- .then((_) => testRename()) |
+ .then(testCreateLoopingLink) |
+ .then(testRename) |
+ .then(testRelativeLinks) |
.then((_) => asyncEnd()); |
} |