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

Side by Side Diff: pkg/front_end/test/physical_file_system_test.dart

Issue 2622423003: Simplify PhysicalFileSystem implementation. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « pkg/front_end/lib/physical_file_system.dart ('k') | no next file » | 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) 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 113 }
114 114
115 test_entityForPath_normalize_dotDot() { 115 test_entityForPath_normalize_dotDot() {
116 expect(entityForPath(p.join(tempPath, 'foo', '..', 'file.txt')).uri, 116 expect(entityForPath(p.join(tempPath, 'foo', '..', 'file.txt')).uri,
117 p.toUri(p.join(tempPath, 'file.txt'))); 117 p.toUri(p.join(tempPath, 'file.txt')));
118 } 118 }
119 119
120 test_entityForUri() { 120 test_entityForUri() {
121 expect( 121 expect(
122 PhysicalFileSystem.instance 122 PhysicalFileSystem.instance
123 .entityForUri(Uri.parse('$tempUri/file.txt')) 123 .entityForUri(Uri.parse('${tempUri}file.txt'))
124 .uri, 124 .uri,
125 p.toUri(p.join(tempPath, 'file.txt'))); 125 p.toUri(p.join(tempPath, 'file.txt')));
126 } 126 }
127 127
128 test_entityForUri_bareUri_absolute() { 128 test_entityForUri_bareUri_absolute() {
129 expect(PhysicalFileSystem.instance.entityForUri(Uri.parse('/file.txt')).uri, 129 expect(PhysicalFileSystem.instance.entityForUri(Uri.parse('/file.txt')).uri,
130 p.toUri(p.fromUri('/file.txt'))); 130 p.toUri(p.fromUri('/file.txt')));
131 } 131 }
132 132
133 test_entityForUri_fileUri_relative() { 133 test_entityForUri_fileUri_relative() {
(...skipping 18 matching lines...) Expand all
152 test_entityForUri_nonFileUri() { 152 test_entityForUri_nonFileUri() {
153 expect( 153 expect(
154 () => PhysicalFileSystem.instance 154 () => PhysicalFileSystem.instance
155 .entityForUri(Uri.parse('package:foo/bar.dart')), 155 .entityForUri(Uri.parse('package:foo/bar.dart')),
156 throwsA(new isInstanceOf<Error>())); 156 throwsA(new isInstanceOf<Error>()));
157 } 157 }
158 158
159 test_entityForUri_normalize_dot() { 159 test_entityForUri_normalize_dot() {
160 expect( 160 expect(
161 PhysicalFileSystem.instance 161 PhysicalFileSystem.instance
162 .entityForUri(Uri.parse('$tempUri/./file.txt')) 162 .entityForUri(Uri.parse('${tempUri}./file.txt'))
163 .uri, 163 .uri,
164 p.toUri(p.join(tempPath, 'file.txt'))); 164 p.toUri(p.join(tempPath, 'file.txt')));
165 } 165 }
166 166
167 test_entityForUri_normalize_dotDot() { 167 test_entityForUri_normalize_dotDot() {
168 expect( 168 expect(
169 PhysicalFileSystem.instance 169 PhysicalFileSystem.instance
170 .entityForUri(Uri.parse('$tempUri/foo/../file.txt')) 170 .entityForUri(Uri.parse('${tempUri}foo/../file.txt'))
171 .uri, 171 .uri,
172 p.toUri(p.join(tempPath, 'file.txt'))); 172 p.toUri(p.join(tempPath, 'file.txt')));
173 } 173 }
174 } 174 }
175 175
176 class _BaseTest { 176 class _BaseTest {
177 io.Directory tempDirectory; 177 io.Directory tempDirectory;
178 String tempPath; 178 String tempPath;
179 179
180 FileSystemEntity entityForPath(String path) => 180 FileSystemEntity entityForPath(String path) =>
181 PhysicalFileSystem.instance.entityForUri(p.toUri(path)); 181 PhysicalFileSystem.instance.entityForUri(p.toUri(path));
182 182
183 setUp() { 183 setUp() {
184 tempDirectory = io.Directory.systemTemp.createTempSync('test_file_system'); 184 tempDirectory = io.Directory.systemTemp.createTempSync('test_file_system');
185 tempPath = tempDirectory.absolute.path; 185 tempPath = tempDirectory.absolute.path;
186 } 186 }
187 187
188 tearDown() async { 188 tearDown() async {
189 try { 189 try {
190 tempDirectory.deleteSync(recursive: true); 190 tempDirectory.deleteSync(recursive: true);
191 } on io.FileSystemException { 191 } on io.FileSystemException {
192 // Sometimes on Windows the delete fails with errno 32 192 // Sometimes on Windows the delete fails with errno 32
193 // (ERROR_SHARING_VIOLATION: The process cannot access the file because it 193 // (ERROR_SHARING_VIOLATION: The process cannot access the file because it
194 // is being used by another process). Wait 1 second and try again. 194 // is being used by another process). Wait 1 second and try again.
195 await new Future.delayed(new Duration(seconds: 1)); 195 await new Future.delayed(new Duration(seconds: 1));
196 tempDirectory.deleteSync(recursive: true); 196 tempDirectory.deleteSync(recursive: true);
197 } 197 }
198 } 198 }
199 } 199 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/physical_file_system.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698