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

Side by Side Diff: tests/standalone/io/file_system_exists_test.dart

Issue 25471003: Modify tests to use Directory.systemTemp (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase Created 7 years, 2 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
OLDNEW
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 "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import "dart:io"; 6 import "dart:io";
7 7
8 void testFileExistsSync() { 8 void testFileExistsSync() {
9 var tmp = new Directory("").createTempSync(); 9 var tmp = Directory.systemTemp.createTempSync('dart_file_system_exists');
10 var path = "${tmp.path}${Platform.pathSeparator}"; 10 var path = "${tmp.path}${Platform.pathSeparator}";
11 11
12 var file = new File("${path}myFile"); 12 var file = new File("${path}myFile");
13 file.createSync(); 13 file.createSync();
14 14
15 Expect.isTrue(new File(file.path).existsSync()); 15 Expect.isTrue(new File(file.path).existsSync());
16 Expect.isFalse(new Directory(file.path).existsSync()); 16 Expect.isFalse(new Directory(file.path).existsSync());
17 Expect.isFalse(new Link(file.path).existsSync()); 17 Expect.isFalse(new Link(file.path).existsSync());
18 18
19 file.deleteSync(); 19 file.deleteSync();
20 Expect.isFalse(file.existsSync()); 20 Expect.isFalse(file.existsSync());
21 21
22 tmp.deleteSync(); 22 tmp.deleteSync();
23 } 23 }
24 24
25 void testFileExists() { 25 void testFileExists() {
26 new Directory("").createTemp().then((tmp) { 26 Directory.systemTemp.createTemp('dart_file_system_exists').then((tmp) {
27 var path = "${tmp.path}${Platform.pathSeparator}"; 27 var path = "${tmp.path}${Platform.pathSeparator}";
28 var file = new File("${path}myFile"); 28 var file = new File("${path}myFile");
29 return file.create() 29 return file.create()
30 .then((_) => new File(file.path).exists().then(Expect.isTrue)) 30 .then((_) => new File(file.path).exists().then(Expect.isTrue))
31 .then((_) => new Directory(file.path).exists().then(Expect.isFalse)) 31 .then((_) => new Directory(file.path).exists().then(Expect.isFalse))
32 .then((_) => new Link(file.path).exists().then(Expect.isFalse)) 32 .then((_) => new Link(file.path).exists().then(Expect.isFalse))
33 33
34 .then((_) => file.delete()) 34 .then((_) => file.delete())
35 .then((_) => tmp.delete()); 35 .then((_) => tmp.delete());
36 }); 36 });
37 } 37 }
38 38
39 void testDirectoryExistsSync() { 39 void testDirectoryExistsSync() {
40 var tmp = new Directory("").createTempSync(); 40 var tmp = Directory.systemTemp.createTempSync('dart_file_system_exists');
41 var path = "${tmp.path}${Platform.pathSeparator}"; 41 var path = "${tmp.path}${Platform.pathSeparator}";
42 42
43 var dir = new Directory("${path}myDirectory"); 43 var dir = new Directory("${path}myDirectory");
44 dir.createSync(); 44 dir.createSync();
45 45
46 Expect.isFalse(new File(dir.path).existsSync()); 46 Expect.isFalse(new File(dir.path).existsSync());
47 Expect.isTrue(new Directory(dir.path).existsSync()); 47 Expect.isTrue(new Directory(dir.path).existsSync());
48 Expect.isFalse(new Link(dir.path).existsSync()); 48 Expect.isFalse(new Link(dir.path).existsSync());
49 49
50 dir.deleteSync(); 50 dir.deleteSync();
51 Expect.isFalse(dir.existsSync()); 51 Expect.isFalse(dir.existsSync());
52 52
53 tmp.deleteSync(); 53 tmp.deleteSync();
54 } 54 }
55 55
56 void testDirectoryExists() { 56 void testDirectoryExists() {
57 new Directory("").createTemp().then((tmp) { 57 Directory.systemTemp.createTemp('dart_file_system_exists').then((tmp) {
58 var path = "${tmp.path}${Platform.pathSeparator}"; 58 var path = "${tmp.path}${Platform.pathSeparator}";
59 var dir = new Directory("${path}myDirectory"); 59 var dir = new Directory("${path}myDirectory");
60 return dir.create() 60 return dir.create()
61 .then((_) => new File(dir.path).exists().then(Expect.isFalse)) 61 .then((_) => new File(dir.path).exists().then(Expect.isFalse))
62 .then((_) => new Directory(dir.path).exists().then(Expect.isTrue)) 62 .then((_) => new Directory(dir.path).exists().then(Expect.isTrue))
63 .then((_) => new Link(dir.path).exists().then(Expect.isFalse)) 63 .then((_) => new Link(dir.path).exists().then(Expect.isFalse))
64 64
65 .then((_) => dir.delete()) 65 .then((_) => dir.delete())
66 .then((_) => tmp.delete()); 66 .then((_) => tmp.delete());
67 }); 67 });
68 } 68 }
69 69
70 void testFileLinkExistsSync() { 70 void testFileLinkExistsSync() {
71 var tmp = new Directory("").createTempSync(); 71 var tmp = Directory.systemTemp.createTempSync('dart_file_system_exists');
72 var path = "${tmp.path}${Platform.pathSeparator}"; 72 var path = "${tmp.path}${Platform.pathSeparator}";
73 73
74 var file = new File("${path}myFile"); 74 var file = new File("${path}myFile");
75 file.createSync(); 75 file.createSync();
76 76
77 var link = new Link("${path}myLink"); 77 var link = new Link("${path}myLink");
78 link.createSync(file.path); 78 link.createSync(file.path);
79 79
80 Expect.isTrue(new File(link.path).existsSync()); 80 Expect.isTrue(new File(link.path).existsSync());
81 Expect.isFalse(new Directory(link.path).existsSync()); 81 Expect.isFalse(new Directory(link.path).existsSync());
82 Expect.isTrue(new Link(link.path).existsSync()); 82 Expect.isTrue(new Link(link.path).existsSync());
83 83
84 link.deleteSync(); 84 link.deleteSync();
85 Expect.isFalse(link.existsSync()); 85 Expect.isFalse(link.existsSync());
86 86
87 file.deleteSync(); 87 file.deleteSync();
88 Expect.isFalse(file.existsSync()); 88 Expect.isFalse(file.existsSync());
89 89
90 tmp.deleteSync(); 90 tmp.deleteSync();
91 } 91 }
92 92
93 void testFileLinkExists() { 93 void testFileLinkExists() {
94 new Directory("").createTemp().then((tmp) { 94 Directory.systemTemp.createTemp('dart_file_system_exists').then((tmp) {
95 var path = "${tmp.path}${Platform.pathSeparator}"; 95 var path = "${tmp.path}${Platform.pathSeparator}";
96 var file = new File("${path}myFile"); 96 var file = new File("${path}myFile");
97 var link = new Link("${path}myLink"); 97 var link = new Link("${path}myLink");
98 return file.create() 98 return file.create()
99 .then((_) => link.create(file.path)) 99 .then((_) => link.create(file.path))
100 100
101 .then((_) => new File(link.path).exists().then(Expect.isTrue)) 101 .then((_) => new File(link.path).exists().then(Expect.isTrue))
102 .then((_) => new Directory(link.path).exists().then(Expect.isFalse)) 102 .then((_) => new Directory(link.path).exists().then(Expect.isFalse))
103 .then((_) => new Link(link.path).exists().then(Expect.isTrue)) 103 .then((_) => new Link(link.path).exists().then(Expect.isTrue))
104 104
105 .then((_) => link.delete()) 105 .then((_) => link.delete())
106 .then((_) => file.delete()) 106 .then((_) => file.delete())
107 .then((_) => tmp.delete()); 107 .then((_) => tmp.delete());
108 }); 108 });
109 } 109 }
110 110
111 void testDirectoryLinkExistsSync() { 111 void testDirectoryLinkExistsSync() {
112 var tmp = new Directory("").createTempSync(); 112 var tmp = Directory.systemTemp.createTempSync('dart_file_system_exists');
113 var path = "${tmp.path}${Platform.pathSeparator}"; 113 var path = "${tmp.path}${Platform.pathSeparator}";
114 114
115 var directory = new Directory("${path}myDirectory"); 115 var directory = new Directory("${path}myDirectory");
116 directory.createSync(); 116 directory.createSync();
117 117
118 var link = new Link("${path}myLink"); 118 var link = new Link("${path}myLink");
119 link.createSync(directory.path); 119 link.createSync(directory.path);
120 120
121 Expect.isFalse(new File(link.path).existsSync()); 121 Expect.isFalse(new File(link.path).existsSync());
122 Expect.isTrue(new Directory(link.path).existsSync()); 122 Expect.isTrue(new Directory(link.path).existsSync());
123 Expect.isTrue(new Link(link.path).existsSync()); 123 Expect.isTrue(new Link(link.path).existsSync());
124 124
125 link.deleteSync(); 125 link.deleteSync();
126 Expect.isFalse(link.existsSync()); 126 Expect.isFalse(link.existsSync());
127 127
128 directory.deleteSync(); 128 directory.deleteSync();
129 Expect.isFalse(directory.existsSync()); 129 Expect.isFalse(directory.existsSync());
130 130
131 tmp.deleteSync(); 131 tmp.deleteSync();
132 } 132 }
133 133
134 void testDirectoryLinkExists() { 134 void testDirectoryLinkExists() {
135 new Directory("").createTemp().then((tmp) { 135 Directory.systemTemp.createTemp('dart_file_system_exists').then((tmp) {
136 var path = "${tmp.path}${Platform.pathSeparator}"; 136 var path = "${tmp.path}${Platform.pathSeparator}";
137 var dir = new Directory("${path}myDir"); 137 var dir = new Directory("${path}myDir");
138 var link = new Link("${path}myLink"); 138 var link = new Link("${path}myLink");
139 return dir.create() 139 return dir.create()
140 .then((_) => link.create(dir.path)) 140 .then((_) => link.create(dir.path))
141 141
142 .then((_) => new File(link.path).exists().then(Expect.isFalse)) 142 .then((_) => new File(link.path).exists().then(Expect.isFalse))
143 .then((_) => new Directory(link.path).exists().then(Expect.isTrue)) 143 .then((_) => new Directory(link.path).exists().then(Expect.isTrue))
144 .then((_) => new Link(link.path).exists().then(Expect.isTrue)) 144 .then((_) => new Link(link.path).exists().then(Expect.isTrue))
145 145
146 .then((_) => link.delete()) 146 .then((_) => link.delete())
147 .then((_) => dir.delete()) 147 .then((_) => dir.delete())
148 .then((_) => tmp.delete()); 148 .then((_) => tmp.delete());
149 }); 149 });
150 } 150 }
151 151
152 void testBrokenLinkExistsSync() { 152 void testBrokenLinkExistsSync() {
153 var tmp = new Directory("").createTempSync(); 153 var tmp = Directory.systemTemp.createTempSync('dart_file_system_exists');
154 var path = "${tmp.path}${Platform.pathSeparator}"; 154 var path = "${tmp.path}${Platform.pathSeparator}";
155 155
156 var directory = new Directory("${path}myDirectory"); 156 var directory = new Directory("${path}myDirectory");
157 directory.createSync(); 157 directory.createSync();
158 158
159 var link = new Link("${path}myLink"); 159 var link = new Link("${path}myLink");
160 link.createSync(directory.path); 160 link.createSync(directory.path);
161 directory.deleteSync(); 161 directory.deleteSync();
162 162
163 Expect.isFalse(new File(link.path).existsSync()); 163 Expect.isFalse(new File(link.path).existsSync());
164 Expect.isFalse(new Directory(link.path).existsSync()); 164 Expect.isFalse(new Directory(link.path).existsSync());
165 Expect.isTrue(new Link(link.path).existsSync()); 165 Expect.isTrue(new Link(link.path).existsSync());
166 166
167 link.deleteSync(); 167 link.deleteSync();
168 Expect.isFalse(link.existsSync()); 168 Expect.isFalse(link.existsSync());
169 169
170 tmp.deleteSync(); 170 tmp.deleteSync();
171 } 171 }
172 172
173 void testBrokenLinkExists() { 173 void testBrokenLinkExists() {
174 new Directory("").createTemp().then((tmp) { 174 Directory.systemTemp.createTemp('dart_file_system_exists').then((tmp) {
175 var path = "${tmp.path}${Platform.pathSeparator}"; 175 var path = "${tmp.path}${Platform.pathSeparator}";
176 var dir = new Directory("${path}myDir"); 176 var dir = new Directory("${path}myDir");
177 var link = new Link("${path}myLink"); 177 var link = new Link("${path}myLink");
178 return dir.create() 178 return dir.create()
179 .then((_) => link.create(dir.path)) 179 .then((_) => link.create(dir.path))
180 .then((_) => dir.delete()) 180 .then((_) => dir.delete())
181 181
182 .then((_) => new File(link.path).exists().then(Expect.isFalse)) 182 .then((_) => new File(link.path).exists().then(Expect.isFalse))
183 .then((_) => new Directory(link.path).exists().then(Expect.isFalse)) 183 .then((_) => new Directory(link.path).exists().then(Expect.isFalse))
184 .then((_) => new Link(link.path).exists().then(Expect.isTrue)) 184 .then((_) => new Link(link.path).exists().then(Expect.isTrue))
(...skipping 11 matching lines...) Expand all
196 if (Platform.operatingSystem != 'windows') { 196 if (Platform.operatingSystem != 'windows') {
197 testFileLinkExistsSync(); 197 testFileLinkExistsSync();
198 testFileLinkExists(); 198 testFileLinkExists();
199 } 199 }
200 testDirectoryLinkExistsSync(); 200 testDirectoryLinkExistsSync();
201 testDirectoryLinkExists(); 201 testDirectoryLinkExists();
202 testBrokenLinkExistsSync(); 202 testBrokenLinkExistsSync();
203 testBrokenLinkExists(); 203 testBrokenLinkExists();
204 } 204 }
205 205
OLDNEW
« no previous file with comments | « tests/standalone/io/file_system_delete_test.dart ('k') | tests/standalone/io/file_system_links_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698