OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 analyzer.test.file_system.physical_resource_provider_test; | 5 library analyzer.test.file_system.physical_resource_provider_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:core' hide Resource; | 8 import 'dart:core' hide Resource; |
9 import 'dart:io' as io; | 9 import 'dart:io' as io; |
10 | 10 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 new io.File(oldPath).writeAsStringSync('text'); | 173 new io.File(oldPath).writeAsStringSync('text'); |
174 new io.Directory(newPath).createSync(); | 174 new io.Directory(newPath).createSync(); |
175 File file = PhysicalResourceProvider.INSTANCE.getResource(oldPath); | 175 File file = PhysicalResourceProvider.INSTANCE.getResource(oldPath); |
176 expect(() { | 176 expect(() { |
177 file.renameSync(newPath); | 177 file.renameSync(newPath); |
178 }, throwsA(_isFileSystemException)); | 178 }, throwsA(_isFileSystemException)); |
179 expect(file.path, oldPath); | 179 expect(file.path, oldPath); |
180 expect(file.exists, isTrue); | 180 expect(file.exists, isTrue); |
181 } | 181 } |
182 | 182 |
| 183 void test_resolveSymbolicLinksSync_links() { |
| 184 Context pathContext = PhysicalResourceProvider.INSTANCE.pathContext; |
| 185 String pathA = pathContext.join(tempPath, 'a'); |
| 186 String pathB = pathContext.join(pathA, 'b'); |
| 187 new io.Directory(pathB).createSync(recursive: true); |
| 188 String filePath = pathContext.join(pathB, 'test.txt'); |
| 189 io.File testFile = new io.File(filePath); |
| 190 testFile.writeAsStringSync('test'); |
| 191 |
| 192 String pathC = pathContext.join(tempPath, 'c'); |
| 193 String pathD = pathContext.join(pathC, 'd'); |
| 194 new io.Link(pathD).createSync(pathA, recursive: true); |
| 195 |
| 196 String pathE = pathContext.join(tempPath, 'e'); |
| 197 String pathF = pathContext.join(pathE, 'f'); |
| 198 new io.Link(pathF).createSync(pathC, recursive: true); |
| 199 |
| 200 String linkPath = |
| 201 pathContext.join(tempPath, 'e', 'f', 'd', 'b', 'test.txt'); |
| 202 File file = PhysicalResourceProvider.INSTANCE.getFile(linkPath); |
| 203 expect(file.resolveSymbolicLinksSync().path, |
| 204 testFile.resolveSymbolicLinksSync()); |
| 205 } |
| 206 |
| 207 void test_resolveSymbolicLinksSync_noLinks() { |
| 208 // |
| 209 // On some platforms the path to the temp directory includes a symbolic |
| 210 // link. We remove that from the equation before creating the File in order |
| 211 // to show that the operation works as expected without symbolic links. |
| 212 // |
| 213 io.File ioFile = new io.File(path); |
| 214 ioFile.writeAsStringSync('test'); |
| 215 file = PhysicalResourceProvider.INSTANCE |
| 216 .getFile(ioFile.resolveSymbolicLinksSync()); |
| 217 expect(file.resolveSymbolicLinksSync(), file); |
| 218 } |
| 219 |
183 void test_shortName() { | 220 void test_shortName() { |
184 expect(file.shortName, 'file.txt'); | 221 expect(file.shortName, 'file.txt'); |
185 } | 222 } |
186 | 223 |
187 void test_toString() { | 224 void test_toString() { |
188 expect(file.toString(), path); | 225 expect(file.toString(), path); |
189 } | 226 } |
190 | 227 |
191 void test_toUri() { | 228 void test_toUri() { |
192 String path = '/foo/file.txt'; | 229 String path = '/foo/file.txt'; |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 | 621 |
585 setUp() { | 622 setUp() { |
586 tempDirectory = io.Directory.systemTemp.createTempSync('test_resource'); | 623 tempDirectory = io.Directory.systemTemp.createTempSync('test_resource'); |
587 tempPath = tempDirectory.absolute.path; | 624 tempPath = tempDirectory.absolute.path; |
588 } | 625 } |
589 | 626 |
590 tearDown() { | 627 tearDown() { |
591 tempDirectory.deleteSync(recursive: true); | 628 tempDirectory.deleteSync(recursive: true); |
592 } | 629 } |
593 } | 630 } |
OLD | NEW |