OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 // SharedOptions=--supermixin | 4 // SharedOptions=--supermixin |
5 | 5 |
6 library front_end.test.physical_file_system_test; | 6 library front_end.test.physical_file_system_test; |
7 | 7 |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'dart:convert'; | 9 import 'dart:convert'; |
10 import 'dart:io' as io; | 10 import 'dart:io' as io; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 test_exists_fileExists() async { | 90 test_exists_fileExists() async { |
91 new io.File(path).writeAsStringSync('contents'); | 91 new io.File(path).writeAsStringSync('contents'); |
92 expect(await file.exists(), isTrue); | 92 expect(await file.exists(), isTrue); |
93 } | 93 } |
94 | 94 |
95 test_hashCode_samePath() { | 95 test_hashCode_samePath() { |
96 expect(file.hashCode, entityForPath(p.join(tempPath, 'file.txt')).hashCode); | 96 expect(file.hashCode, entityForPath(p.join(tempPath, 'file.txt')).hashCode); |
97 } | 97 } |
98 | 98 |
99 test_lastModified_doesNotExist() { | |
100 expect(file.lastModified(), _throwsFileSystemException); | |
101 } | |
102 | |
103 test_lastModified_increasesOnEachChange() async { | |
104 new io.File(path).writeAsStringSync('contents1'); | |
105 var mod1 = await file.lastModified(); | |
106 | |
107 // Pause to ensure the file-system time-stamps are different. | |
108 await new Future.delayed(new Duration(seconds: 1)); | |
109 new io.File(path).writeAsStringSync('contents2'); | |
110 var mod2 = await file.lastModified(); | |
111 expect(mod2.isAfter(mod1), isTrue); | |
112 | |
113 await new Future.delayed(new Duration(seconds: 1)); | |
114 var path2 = p.join(tempPath, 'file2.txt'); | |
115 new io.File(path2).writeAsStringSync('contents2'); | |
116 var file2 = entityForPath(path2); | |
117 var mod3 = await file2.lastModified(); | |
118 expect(mod3.isAfter(mod2), isTrue); | |
119 } | |
120 | |
121 test_readAsBytes_badUtf8() async { | 99 test_readAsBytes_badUtf8() async { |
122 // A file containing invalid UTF-8 can still be read as raw bytes. | 100 // A file containing invalid UTF-8 can still be read as raw bytes. |
123 List<int> bytes = [0xc0, 0x40]; // Invalid UTF-8 | 101 List<int> bytes = [0xc0, 0x40]; // Invalid UTF-8 |
124 new io.File(path).writeAsBytesSync(bytes); | 102 new io.File(path).writeAsBytesSync(bytes); |
125 expect(await file.readAsBytes(), bytes); | 103 expect(await file.readAsBytes(), bytes); |
126 } | 104 } |
127 | 105 |
128 test_readAsBytes_doesNotExist() { | 106 test_readAsBytes_doesNotExist() { |
129 expect(file.readAsBytes(), _throwsFileSystemException); | 107 expect(file.readAsBytes(), _throwsFileSystemException); |
130 } | 108 } |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 tempDirectory.deleteSync(recursive: true); | 241 tempDirectory.deleteSync(recursive: true); |
264 } on io.FileSystemException { | 242 } on io.FileSystemException { |
265 // Sometimes on Windows the delete fails with errno 32 | 243 // Sometimes on Windows the delete fails with errno 32 |
266 // (ERROR_SHARING_VIOLATION: The process cannot access the file because it | 244 // (ERROR_SHARING_VIOLATION: The process cannot access the file because it |
267 // is being used by another process). Wait 1 second and try again. | 245 // is being used by another process). Wait 1 second and try again. |
268 await new Future.delayed(new Duration(seconds: 1)); | 246 await new Future.delayed(new Duration(seconds: 1)); |
269 tempDirectory.deleteSync(recursive: true); | 247 tempDirectory.deleteSync(recursive: true); |
270 } | 248 } |
271 } | 249 } |
272 } | 250 } |
OLD | NEW |