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

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

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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
Index: tests/standalone/io/resolve_symbolic_links_test.dart
diff --git a/tests/standalone/io/resolve_symbolic_links_test.dart b/tests/standalone/io/resolve_symbolic_links_test.dart
index 4d3f22e8674b258ebe460e0e7a3be52c024657ed..c8978f6b5829ec893815a3d4077623c15e2100b7 100644
--- a/tests/standalone/io/resolve_symbolic_links_test.dart
+++ b/tests/standalone/io/resolve_symbolic_links_test.dart
@@ -16,88 +16,94 @@ main() {
// All of these tests test that resolveSymbolicLinks gives a path
// that points to the same place as the original, and that it removes
// all links, .., and . segments, and that it produces an absolute path.
- asyncTest(() => testFile(join(
- testsDir, 'standalone', 'io', 'resolve_symbolic_links_test.dart')));
+ asyncTest(() => testFile(
+ join(testsDir, 'standalone', 'io', 'resolve_symbolic_links_test.dart')));
asyncTest(() => testFile(join(testsDir, 'standalone', 'io', '..', 'io',
- 'resolve_symbolic_links_test.dart')));
+ 'resolve_symbolic_links_test.dart')));
asyncTest(() => testDir(join(testsDir, 'standalone', 'io')));
asyncTest(() => testDir(join(testsDir, 'lib', '..', 'standalone', 'io')));
// Test a relative path.
if (Platform.isWindows) {
- asyncTest(() =>testFile(join('\\\\?\\$testsDir', 'standalone', 'io',
- 'resolve_symbolic_links_test.dart')));
+ asyncTest(() => testFile(join('\\\\?\\$testsDir', 'standalone', 'io',
+ 'resolve_symbolic_links_test.dart')));
asyncTest(() => testDir('\\\\?\\$testsDir'));
}
- asyncTest(() => Directory.systemTemp.createTemp('dart_resolve_symbolic_links')
- .then((tempDir) {
- String temp = tempDir.path;
- return makeEntities(temp).then((_) => Future.wait(
- [testFile(join(temp, 'dir1', 'file1')),
- testFile(join(temp, 'link1', 'file2')),
- testDir(join(temp, 'dir1', 'dir2', '..', '.', '..', 'dir1')),
- testDir(join(temp, 'dir1', 'dir2', '..', '.', '..', 'dir1')),
- testLink(join(temp, 'link1')),
- testDir('.')]))
- .then((_) {
- if (Platform.isWindows) {
- // Windows applies '..' to a link without resolving the link first.
- return Future.wait([
- testFile(join(
- temp, 'dir1', '..', 'link1', '..', 'dir1', 'dir2', 'file2')),
- testDir(join(temp, 'dir1', '..', 'link1', '..', 'dir1')),
- testLink(join(temp, 'link1', '..', 'link1'))]);
- } else {
- // Non-Windows platforms resolve the link before adding the '..'.
- return Future.wait([
- testFile(join(
- temp, 'dir1', '..', 'link1', '..', 'dir2', 'file2')),
- testDir(join(temp, 'dir1', '..', 'link1', '..', 'dir2')),
- testLink(join(temp, 'link1', '..', '..', 'link1'))]);
- }
- })
- .then((_) {
- Directory.current = temp;
- return Future.wait([
- testFile('dir1/dir2/file2'), // Test forward slashes on Windows too.
- testFile('link1/file2'),
- testFile(join('dir1', '..', 'dir1', '.', 'file1')),
- testDir('.'),
- testLink('link1')]);
- })
- .then((_) {
- Directory.current = 'link1';
- if (Platform.isWindows) {
- return Future.wait([
- testFile('file2'),
- // Windows applies '..' to a link without resolving the link first.
- testFile('..\\dir1\\file1'),
- testLink('.'),
- testDir('..'),
- testLink('..\\link1')]);
- } else {
- return Future.wait([
- testFile('file2'),
- // On non-Windows the link is changed to dir1/dir2 before .. happens.
- testFile('../dir2/file2'),
- testDir('.'),
- testDir('..'),
- testLink('../../link1')]);
- }
- })
- .whenComplete(() {
- Directory.current = testsDir;
- tempDir.delete(recursive: true);
- });
- }));
+ asyncTest(() => Directory.systemTemp
+ .createTemp('dart_resolve_symbolic_links')
+ .then((tempDir) {
+ String temp = tempDir.path;
+ return makeEntities(temp)
+ .then((_) => Future.wait([
+ testFile(join(temp, 'dir1', 'file1')),
+ testFile(join(temp, 'link1', 'file2')),
+ testDir(join(temp, 'dir1', 'dir2', '..', '.', '..', 'dir1')),
+ testDir(join(temp, 'dir1', 'dir2', '..', '.', '..', 'dir1')),
+ testLink(join(temp, 'link1')),
+ testDir('.')
+ ]))
+ .then((_) {
+ if (Platform.isWindows) {
+ // Windows applies '..' to a link without resolving the link first.
+ return Future.wait([
+ testFile(join(
+ temp, 'dir1', '..', 'link1', '..', 'dir1', 'dir2', 'file2')),
+ testDir(join(temp, 'dir1', '..', 'link1', '..', 'dir1')),
+ testLink(join(temp, 'link1', '..', 'link1'))
+ ]);
+ } else {
+ // Non-Windows platforms resolve the link before adding the '..'.
+ return Future.wait([
+ testFile(
+ join(temp, 'dir1', '..', 'link1', '..', 'dir2', 'file2')),
+ testDir(join(temp, 'dir1', '..', 'link1', '..', 'dir2')),
+ testLink(join(temp, 'link1', '..', '..', 'link1'))
+ ]);
+ }
+ }).then((_) {
+ Directory.current = temp;
+ return Future.wait([
+ testFile('dir1/dir2/file2'), // Test forward slashes on Windows too.
+ testFile('link1/file2'),
+ testFile(join('dir1', '..', 'dir1', '.', 'file1')),
+ testDir('.'),
+ testLink('link1')
+ ]);
+ }).then((_) {
+ Directory.current = 'link1';
+ if (Platform.isWindows) {
+ return Future.wait([
+ testFile('file2'),
+ // Windows applies '..' to a link without resolving the link first.
+ testFile('..\\dir1\\file1'),
+ testLink('.'),
+ testDir('..'),
+ testLink('..\\link1')
+ ]);
+ } else {
+ return Future.wait([
+ testFile('file2'),
+ // On non-Windows the link is changed to dir1/dir2 before .. happens.
+ testFile('../dir2/file2'),
+ testDir('.'),
+ testDir('..'),
+ testLink('../../link1')
+ ]);
+ }
+ }).whenComplete(() {
+ Directory.current = testsDir;
+ tempDir.delete(recursive: true);
+ });
+ }));
}
Future makeEntities(String temp) {
- return new Directory(join(temp, 'dir1', 'dir2')).create(recursive: true)
+ return new Directory(join(temp, 'dir1', 'dir2'))
+ .create(recursive: true)
.then((_) => new File(join(temp, 'dir1', 'dir2', 'file2')).create())
.then((_) => new File(join(temp, 'dir1', 'file1')).create())
- .then((_) => new Link(join(temp, 'link1'))
- .create(join(temp, 'dir1', 'dir2')));
+ .then((_) =>
+ new Link(join(temp, 'link1')).create(join(temp, 'dir1', 'dir2')));
}
Future testFile(String name) {
@@ -108,7 +114,7 @@ Future testFile(String name) {
//Expect.isTrue(FileSystemEntity.identicalSync(name,
// new File(name).resolveSymbolicLinksSync()));
return new File(name).resolveSymbolicLinks().then((String resolved) {
- //Expect.isTrue(FileSystemEntity.identicalSync(name, resolved));
+ //Expect.isTrue(FileSystemEntity.identicalSync(name, resolved));
Expect.isTrue(isAbsolute(resolved));
// Test that resolveSymbolicLinks removes all links, .., and . segments.
Expect.isFalse(resolved.contains('..'));
@@ -118,8 +124,8 @@ Future testFile(String name) {
}
Future testDir(String name) {
- Expect.isTrue(FileSystemEntity.identicalSync(name,
- new Directory(name).resolveSymbolicLinksSync()));
+ Expect.isTrue(FileSystemEntity.identicalSync(
+ name, new Directory(name).resolveSymbolicLinksSync()));
return new Directory(name).resolveSymbolicLinks().then((String resolved) {
Expect.isTrue(FileSystemEntity.identicalSync(name, resolved));
Expect.isTrue(isAbsolute(resolved));
@@ -131,10 +137,10 @@ Future testDir(String name) {
}
Future testLink(String name) {
- Expect.isFalse(FileSystemEntity.identicalSync(name,
- new Link(name).resolveSymbolicLinksSync()));
- Expect.isTrue(FileSystemEntity.identicalSync(new Link(name).targetSync(),
- new Link(name).resolveSymbolicLinksSync()));
+ Expect.isFalse(FileSystemEntity.identicalSync(
+ name, new Link(name).resolveSymbolicLinksSync()));
+ Expect.isTrue(FileSystemEntity.identicalSync(
+ new Link(name).targetSync(), new Link(name).resolveSymbolicLinksSync()));
return new Link(name).resolveSymbolicLinks().then((String resolved) {
Expect.isFalse(FileSystemEntity.identicalSync(name, resolved));
Expect.isTrue(isAbsolute(resolved));
@@ -142,7 +148,8 @@ Future testLink(String name) {
Expect.isFalse(resolved.contains('..'));
Expect.isFalse(resolved.contains('./'));
Expect.isFalse(resolved.contains('link1'));
- return new Link(name).target()
+ return new Link(name)
+ .target()
.then((targetName) => FileSystemEntity.identical(targetName, resolved))
.then((identical) => Expect.isTrue(identical));
});

Powered by Google App Engine
This is Rietveld 408576698