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

Side by Side Diff: utils/tests/pub/io_test.dart

Issue 12079112: Make a bunch of stuff in pub synchronous. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix after merge. Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « utils/pub/validator/name.dart ('k') | utils/tests/pub/test_pub.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 io_test; 5 library io_test;
6 6
7 import '../../../pkg/unittest/lib/unittest.dart'; 7 import '../../../pkg/unittest/lib/unittest.dart';
8 import '../../pub/io.dart'; 8 import '../../pub/io.dart';
9 import '../../pub/utils.dart';
9 10
10 main() { 11 main() {
11 group('listDir', () { 12 group('listDir', () {
12 test('lists a simple directory non-recursively', () { 13 test('lists a simple directory non-recursively', () {
13 expect(withTempDir((path) { 14 expect(withTempDir((path) {
14 var future = writeTextFile(join(path, 'file1.txt'), '') 15 var future = defer(() {
15 .then((_) => writeTextFile(join(path, 'file2.txt'), '')) 16 writeTextFile(join(path, 'file1.txt'), '');
16 .then((_) => createDir(join(path, 'subdir'))) 17 writeTextFile(join(path, 'file2.txt'), '');
17 .then((_) => writeTextFile(join(path, 'subdir', 'file3.txt'), '')) 18 createDir(join(path, 'subdir'));
18 .then((_) => listDir(path)); 19 writeTextFile(join(path, 'subdir', 'file3.txt'), '');
20 return listDir(path);
21 });
19 expect(future, completion(unorderedEquals([ 22 expect(future, completion(unorderedEquals([
20 join(path, 'file1.txt'), 23 join(path, 'file1.txt'),
21 join(path, 'file2.txt'), 24 join(path, 'file2.txt'),
22 join(path, 'subdir') 25 join(path, 'subdir')
23 ]))); 26 ])));
24 return future; 27 return future;
25 }), completes); 28 }), completes);
26 }); 29 });
27 30
28 test('lists a simple directory recursively', () { 31 test('lists a simple directory recursively', () {
29 expect(withTempDir((path) { 32 expect(withTempDir((path) {
30 var future = writeTextFile(join(path, 'file1.txt'), '') 33 var future = defer(() {
31 .then((_) => writeTextFile(join(path, 'file2.txt'), '')) 34 writeTextFile(join(path, 'file1.txt'), '');
32 .then((_) => createDir(join(path, 'subdir'))) 35 writeTextFile(join(path, 'file2.txt'), '');
33 .then((_) => writeTextFile(join(path, 'subdir', 'file3.txt'), '')) 36 createDir(join(path, 'subdir'));
34 .then((_) => listDir(path, recursive: true)); 37 writeTextFile(join(path, 'subdir', 'file3.txt'), '');
38 return listDir(path, recursive: true);
39 });
35 expect(future, completion(unorderedEquals([ 40 expect(future, completion(unorderedEquals([
36 join(path, 'file1.txt'), 41 join(path, 'file1.txt'),
37 join(path, 'file2.txt'), 42 join(path, 'file2.txt'),
38 join(path, 'subdir'), 43 join(path, 'subdir'),
39 join(path, 'subdir/file3.txt'), 44 join(path, 'subdir/file3.txt'),
40 ]))); 45 ])));
41 return future; 46 return future;
42 }), completes); 47 }), completes);
43 }); 48 });
44 49
45 test('ignores hidden files by default', () { 50 test('ignores hidden files by default', () {
46 expect(withTempDir((path) { 51 expect(withTempDir((path) {
47 var future = writeTextFile(join(path, 'file1.txt'), '') 52 var future = defer(() {
48 .then((_) => writeTextFile(join(path, 'file2.txt'), '')) 53 writeTextFile(join(path, 'file1.txt'), '');
49 .then((_) => writeTextFile(join(path, '.file3.txt'), '')) 54 writeTextFile(join(path, 'file2.txt'), '');
50 .then((_) => createDir(join(path, '.subdir'))) 55 writeTextFile(join(path, '.file3.txt'), '');
51 .then((_) => writeTextFile(join(path, '.subdir', 'file3.txt'), '')) 56 createDir(join(path, '.subdir'));
52 .then((_) => listDir(path, recursive: true)); 57 writeTextFile(join(path, '.subdir', 'file3.txt'), '');
58 return listDir(path, recursive: true);
59 });
53 expect(future, completion(unorderedEquals([ 60 expect(future, completion(unorderedEquals([
54 join(path, 'file1.txt'), 61 join(path, 'file1.txt'),
55 join(path, 'file2.txt') 62 join(path, 'file2.txt')
56 ]))); 63 ])));
57 return future; 64 return future;
58 }), completes); 65 }), completes);
59 }); 66 });
60 67
61 test('includes hidden files when told to', () { 68 test('includes hidden files when told to', () {
62 expect(withTempDir((path) { 69 expect(withTempDir((path) {
63 var future = writeTextFile(join(path, 'file1.txt'), '') 70 var future = defer(() {
64 .then((_) => writeTextFile(join(path, 'file2.txt'), '')) 71 writeTextFile(join(path, 'file1.txt'), '');
65 .then((_) => writeTextFile(join(path, '.file3.txt'), '')) 72 writeTextFile(join(path, 'file2.txt'), '');
66 .then((_) => createDir(join(path, '.subdir'))) 73 writeTextFile(join(path, '.file3.txt'), '');
67 .then((_) => writeTextFile(join(path, '.subdir', 'file3.txt'), '')) 74 createDir(join(path, '.subdir'));
68 .then((_) { 75 writeTextFile(join(path, '.subdir', 'file3.txt'), '');
69 return listDir(path, recursive: true, includeHiddenFiles: true); 76 return listDir(path, recursive: true, includeHiddenFiles: true);
70 }); 77 });
71 expect(future, completion(unorderedEquals([ 78 expect(future, completion(unorderedEquals([
72 join(path, 'file1.txt'), 79 join(path, 'file1.txt'),
73 join(path, 'file2.txt'), 80 join(path, 'file2.txt'),
74 join(path, '.file3.txt'), 81 join(path, '.file3.txt'),
75 join(path, '.subdir'), 82 join(path, '.subdir'),
76 join(path, '.subdir/file3.txt') 83 join(path, '.subdir/file3.txt')
77 ]))); 84 ])));
78 return future; 85 return future;
79 }), completes); 86 }), completes);
80 }); 87 });
81 88
82 test('returns the unresolved paths for symlinks', () { 89 test('returns the unresolved paths for symlinks', () {
83 expect(withTempDir((path) { 90 expect(withTempDir((path) {
84 var dirToList = join(path, 'dir-to-list'); 91 var dirToList = join(path, 'dir-to-list');
85 var future = writeTextFile(join(path, 'file1.txt'), '') 92 var future = defer(() {
86 .then((_) => writeTextFile(join(path, 'file2.txt'), '')) 93 writeTextFile(join(path, 'file1.txt'), '');
87 .then((_) => createDir(dirToList)) 94 writeTextFile(join(path, 'file2.txt'), '');
88 .then((_) { 95 createDir(dirToList);
89 return createSymlink( 96 return createSymlink(join(path, 'file1.txt'),
90 join(path, 'file1.txt'), 97 join(dirToList, 'link1'));
91 join(dirToList, 'link1')); 98 }).then((_) {
92 }).then((_) => createDir(join(dirToList, 'subdir'))) 99 createDir(join(dirToList, 'subdir'));
93 .then((_) { 100 return createSymlink(
94 return createSymlink(
95 join(path, 'file2.txt'), 101 join(path, 'file2.txt'),
96 join(dirToList, 'subdir', 'link2')); 102 join(dirToList, 'subdir', 'link2'));
97 }).then((_) => listDir(dirToList, recursive: true)); 103 }).then((_) => listDir(dirToList, recursive: true));
98 expect(future, completion(unorderedEquals([ 104 expect(future, completion(unorderedEquals([
99 join(dirToList, 'link1'), 105 join(dirToList, 'link1'),
100 join(dirToList, 'subdir'), 106 join(dirToList, 'subdir'),
101 join(dirToList, 'subdir/link2'), 107 join(dirToList, 'subdir/link2'),
102 ]))); 108 ])));
103 return future; 109 return future;
104 }), completes); 110 }), completes);
105 }); 111 });
106 112
107 test('works with recursive symlinks', () { 113 test('works with recursive symlinks', () {
108 expect(withTempDir((path) { 114 expect(withTempDir((path) {
109 var future = writeTextFile(join(path, 'file1.txt'), '') 115 var future = defer(() {
110 .then((_) => createSymlink(path, join(path, 'linkdir'))) 116 writeTextFile(join(path, 'file1.txt'), '');
111 .then((_) => listDir(path, recursive: true)); 117 return createSymlink(path, join(path, 'linkdir'));
118 }).then((_) => listDir(path, recursive: true));
112 expect(future, completion(unorderedEquals([ 119 expect(future, completion(unorderedEquals([
113 join(path, 'file1.txt'), 120 join(path, 'file1.txt'),
114 join(path, 'linkdir') 121 join(path, 'linkdir')
115 ]))); 122 ])));
116 return future; 123 return future;
117 }), completes); 124 }), completes);
118 }); 125 });
119 }); 126 });
120 } 127 }
OLDNEW
« no previous file with comments | « utils/pub/validator/name.dart ('k') | utils/tests/pub/test_pub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698