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

Side by Side Diff: pkg/analyzer/test/file_system/physical_resource_provider_test.dart

Issue 2239303004: Normalize paths in PhysicalResourceProvider.getFile()/getFolder(). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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
OLDNEW
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
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_toUri() {
184 String path = '/foo/file.txt';
185 File file = PhysicalResourceProvider.INSTANCE.getFile(path);
186 expect(file.toUri(), new Uri.file(path));
187 }
188
189 void test_shortName() { 183 void test_shortName() {
190 expect(file.shortName, 'file.txt'); 184 expect(file.shortName, 'file.txt');
191 } 185 }
192 186
193 void test_toString() { 187 void test_toString() {
194 expect(file.toString(), path); 188 expect(file.toString(), path);
195 } 189 }
196 190
191 void test_toUri() {
192 String path = '/foo/file.txt';
193 File file = PhysicalResourceProvider.INSTANCE.getFile(path);
194 expect(file.toUri(), new Uri.file(path));
195 }
196
197 void test_writeAsBytesSync() { 197 void test_writeAsBytesSync() {
198 new io.File(path).writeAsBytesSync(<int>[1, 2]); 198 new io.File(path).writeAsBytesSync(<int>[1, 2]);
199 expect(file.readAsBytesSync(), <int>[1, 2]); 199 expect(file.readAsBytesSync(), <int>[1, 2]);
200 // write new bytes 200 // write new bytes
201 file.writeAsBytesSync(<int>[10, 20]); 201 file.writeAsBytesSync(<int>[10, 20]);
202 expect(file.readAsBytesSync(), <int>[10, 20]); 202 expect(file.readAsBytesSync(), <int>[10, 20]);
203 } 203 }
204 } 204 }
205 205
206 @reflectiveTest 206 @reflectiveTest
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 382
383 void test_toUri() { 383 void test_toUri() {
384 String path = '/foo/directory'; 384 String path = '/foo/directory';
385 Folder folder = PhysicalResourceProvider.INSTANCE.getFolder(path); 385 Folder folder = PhysicalResourceProvider.INSTANCE.getFolder(path);
386 expect(folder.toUri(), new Uri.directory(path)); 386 expect(folder.toUri(), new Uri.directory(path));
387 } 387 }
388 } 388 }
389 389
390 @reflectiveTest 390 @reflectiveTest
391 class PhysicalResourceProviderTest extends _BaseTest { 391 class PhysicalResourceProviderTest extends _BaseTest {
392 test_getFolder_trailingSeparator() {
393 String path = tempPath;
394 PhysicalResourceProvider provider = PhysicalResourceProvider.INSTANCE;
395 Folder folder = provider.getFolder('$path$separator');
396 expect(folder.path, path);
397 }
398
392 test_getModificationTimes() async { 399 test_getModificationTimes() async {
393 PhysicalResourceProvider provider = PhysicalResourceProvider.INSTANCE; 400 PhysicalResourceProvider provider = PhysicalResourceProvider.INSTANCE;
394 String path = join(tempPath, 'file1.txt'); 401 String path = join(tempPath, 'file1.txt');
395 new io.File(path).writeAsStringSync(''); 402 new io.File(path).writeAsStringSync('');
396 Source source = provider.getFile(path).createSource(); 403 Source source = provider.getFile(path).createSource();
397 List<int> times = await provider.getModificationTimes([source]); 404 List<int> times = await provider.getModificationTimes([source]);
398 expect(times, [source.modificationStamp]); 405 expect(times, [source.modificationStamp]);
399 } 406 }
400 407
401 void test_getStateLocation_uniqueness() { 408 void test_getStateLocation_uniqueness() {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 572
566 setUp() { 573 setUp() {
567 tempDirectory = io.Directory.systemTemp.createTempSync('test_resource'); 574 tempDirectory = io.Directory.systemTemp.createTempSync('test_resource');
568 tempPath = tempDirectory.absolute.path; 575 tempPath = tempDirectory.absolute.path;
569 } 576 }
570 577
571 tearDown() { 578 tearDown() {
572 tempDirectory.deleteSync(recursive: true); 579 tempDirectory.deleteSync(recursive: true);
573 } 580 }
574 } 581 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698