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

Unified Diff: runtime/observatory/tests/service/dev_fs_test.dart

Issue 2120473004: Reimplement devfs in dart. Implementation now writes to disk. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: code review Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/vmservice/vmservice_io.dart ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/observatory/tests/service/dev_fs_test.dart
diff --git a/runtime/observatory/tests/service/dev_fs_test.dart b/runtime/observatory/tests/service/dev_fs_test.dart
index 8855e133646c63f9fc319a0e60be9fbe9b9533a5..08e5a5e2bac61c247abd9f6fe503799e62ab0adc 100644
--- a/runtime/observatory/tests/service/dev_fs_test.dart
+++ b/runtime/observatory/tests/service/dev_fs_test.dart
@@ -11,17 +11,19 @@ import 'test_helper.dart';
var tests = [
(VM vm) async {
var result = await vm.invokeRpcNoUpgrade('_listDevFS', {});
- expect(result['type'], equals('FSList'));
+ expect(result['type'], equals('FileSystemList'));
expect(result['fsNames'].toString(), equals("[]"));
var params = {
'fsName': 'alpha'
};
result = await vm.invokeRpcNoUpgrade('_createDevFS', params);
- expect(result['type'], equals('Success'));
+ expect(result['type'], equals('FileSystem'));
+ expect(result['name'], equals('alpha'));
+ expect(result['uri'], new isInstanceOf<String>());
result = await vm.invokeRpcNoUpgrade('_listDevFS', {});
- expect(result['type'], equals('FSList'));
+ expect(result['type'], equals('FileSystemList'));
expect(result['fsNames'].toString(), equals('[alpha]'));
bool caughtException;
@@ -39,7 +41,7 @@ var tests = [
expect(result['type'], equals('Success'));
result = await vm.invokeRpcNoUpgrade('_listDevFS', {});
- expect(result['type'], equals('FSList'));
+ expect(result['type'], equals('FileSystemList'));
expect(result['fsNames'].toString(), equals("[]"));
caughtException = false;
@@ -61,10 +63,10 @@ var tests = [
var result;
// Create DevFS.
- result = await vm.invokeRpcNoUpgrade('_createDevFS', {
- 'fsName': fsId
- });
- expect(result['type'], equals('Success'));
+ result = await vm.invokeRpcNoUpgrade('_createDevFS', { 'fsName': fsId });
+ expect(result['type'], equals('FileSystem'));
+ expect(result['name'], equals(fsId));
+ expect(result['uri'], new isInstanceOf<String>());
bool caughtException = false;
try {
@@ -76,9 +78,7 @@ var tests = [
} on ServerRpcException catch(e) {
caughtException = true;
expect(e.code, equals(ServerRpcException.kFileDoesNotExist));
- expect(e.message,
- "_readDevFSFile: file 'dart-devfs://banana//foobar.dat' "
- "does not exist");
+ expect(e.message, startsWith("_readDevFSFile: FileSystemException: "));
}
expect(caughtException, isTrue);
@@ -98,25 +98,29 @@ var tests = [
expect(result['type'], equals('FSFile'));
expect(result['fileContents'], equals(fileContents));
- // Read a malformed path back.
+ // The leading '/' is optional.
+ result = await vm.invokeRpcNoUpgrade('_readDevFSFile', {
+ 'fsName': fsId,
+ 'path': filePath.substring(1),
+ });
+ expect(result['type'], equals('FSFile'));
+ expect(result['fileContents'], equals(fileContents));
+
+ // Read a file outside of the fs.
caughtException = false;
try {
- result = await vm.invokeRpcNoUpgrade('_readDevFSFile', {
- 'fsName': fsId,
- 'path': filePath.substring(1) // Strip the leading '/'.
+ await vm.invokeRpcNoUpgrade('_readDevFSFile', {
+ 'fsName': fsId,
+ 'path': '../foo',
});
+ expect(false, isTrue, reason:'Unreachable');
} on ServerRpcException catch(e) {
caughtException = true;
expect(e.code, equals(ServerRpcException.kInvalidParams));
- expect(e.message,
- "_readDevFSFile: file system path \'foobar.dat\' "
- "must begin with a /");
+ expect(e.message, "_readDevFSFile: invalid 'path' parameter: ../foo");
}
expect(caughtException, isTrue);
- expect(result['type'], equals('FSFile'));
- expect(result['fileContents'], equals(fileContents));
-
// Write a set of files.
result = await vm.invokeRpcNoUpgrade('_writeDevFSFiles', {
'fsName': fsId,
@@ -140,7 +144,7 @@ var tests = [
result = await vm.invokeRpcNoUpgrade('_listDevFSFiles', {
'fsName': fsId,
});
- expect(result['type'], equals('FSFilesList'));
+ expect(result['type'], equals('FSFileList'));
expect(result['files'].length, equals(3));
// Delete DevFS.
« no previous file with comments | « runtime/bin/vmservice/vmservice_io.dart ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698