Index: runtime/observatory/tests/service/get_source_report_test.dart |
diff --git a/runtime/observatory/tests/service/get_source_report_test.dart b/runtime/observatory/tests/service/get_source_report_test.dart |
index 81f21a5bbc657380db03ed627de51bada92c5b87..2fda27670188d47112303bd3c7c41cffa0744967 100644 |
--- a/runtime/observatory/tests/service/get_source_report_test.dart |
+++ b/runtime/observatory/tests/service/get_source_report_test.dart |
@@ -45,115 +45,131 @@ bool allRangesCompiled(coverage) { |
} |
var tests = [ |
- |
-hasStoppedAtBreakpoint, |
- |
-(Isolate isolate) async { |
- var stack = await isolate.getStack(); |
- |
- // Make sure we are in the right place. |
- expect(stack.type, equals('Stack')); |
- expect(stack['frames'].length, greaterThanOrEqualTo(2)); |
- expect(stack['frames'][0].function.name, equals('myFunction')); |
- expect(stack['frames'][0].function.dartOwner.name, equals('MyClass')); |
- |
- var func = stack['frames'][0].function; |
- expect(func.name, equals('myFunction')); |
- await func.load(); |
- |
- var expectedRange = { |
- 'scriptIndex': 0, |
- 'startPos': 39, |
- 'endPos': 88, |
- 'compiled': true, |
- 'coverage': {'hits': [54, 72, 82], 'misses': [60]} |
- }; |
- |
- // Full script |
- var params = { 'reports' : ['Coverage'], |
- 'scriptId' : func.location.script.id }; |
- var coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params); |
- expect(coverage['type'], equals('SourceReport')); |
- expect(coverage['ranges'].length, 6); |
- expect(coverage['ranges'][0], equals(expectedRange)); |
- expect(coverage['scripts'].length, 1); |
- expect(coverage['scripts'][0]['uri'], |
- endsWith('get_source_report_test.dart')); |
- expect(allRangesCompiled(coverage), isFalse); |
- |
- // Force compilation. |
- params = { 'reports' : ['Coverage'], |
- 'scriptId' : func.location.script.id, |
- 'forceCompile' : true }; |
- coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params); |
- expect(coverage['type'], equals('SourceReport')); |
- expect(coverage['ranges'].length, 6); |
- expect(allRangesCompiled(coverage), isTrue); |
- |
- // One function |
- params = { 'reports' : ['Coverage'], |
- 'scriptId' : func.location.script.id, |
- 'tokenPos' : func.location.tokenPos, |
- 'endTokenPos' : func.location.endTokenPos }; |
- coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params); |
- expect(coverage['type'], equals('SourceReport')); |
- expect(coverage['ranges'].length, 1); |
- expect(coverage['ranges'][0], equals(expectedRange)); |
- expect(coverage['scripts'].length, 1); |
- expect(coverage['scripts'][0]['uri'], |
- endsWith('get_source_report_test.dart')); |
- |
- // Full isolate |
- params = { 'reports' : ['Coverage'] }; |
- coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params); |
- expect(coverage['type'], equals('SourceReport')); |
- expect(coverage['ranges'].length, greaterThan(1)); |
- expect(coverage['scripts'].length, greaterThan(1)); |
- |
- // Multiple reports (make sure enum list parameter parsing works). |
- params = { 'reports' : ['_CallSites', 'Coverage', 'PossibleBreakpoints'], |
- 'scriptId' : func.location.script.id, |
- 'tokenPos' : func.location.tokenPos, |
- 'endTokenPos' : func.location.endTokenPos }; |
- coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params); |
- expect(coverage['type'], equals('SourceReport')); |
- expect(coverage['ranges'].length, 1); |
- var range = coverage['ranges'][0]; |
- expect(range.containsKey('callSites'), isTrue); |
- expect(range.containsKey('coverage'), isTrue); |
- expect(range.containsKey('possibleBreakpoints'), isTrue); |
- |
- // missing scriptId with tokenPos. |
- bool caughtException = false; |
- try { |
- params = { 'reports' : ['Coverage'], |
- 'tokenPos' : func.location.tokenPos }; |
+ hasStoppedAtBreakpoint, |
+ (Isolate isolate) async { |
+ var stack = await isolate.getStack(); |
+ |
+ // Make sure we are in the right place. |
+ expect(stack.type, equals('Stack')); |
+ expect(stack['frames'].length, greaterThanOrEqualTo(2)); |
+ expect(stack['frames'][0].function.name, equals('myFunction')); |
+ expect(stack['frames'][0].function.dartOwner.name, equals('MyClass')); |
+ |
+ var func = stack['frames'][0].function; |
+ expect(func.name, equals('myFunction')); |
+ await func.load(); |
+ |
+ var expectedRange = { |
+ 'scriptIndex': 0, |
+ 'startPos': 39, |
+ 'endPos': 88, |
+ 'compiled': true, |
+ 'coverage': { |
+ 'hits': [54, 72, 82], |
+ 'misses': [60] |
+ } |
+ }; |
+ |
+ // Full script |
+ var params = { |
+ 'reports': ['Coverage'], |
+ 'scriptId': func.location.script.id |
+ }; |
+ var coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params); |
+ expect(coverage['type'], equals('SourceReport')); |
+ expect(coverage['ranges'].length, 6); |
+ expect(coverage['ranges'][0], equals(expectedRange)); |
+ expect(coverage['scripts'].length, 1); |
+ expect( |
+ coverage['scripts'][0]['uri'], endsWith('get_source_report_test.dart')); |
+ expect(allRangesCompiled(coverage), isFalse); |
+ |
+ // Force compilation. |
+ params = { |
+ 'reports': ['Coverage'], |
+ 'scriptId': func.location.script.id, |
+ 'forceCompile': true |
+ }; |
coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params); |
- } on ServerRpcException catch(e) { |
- caughtException = true; |
- expect(e.code, equals(ServerRpcException.kInvalidParams)); |
- expect(e.message, |
- "getSourceReport: the 'tokenPos' parameter requires the " |
- "\'scriptId\' parameter"); |
- } |
- expect(caughtException, isTrue); |
- |
- // missing scriptId with endTokenPos. |
- caughtException = false; |
- try { |
- params = { 'reports' : ['Coverage'], |
- 'endTokenPos' : func.location.endTokenPos }; |
+ expect(coverage['type'], equals('SourceReport')); |
+ expect(coverage['ranges'].length, 6); |
+ expect(allRangesCompiled(coverage), isTrue); |
+ |
+ // One function |
+ params = { |
+ 'reports': ['Coverage'], |
+ 'scriptId': func.location.script.id, |
+ 'tokenPos': func.location.tokenPos, |
+ 'endTokenPos': func.location.endTokenPos |
+ }; |
coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params); |
- } on ServerRpcException catch(e) { |
- caughtException = true; |
- expect(e.code, equals(ServerRpcException.kInvalidParams)); |
- expect(e.message, |
- "getSourceReport: the 'endTokenPos' parameter requires the " |
- "\'scriptId\' parameter"); |
- } |
- expect(caughtException, isTrue); |
-}, |
- |
+ expect(coverage['type'], equals('SourceReport')); |
+ expect(coverage['ranges'].length, 1); |
+ expect(coverage['ranges'][0], equals(expectedRange)); |
+ expect(coverage['scripts'].length, 1); |
+ expect( |
+ coverage['scripts'][0]['uri'], endsWith('get_source_report_test.dart')); |
+ |
+ // Full isolate |
+ params = { |
+ 'reports': ['Coverage'] |
+ }; |
+ coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params); |
+ expect(coverage['type'], equals('SourceReport')); |
+ expect(coverage['ranges'].length, greaterThan(1)); |
+ expect(coverage['scripts'].length, greaterThan(1)); |
+ |
+ // Multiple reports (make sure enum list parameter parsing works). |
+ params = { |
+ 'reports': ['_CallSites', 'Coverage', 'PossibleBreakpoints'], |
+ 'scriptId': func.location.script.id, |
+ 'tokenPos': func.location.tokenPos, |
+ 'endTokenPos': func.location.endTokenPos |
+ }; |
+ coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params); |
+ expect(coverage['type'], equals('SourceReport')); |
+ expect(coverage['ranges'].length, 1); |
+ var range = coverage['ranges'][0]; |
+ expect(range.containsKey('callSites'), isTrue); |
+ expect(range.containsKey('coverage'), isTrue); |
+ expect(range.containsKey('possibleBreakpoints'), isTrue); |
+ |
+ // missing scriptId with tokenPos. |
+ bool caughtException = false; |
+ try { |
+ params = { |
+ 'reports': ['Coverage'], |
+ 'tokenPos': func.location.tokenPos |
+ }; |
+ coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params); |
+ } on ServerRpcException catch (e) { |
+ caughtException = true; |
+ expect(e.code, equals(ServerRpcException.kInvalidParams)); |
+ expect( |
+ e.message, |
+ "getSourceReport: the 'tokenPos' parameter requires the " |
+ "\'scriptId\' parameter"); |
+ } |
+ expect(caughtException, isTrue); |
+ |
+ // missing scriptId with endTokenPos. |
+ caughtException = false; |
+ try { |
+ params = { |
+ 'reports': ['Coverage'], |
+ 'endTokenPos': func.location.endTokenPos |
+ }; |
+ coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params); |
+ } on ServerRpcException catch (e) { |
+ caughtException = true; |
+ expect(e.code, equals(ServerRpcException.kInvalidParams)); |
+ expect( |
+ e.message, |
+ "getSourceReport: the 'endTokenPos' parameter requires the " |
+ "\'scriptId\' parameter"); |
+ } |
+ expect(caughtException, isTrue); |
+ }, |
]; |
main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction); |