Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(967)

Unified Diff: tests/standalone/io/link_async_test.dart

Issue 23532066: dart:io | Change creation of symbolic links with relative targets on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Drop .. and . segments from Windows link targets. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/io/link.dart ('k') | tests/standalone/io/link_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
}
« no previous file with comments | « sdk/lib/io/link.dart ('k') | tests/standalone/io/link_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698