diff --git a/pkg/vm_service/test/analysis_options.yaml b/pkg/vm_service/test/analysis_options.yaml index 78d0caee85e..f497c423f6a 100644 --- a/pkg/vm_service/test/analysis_options.yaml +++ b/pkg/vm_service/test/analysis_options.yaml @@ -14,16 +14,16 @@ analyzer: linter: rules: - # always_declare_return_types: true - # avoid_escaping_inner_quotes: true - # avoid_void_async: true - # cancel_subscriptions: true - # close_sinks: true + always_declare_return_types: true + avoid_escaping_inner_quotes: true + avoid_void_async: true + cancel_subscriptions: true + close_sinks: true constant_identifier_names: false # Disabled for LINE_N style constants in tests directives_ordering: true - # no_adjacent_strings_in_list: true - # prefer_final_locals: true - # prefer_void_to_null: true - # require_trailing_commas: true - # unnecessary_parenthesis: true - # unnecessary_raw_strings: true + no_adjacent_strings_in_list: true + prefer_final_locals: true + prefer_void_to_null: true + require_trailing_commas: true + unnecessary_parenthesis: true + unnecessary_raw_strings: true diff --git a/pkg/vm_service/test/async_generator_breakpoint_test.dart b/pkg/vm_service/test/async_generator_breakpoint_test.dart index 4cd8d24c872..e812fbd9383 100644 --- a/pkg/vm_service/test/async_generator_breakpoint_test.dart +++ b/pkg/vm_service/test/async_generator_breakpoint_test.dart @@ -89,7 +89,7 @@ Future testAsync(VmService service, IsolateRef isolateRef) async { unawaited( service.evaluate(isolateId, lib.id!, 'testerReady = true').then( (Response result) async { - Obj res = + final Obj res = await service.getObject(isolateId, (result as InstanceRef).id!); print(res); expect((res as Instance).valueAsString, equals('true')); @@ -114,7 +114,7 @@ Future testAsync(VmService service, IsolateRef isolateRef) async { final tests = [testAsync]; -main([args = const []]) => runIsolateTests( +void main([args = const []]) => runIsolateTests( args, tests, 'async_generator_breakpoint_test.dart', diff --git a/pkg/vm_service/test/async_next_regression_18877_test.dart b/pkg/vm_service/test/async_next_regression_18877_test.dart index 7aadec2eae9..42ae90d1b4d 100644 --- a/pkg/vm_service/test/async_next_regression_18877_test.dart +++ b/pkg/vm_service/test/async_next_regression_18877_test.dart @@ -20,9 +20,9 @@ const LINE_B = 34; const LINE_C = 35; // AUTOGENERATED END -foo() async {} +Future foo() async {} -doAsync(stop) async { +Future doAsync(stop) async { // Flutter issue 18877: // If a closure is defined in the context of an async method, stepping over // an await causes the implicit breakpoint to be set for that closure instead @@ -34,10 +34,9 @@ doAsync(stop) async { await foo(); // LINE_B await foo(); // LINE_C baz(); - return null; } -testMain() { +void testMain() { // With two runs of doAsync floating around, async step should only cause // us to stop in the run we started in. doAsync(false); diff --git a/pkg/vm_service/test/async_next_test.dart b/pkg/vm_service/test/async_next_test.dart index 9678f50c6c7..d6652abc240 100644 --- a/pkg/vm_service/test/async_next_test.dart +++ b/pkg/vm_service/test/async_next_test.dart @@ -7,29 +7,36 @@ import 'dart:developer'; import 'common/service_test_common.dart'; import 'common/test_helper.dart'; -const int LINE_D = 18; -const int LINE_A = 19; -const int LINE_B = 20; -const int LINE_C = 21; +// AUTOGENERATED START +// +// Update these constants by running: +// +// dart pkg/vm_service/test/update_line_numbers.dart +// +const LINE_D = 25; +const LINE_A = 26; +const LINE_B = 27; +const LINE_C = 28; +// AUTOGENERATED END -foo() async {} +Future foo() async {} -doAsync(stop) async { - if (stop) debugger(); - await foo(); // Line A. - await foo(); // Line B. - await foo(); // Line C. - return null; +Future doAsync(bool stop) async { + if (stop) debugger(); // LINE_D + await foo(); // LINE_A + await foo(); // LINE_B + await foo(); // LINE_C + return; } -testMain() { +void testMain() { // With two runs of doAsync floating around, async step should only cause // us to stop in the run we started in. doAsync(false); doAsync(true); } -var tests = [ +final tests = [ hasStoppedAtBreakpoint, stoppedAtLine(LINE_D), stepOver, // foo() @@ -45,7 +52,7 @@ var tests = [ resumeIsolate, ]; -main([args = const []]) => runIsolateTests( +void main([args = const []]) => runIsolateTests( args, tests, 'async_next_test.dart', diff --git a/pkg/vm_service/test/async_scope_test.dart b/pkg/vm_service/test/async_scope_test.dart index f72311b9b45..f378959d18c 100644 --- a/pkg/vm_service/test/async_scope_test.dart +++ b/pkg/vm_service/test/async_scope_test.dart @@ -10,25 +10,34 @@ import 'package:vm_service/vm_service.dart'; import 'common/service_test_common.dart'; import 'common/test_helper.dart'; -const int LINE_A = 20; -const int LINE_B = 26; +// AUTOGENERATED START +// +// Update these constants by running: +// +// dart pkg/vm_service/test/update_line_numbers.dart +// +const LINE_A = 28; +const LINE_B = 35; +const LINE_C = 40; +// AUTOGENERATED END -foo() {} +void foo() {} -doAsync(param1) async { - var local1 = param1 + 1; - foo(); // Line A. +Future doAsync(int param1) async { + final local1 = param1 + 1; + foo(); // LINE_A + // ignore: await_only_futures await local1; } -doAsyncStar(param2) async* { - var local2 = param2 + 1; - foo(); // Line B. +Stream doAsyncStar(int param2) async* { + final local2 = param2 + 1; + foo(); // LINE_B yield local2; } -testeeDo() { - debugger(); +void testeeDo() { + debugger(); // LINE_C doAsync(1).then((_) { doAsyncStar(1).listen((_) {}); @@ -36,9 +45,11 @@ testeeDo() { } Future checkAsyncVarDescriptors( - VmService? service, IsolateRef? isolateRef) async { - final isolateId = isolateRef!.id!; - final stack = await service!.getStack(isolateId); + VmService service, + IsolateRef isolateRef, +) async { + final isolateId = isolateRef.id!; + final stack = await service.getStack(isolateId); expect(stack.frames!.length, greaterThanOrEqualTo(1)); final frame = stack.frames![0]; final vars = frame.vars!.map((v) => v.name).join(' '); @@ -46,33 +57,34 @@ Future checkAsyncVarDescriptors( } Future checkAsyncStarVarDescriptors( - VmService? service, IsolateRef? isolateRef) async { - final isolateId = isolateRef!.id!; - final stack = await service!.getStack(isolateId); + VmService service, + IsolateRef isolateRef, +) async { + final isolateId = isolateRef.id!; + final stack = await service.getStack(isolateId); expect(stack.frames!.length, greaterThanOrEqualTo(1)); final frame = stack.frames![0]; final vars = frame.vars!.map((v) => v.name).join(' '); expect(vars, 'param2 local2'); // no :async_op et al } -var tests = [ - hasStoppedAtBreakpoint, // debugger() +final tests = [ + hasStoppedAtBreakpoint, + stoppedAtLine(LINE_C), setBreakpointAtLine(LINE_A), setBreakpointAtLine(LINE_B), resumeIsolate, - hasStoppedAtBreakpoint, stoppedAtLine(LINE_A), checkAsyncVarDescriptors, resumeIsolate, - hasStoppedAtBreakpoint, stoppedAtLine(LINE_B), checkAsyncStarVarDescriptors, resumeIsolate, ]; -main([args = const []]) => runIsolateTests( +Future main([args = const []]) => runIsolateTests( args, tests, 'async_scope_test.dart', diff --git a/pkg/vm_service/test/async_single_step_exception_test.dart b/pkg/vm_service/test/async_single_step_exception_test.dart index 133ab416703..c565a2dc8d1 100644 --- a/pkg/vm_service/test/async_single_step_exception_test.dart +++ b/pkg/vm_service/test/async_single_step_exception_test.dart @@ -6,21 +6,28 @@ import 'dart:developer'; import 'common/service_test_common.dart'; import 'common/test_helper.dart'; -const LINE_A = 19; -const LINE_B = 20; -const LINE_0 = 24; -const LINE_C = 25; -const LINE_D = 27; -const LINE_E = 30; -const LINE_F = 33; -const LINE_G = 35; +// AUTOGENERATED START +// +// Update these constants by running: +// +// dart pkg/vm_service/test/update_line_numbers.dart +// +const LINE_A = 26; +const LINE_B = 27; +const LINE_0 = 31; +const LINE_C = 32; +const LINE_D = 34; +const LINE_E = 37; +const LINE_F = 40; +const LINE_G = 42; +// AUTOGENERATED END -helper() async { +Future helper() async { print('helper'); // LINE_A. throw 'a'; // LINE_B. } -testMain() async { +Future testMain() async { debugger(); // LINE_0. print('mmmmm'); // LINE_C. try { @@ -35,7 +42,7 @@ testMain() async { print('z'); // LINE_G. } -var tests = [ +final tests = [ hasStoppedAtBreakpoint, stoppedAtLine(LINE_0), // debugger stepOver, @@ -73,10 +80,10 @@ var tests = [ hasStoppedAtBreakpoint, stoppedAtLine(LINE_G), // print(z) - resumeIsolate + resumeIsolate, ]; -main([args = const []]) => runIsolateTests( +void main([args = const []]) => runIsolateTests( args, tests, 'async_single_step_exception_test.dart', diff --git a/pkg/vm_service/test/async_single_step_into_test.dart b/pkg/vm_service/test/async_single_step_into_test.dart index 88cbe1ceab6..b5399b88a33 100644 --- a/pkg/vm_service/test/async_single_step_into_test.dart +++ b/pkg/vm_service/test/async_single_step_into_test.dart @@ -6,21 +6,28 @@ import 'dart:developer'; import 'common/service_test_common.dart'; import 'common/test_helper.dart'; -const LINE_A = 16; -const LINE_B = 17; -const LINE_0 = 21; -const LINE_C = 22; -const LINE_D = 23; +// AUTOGENERATED START +// +// Update these constants by running: +// +// dart pkg/vm_service/test/update_line_numbers.dart +// +const LINE_A = 23; +const LINE_B = 24; +const LINE_0 = 28; +const LINE_C = 29; +const LINE_D = 30; +// AUTOGENERATED END -helper() async { +Future helper() async { print('helper'); // LINE_A. print('foobar'); // LINE_B. } -testMain() { +Future testMain() async { debugger(); // LINE_0. print('mmmmm'); // LINE_C. - helper(); // LINE_D. + await helper(); // LINE_D. print('z'); } @@ -42,10 +49,10 @@ var tests = [ hasStoppedAtBreakpoint, stoppedAtLine(LINE_B), - resumeIsolate + resumeIsolate, ]; -main([args = const []]) => runIsolateTestsSynchronous( +void main([args = const []]) => runIsolateTests( args, tests, 'async_single_step_into_test.dart', diff --git a/pkg/vm_service/test/async_single_step_out_test.dart b/pkg/vm_service/test/async_single_step_out_test.dart index c65ab976529..935c13d07d3 100644 --- a/pkg/vm_service/test/async_single_step_out_test.dart +++ b/pkg/vm_service/test/async_single_step_out_test.dart @@ -6,26 +6,33 @@ import 'dart:developer'; import 'common/service_test_common.dart'; import 'common/test_helper.dart'; -const LINE_A = 17; -const LINE_B = 18; -const LINE_0 = 22; -const LINE_C = 23; -const LINE_D = 24; -const LINE_E = 25; +// AUTOGENERATED START +// +// Update these constants by running: +// +// dart pkg/vm_service/test/update_line_numbers.dart +// +const LINE_A = 24; +const LINE_B = 25; +const LINE_0 = 29; +const LINE_C = 30; +const LINE_D = 31; +const LINE_E = 32; +// AUTOGENERATED END -helper() async { +Future helper() async { print('helper'); // LINE_A. - return null; // LINE_B. + return; // LINE_B. } -testMain() async { +Future testMain() async { debugger(); // LINE_0. print('mmmmm'); // LINE_C. await helper(); // LINE_D. print('z'); // LINE_E. } -var tests = [ +final tests = [ hasStoppedAtBreakpoint, stoppedAtLine(LINE_0), // debugger stepOver, @@ -51,10 +58,10 @@ var tests = [ hasStoppedAtBreakpoint, stoppedAtLine(LINE_E), // arrive after the await. - resumeIsolate + resumeIsolate, ]; -main([args = const []]) => runIsolateTests( +void main([args = const []]) => runIsolateTests( args, tests, 'async_single_step_out_test.dart', diff --git a/pkg/vm_service/test/async_star_single_step_into_test.dart b/pkg/vm_service/test/async_star_single_step_into_test.dart index 2c9f3c1951d..7d207b406a7 100644 --- a/pkg/vm_service/test/async_star_single_step_into_test.dart +++ b/pkg/vm_service/test/async_star_single_step_into_test.dart @@ -6,39 +6,45 @@ import 'dart:developer'; import 'common/service_test_common.dart'; import 'common/test_helper.dart'; -const LINE_A = 21; -const LINE_B = 22; -const LINE_C = 26; -const LINE_D = 30; -const LINE_E = 36; -const LINE_F = 37; -const LINE_G = 28; +// AUTOGENERATED START +// +// Update these constants by running: +// +// dart pkg/vm_service/test/update_line_numbers.dart +// +const LINE_A = 27; +const LINE_B = 28; +const LINE_C = 32; +const LINE_G = 34; +const LINE_0 = 35; +const LINE_D = 36; +const LINE_1 = 41; +const LINE_E = 42; +const LINE_F = 43; +// AUTOGENERATED END -const LINE_0 = 29; -const LINE_1 = 35; - -foobar() async* { - yield 1; // LINE_A. - yield 2; // LINE_B. +Stream foobar() async* { + yield 1; // LINE_A + yield 2; // LINE_B } -helper() async { - print('helper'); // LINE_C. +Future helper() async { + print('helper'); // LINE_C // ignore: unused_local_variable - await for (var i in foobar()) /* LINE_G. */ { - debugger(); // LINE_0. - print('loop'); // LINE_D. + await for (var i in foobar()) /* LINE_G */ { + debugger(); // LINE_0 + print('loop'); // LINE_D } } -testMain() { - debugger(); // LINE_1. - print('mmmmm'); // LINE_E. - helper(); // LINE_F. +Future testMain() async { + debugger(); // LINE_1 + print('mmmmm'); // LINE_E + await helper(); // LINE_F print('z'); } -var tests = [ +final tests = [ hasStoppedAtBreakpoint, stoppedAtLine(LINE_1), stepOver, // debugger. @@ -86,7 +92,7 @@ var tests = [ resumeIsolate, ]; -main([args = const []]) => runIsolateTestsSynchronous( +void main([args = const []]) => runIsolateTests( args, tests, 'async_star_single_step_into_test.dart', diff --git a/pkg/vm_service/test/async_star_step_out_test.dart b/pkg/vm_service/test/async_star_step_out_test.dart index d1193232e45..4f6e3d5bbe7 100644 --- a/pkg/vm_service/test/async_star_step_out_test.dart +++ b/pkg/vm_service/test/async_star_step_out_test.dart @@ -6,42 +6,48 @@ import 'dart:developer'; import 'common/service_test_common.dart'; import 'common/test_helper.dart'; -const LINE_A = 23; -const LINE_B = 24; -const LINE_C = 28; -const LINE_D = 32; -const LINE_E = 39; -const LINE_F = 40; -const LINE_G = 41; -const LINE_H = 30; -const LINE_I = 34; +// AUTOGENERATED START +// +// Update these constants by running: +// +// dart pkg/vm_service/test/update_line_numbers.dart +// +const LINE_A = 29; +const LINE_B = 30; +const LINE_C = 34; +const LINE_H = 36; +const LINE_0 = 37; +const LINE_D = 38; +const LINE_I = 40; +const LINE_1 = 44; +const LINE_E = 45; +const LINE_F = 46; +const LINE_G = 47; +// AUTOGENERATED END -const LINE_0 = 30; -const LINE_1 = 38; - -foobar() async* { +Stream foobar() async* { yield 1; // LINE_A. yield 2; // LINE_B. } -helper() async { +Future helper() async { print('helper'); // LINE_C. // ignore: unused_local_variable await for (var i in foobar()) /* LINE_H */ { debugger(); // LINE_0 print('loop'); // LINE_D. } - return null; // LINE_I. + return; // LINE_I. } -testMain() { +Future testMain() async { debugger(); // LINE_1 print('mmmmm'); // LINE_E. - helper(); // LINE_F. + await helper(); // LINE_F. print('z'); // LINE_G. } -var tests = [ +final tests = [ hasStoppedAtBreakpoint, stoppedAtLine(LINE_1), stepOver, // debugger. @@ -110,7 +116,7 @@ var tests = [ stoppedAtLine(LINE_I), // return null. ]; -main([args = const []]) => runIsolateTestsSynchronous( +void main([args = const []]) => runIsolateTests( args, tests, 'async_star_step_out_test.dart', diff --git a/pkg/vm_service/test/async_step_out_test.dart b/pkg/vm_service/test/async_step_out_test.dart index 4c7214620de..843419c753f 100644 --- a/pkg/vm_service/test/async_step_out_test.dart +++ b/pkg/vm_service/test/async_step_out_test.dart @@ -6,29 +6,35 @@ import 'dart:developer'; import 'common/service_test_common.dart'; import 'common/test_helper.dart'; -const LINE_A = 19; -const LINE_B = 20; -const LINE_C = 21; -const LINE_D = 26; -const LINE_E = 27; -const LINE_F = 28; +// AUTOGENERATED START +// +// Update these constants by running: +// +// dart pkg/vm_service/test/update_line_numbers.dart +// +const LINE_A = 25; +const LINE_B = 26; +const LINE_C = 27; +const LINE_0 = 31; +const LINE_D = 32; +const LINE_E = 33; +const LINE_F = 34; +// AUTOGENERATED END -const LINE_0 = 25; - -helper() async { +Future helper() async { await null; // LINE_A. print('helper'); // LINE_B. print('foobar'); // LINE_C. } -testMain() async { +Future testMain() async { debugger(); // LINE_0. print('mmmmm'); // LINE_D. await helper(); // LINE_E. print('z'); // LINE_F. } -var tests = [ +final tests = [ hasStoppedAtBreakpoint, stoppedAtLine(LINE_0), stepOver, // debugger. @@ -57,7 +63,7 @@ var tests = [ stoppedAtLine(LINE_F), ]; -main([args = const []]) => runIsolateTests( +void main([args = const []]) => runIsolateTests( args, tests, 'async_step_out_test.dart', diff --git a/pkg/vm_service/test/awaiter_async_stack_contents_2_test.dart b/pkg/vm_service/test/awaiter_async_stack_contents_2_test.dart index 4c9fb0f23d3..566952321ba 100644 --- a/pkg/vm_service/test/awaiter_async_stack_contents_2_test.dart +++ b/pkg/vm_service/test/awaiter_async_stack_contents_2_test.dart @@ -11,36 +11,42 @@ import 'package:vm_service/vm_service.dart'; import 'common/service_test_common.dart'; import 'common/test_helper.dart'; -const LINE_A = 30; -const LINE_B = 36; -const LINE_C = 40; +// AUTOGENERATED START +// +// Update these constants by running: +// +// dart pkg/vm_service/test/update_line_numbers.dart +// +const LINE_0 = 35; +const LINE_A = 36; +const LINE_B = 42; +const LINE_C = 46; +// AUTOGENERATED END -const LINE_0 = 29; - -notCalled() async { +Future notCalled() async { await null; await null; await null; await null; } -foobar() async { +Future foobar() async { await null; debugger(); // LINE_0. print('foobar'); // LINE_A. } -helper() async { +Future helper() async { await null; print('helper'); await foobar(); // LINE_B. } -testMain() async { - helper(); // LINE_C. +Future testMain() async { + await helper(); // LINE_C. } -var tests = [ +final tests = [ hasStoppedAtBreakpoint, stoppedAtLine(LINE_0), stepOver, @@ -49,9 +55,9 @@ var tests = [ (VmService service, IsolateRef isolate) async { final isolateId = isolate.id!; // Verify awaiter stack trace is the current frame + the awaiter. - Stack stack = await service.getStack(isolateId); + final Stack stack = await service.getStack(isolateId); expect(stack.asyncCausalFrames, isNotNull); - List asyncCausalFrames = stack.asyncCausalFrames!; + final List asyncCausalFrames = stack.asyncCausalFrames!; expect(asyncCausalFrames.length, greaterThanOrEqualTo(4)); expect(asyncCausalFrames[0].function!.name, 'foobar'); expect(asyncCausalFrames[1].kind, FrameKind.kAsyncSuspensionMarker); @@ -60,7 +66,7 @@ var tests = [ }, ]; -main(args) => runIsolateTestsSynchronous( +void main([args = const []]) => runIsolateTests( args, tests, 'awaiter_async_stack_contents_2_test.dart', diff --git a/pkg/vm_service/test/awaiter_async_stack_contents_test.dart b/pkg/vm_service/test/awaiter_async_stack_contents_test.dart index 77d21851628..772be90af85 100644 --- a/pkg/vm_service/test/awaiter_async_stack_contents_test.dart +++ b/pkg/vm_service/test/awaiter_async_stack_contents_test.dart @@ -11,41 +11,47 @@ import 'package:vm_service/vm_service.dart'; import 'common/service_test_common.dart'; import 'common/test_helper.dart'; -const LINE_C = 26; -const LINE_A = 32; -const LINE_B = 38; -const LINE_D = 33; +// AUTOGENERATED START +// +// Update these constants by running: +// +// dart pkg/vm_service/test/update_line_numbers.dart +// +const LINE_0 = 31; +const LINE_C = 32; +const LINE_1 = 37; +const LINE_A = 38; +const LINE_D = 39; +const LINE_2 = 43; +const LINE_B = 44; +// AUTOGENERATED END -const LINE_0 = 25; -const LINE_1 = 31; -const LINE_2 = 37; - -foobar() async { +Future foobar() async { await null; debugger(); // LINE_0. print('foobar'); // LINE_C. } -helper() async { +Future helper() async { await null; debugger(); // LINE_1. print('helper'); // LINE_A. await foobar(); // LINE_D } -testMain() { +Future testMain() async { debugger(); // LINE_2. - helper(); // LINE_B. + await helper(); // LINE_B. } -var tests = [ +final tests = [ hasStoppedAtBreakpoint, stoppedAtLine(LINE_2), stepOver, hasStoppedAtBreakpoint, stoppedAtLine(LINE_B), (VmService service, IsolateRef isolateRef) async { - Stack stack = await service.getStack(isolateRef.id!); + final Stack stack = await service.getStack(isolateRef.id!); // No awaiter frames because we are in a completely synchronous stack. expect(stack.asyncCausalFrames, isNull); }, @@ -63,9 +69,9 @@ var tests = [ stoppedAtLine(LINE_C), (VmService service, IsolateRef isolateRef) async { // Verify awaiter stack trace is the current frame + the awaiter. - Stack stack = await service.getStack(isolateRef.id!); + final Stack stack = await service.getStack(isolateRef.id!); expect(stack.asyncCausalFrames, isNotNull); - List asyncCausalFrames = stack.asyncCausalFrames!; + final List asyncCausalFrames = stack.asyncCausalFrames!; expect(asyncCausalFrames.length, greaterThanOrEqualTo(4)); expect(asyncCausalFrames[0].function!.name, 'foobar'); @@ -76,7 +82,7 @@ var tests = [ }, ]; -main(args) => runIsolateTestsSynchronous( +void main([args = const []]) => runIsolateTests( args, tests, 'awaiter_async_stack_contents_test.dart', diff --git a/pkg/vm_service/test/branch_coverage_test.dart b/pkg/vm_service/test/branch_coverage_test.dart index 03b790d2f38..4d312021d8b 100644 --- a/pkg/vm_service/test/branch_coverage_test.dart +++ b/pkg/vm_service/test/branch_coverage_test.dart @@ -83,8 +83,8 @@ var tests = [ 'compiled': true, 'branchCoverage': { 'hits': [], - 'misses': [397, 426, 444, 474, 507] - } + 'misses': [397, 426, 444, 474, 507], + }, }, reportLines: false, ), @@ -96,8 +96,8 @@ var tests = [ 'compiled': true, 'branchCoverage': { 'hits': [], - 'misses': [11, 12, 13, 15, 18] - } + 'misses': [11, 12, 13, 15, 18], + }, }, reportLines: true, ), @@ -111,8 +111,8 @@ var tests = [ 'compiled': true, 'branchCoverage': { 'hits': [397, 426, 474], - 'misses': [444, 507] - } + 'misses': [444, 507], + }, }, reportLines: false, ), @@ -124,14 +124,14 @@ var tests = [ 'compiled': true, 'branchCoverage': { 'hits': [11, 12, 15], - 'misses': [13, 18] - } + 'misses': [13, 18], + }, }, reportLines: true, ), ]; -main([args = const []]) => runIsolateTests( +Future main([args = const []]) => runIsolateTests( args, tests, 'branch_coverage_test.dart', diff --git a/pkg/vm_service/test/break_on_dart_colon_test.dart b/pkg/vm_service/test/break_on_dart_colon_test.dart index 846438ce2fb..7c6cca60e5f 100644 --- a/pkg/vm_service/test/break_on_dart_colon_test.dart +++ b/pkg/vm_service/test/break_on_dart_colon_test.dart @@ -13,7 +13,7 @@ import 'common/test_helper.dart'; // Line in core/print.dart const int LINE_A = 19; -testMain() { +void testMain() { debugger(); print('1'); print('2'); @@ -46,7 +46,7 @@ final tests = [ resumeIsolate, ]; -main(args) => runIsolateTests( +void main([args = const []]) => runIsolateTests( args, tests, 'break_on_dart_colon_test.dart', diff --git a/pkg/vm_service/test/break_on_default_constructor_test.dart b/pkg/vm_service/test/break_on_default_constructor_test.dart index 08df388eabc..ac3a1bb5a28 100644 --- a/pkg/vm_service/test/break_on_default_constructor_test.dart +++ b/pkg/vm_service/test/break_on_default_constructor_test.dart @@ -10,7 +10,7 @@ import 'common/test_helper.dart'; class Foo {} -code() { +void code() { Foo(); } @@ -53,8 +53,7 @@ final tests = [ await service.addBreakpointAtEntry(isolateId, fooFunc.id!); fail('Successfully added breakpoint at an invalid location!'); } on RPCError catch (e) { - // TODO(bkonyi): add this error code to package:vm_service - expect(e.code, 102); + expect(e.code, RPCErrorKind.kCannotAddBreakpoint.code); expect(e.message, 'Cannot add breakpoint'); expect(e.details, contains('Cannot add breakpoint at function')); } @@ -63,13 +62,11 @@ final tests = [ }, ]; -void main(List args) { - runIsolateTestsSynchronous( - args, - tests, - 'break_on_default_constructor_test.dart', - testeeConcurrent: code, - pauseOnStart: true, - pauseOnExit: true, - ); -} +void main([args = const []]) => runIsolateTests( + args, + tests, + 'break_on_default_constructor_test.dart', + testeeConcurrent: code, + pauseOnStart: true, + pauseOnExit: true, + ); diff --git a/pkg/vm_service/test/break_on_function_many_child_isolates_test.dart b/pkg/vm_service/test/break_on_function_many_child_isolates_test.dart index 10282e8f85a..950ace46506 100644 --- a/pkg/vm_service/test/break_on_function_many_child_isolates_test.dart +++ b/pkg/vm_service/test/break_on_function_many_child_isolates_test.dart @@ -17,9 +17,16 @@ import 'package:vm_service/vm_service.dart'; import 'common/service_test_common.dart'; import 'common/test_helper.dart'; -const int LINE_A = 24; -const int LINE_B = 36; -const int LINE_C = 42; +// AUTOGENERATED START +// +// Update these constants by running: +// +// dart pkg/vm_service/test/update_line_numbers.dart +// +const LINE_A = 31; +const LINE_B = 45; +const LINE_C = 54; +// AUTOGENERATED END /* LINE_A */ void foo(args) { print('${dart_isolate.Isolate.current.debugName}: $args'); @@ -30,13 +37,18 @@ const int LINE_C = 42; Future testMain() async { final rps = List.generate( - nIsolates, (i) => dart_isolate.ReceivePort()); + nIsolates, + (i) => dart_isolate.ReceivePort(), + ); print('Isolate count: $nIsolates\n\n\n\n'); debugger(); // LINE_B for (int i = 0; i < nIsolates; i++) { - await dart_isolate.Isolate.spawn(foo, [rps[i].sendPort, i], - debugName: 'foo$i'); + await dart_isolate.Isolate.spawn( + foo, + [rps[i].sendPort, i], + debugName: 'foo$i', + ); } print(await Future.wait(rps.map((rp) => rp.first))); debugger(); // LINE_C @@ -105,7 +117,9 @@ final tests = [ final stack = await service.getStack(isolateId); final top = stack.frames![0]; final script = await service.getObject( - isolateId, top.location!.script!.id!) as Script; + isolateId, + top.location!.script!.id!, + ) as Script; expect( script.getLineNumberFromTokenPos(top.location!.tokenPos!), LINE_A, diff --git a/pkg/vm_service/test/break_on_unhandled_exception_test.dart b/pkg/vm_service/test/break_on_unhandled_exception_test.dart index 693e78a8ff3..93565ccbc33 100644 --- a/pkg/vm_service/test/break_on_unhandled_exception_test.dart +++ b/pkg/vm_service/test/break_on_unhandled_exception_test.dart @@ -26,11 +26,12 @@ const String file = 'break_on_unhandled_exception_test.dart'; Future testFunction() async { try { - var client = HttpClient(); + final client = HttpClient(); final urlstr = 'https://www.bbc.co.uk/'; final uri = Uri.parse(urlstr); - var response = await client.getUrl(uri); + final response = await client.getUrl(uri); Expect.equals(urlstr, response.uri.toString()); + await response.close(); return 0; } catch (e) { print(e.toString()); @@ -38,7 +39,7 @@ Future testFunction() async { } } -void testMain() async { +Future testMain() async { debugger(); final ret = await testFunction(); Expect.equals(ret, 0); diff --git a/pkg/vm_service/test/breakpoint_async_break_test.dart b/pkg/vm_service/test/breakpoint_async_break_test.dart index adf4b7a37cd..fd54ea5397b 100644 --- a/pkg/vm_service/test/breakpoint_async_break_test.dart +++ b/pkg/vm_service/test/breakpoint_async_break_test.dart @@ -62,19 +62,25 @@ var tests = [ futureBpt = await service.getObject(isolateId, futureBpt.id!) as Breakpoint; expect(futureBpt.resolved, isTrue); expect( - script.getLineNumberFromTokenPos(futureBpt.location!.tokenPos), LINE); + script.getLineNumberFromTokenPos(futureBpt.location!.tokenPos), + LINE, + ); expect(futureBpt.location!.line, LINE); expect( - script.getColumnNumberFromTokenPos(futureBpt.location!.tokenPos), COL); + script.getColumnNumberFromTokenPos(futureBpt.location!.tokenPos), + COL, + ); expect(futureBpt.location!.column, COL); // Remove the breakpoints. - expect((await service.removeBreakpoint(isolateId, futureBpt.id!)).type, - 'Success'); + expect( + (await service.removeBreakpoint(isolateId, futureBpt.id!)).type, + 'Success', + ); }, ]; -main(args) => runIsolateTests( +Future main(args) => runIsolateTests( args, tests, 'breakpoint_async_break_test.dart', diff --git a/pkg/vm_service/test/breakpoint_in_enhanced_enums_test.dart b/pkg/vm_service/test/breakpoint_in_enhanced_enums_test.dart index b97d096c456..ff37ed5bb46 100644 --- a/pkg/vm_service/test/breakpoint_in_enhanced_enums_test.dart +++ b/pkg/vm_service/test/breakpoint_in_enhanced_enums_test.dart @@ -105,7 +105,7 @@ final tests = [ checkRecordedStops(stops, expected), ]; -main([args = const []]) => runIsolateTests( +Future main([args = const []]) => runIsolateTests( args, tests, fileName, diff --git a/pkg/vm_service/test/breakpoint_in_package_parts_class_file_uri_test.dart b/pkg/vm_service/test/breakpoint_in_package_parts_class_file_uri_test.dart index 4537cd02ef1..9379b37f5c1 100644 --- a/pkg/vm_service/test/breakpoint_in_package_parts_class_file_uri_test.dart +++ b/pkg/vm_service/test/breakpoint_in_package_parts_class_file_uri_test.dart @@ -25,14 +25,14 @@ void code() { final stops = []; const expected = [ '$shortFile:${LINE + 0}:5', // on 'print' - '$shortFile:${LINE + 1}:3' // on class ending '}' + '$shortFile:${LINE + 1}:3', // on class ending '}' ]; final tests = [ hasPausedAtStart, setBreakpointAtUriAndLine(breakpointFile.toString(), LINE), runStepThroughProgramRecordingStops(stops), - checkRecordedStops(stops, expected) + checkRecordedStops(stops, expected), ]; void main([args = const []]) => runIsolateTests( diff --git a/pkg/vm_service/test/breakpoint_in_package_parts_class_test.dart b/pkg/vm_service/test/breakpoint_in_package_parts_class_test.dart index c94c47ab47f..c68d9452ea2 100644 --- a/pkg/vm_service/test/breakpoint_in_package_parts_class_test.dart +++ b/pkg/vm_service/test/breakpoint_in_package_parts_class_test.dart @@ -19,14 +19,14 @@ void code() { final stops = []; const expected = [ '$shortFile:${LINE + 0}:5', // on 'print' - '$shortFile:${LINE + 1}:3' // on class ending '}' + '$shortFile:${LINE + 1}:3', // on class ending '}' ]; final tests = [ hasPausedAtStart, setBreakpointAtUriAndLine(breakpointFile, LINE), runStepThroughProgramRecordingStops(stops), - checkRecordedStops(stops, expected) + checkRecordedStops(stops, expected), ]; void main([args = const []]) => runIsolateTests( diff --git a/pkg/vm_service/test/breakpoint_in_parts_class_test.dart b/pkg/vm_service/test/breakpoint_in_parts_class_test.dart index c1db8bb3548..df218b01805 100644 --- a/pkg/vm_service/test/breakpoint_in_parts_class_test.dart +++ b/pkg/vm_service/test/breakpoint_in_parts_class_test.dart @@ -12,7 +12,7 @@ part 'breakpoint_in_parts_class_part.dart'; const int LINE = 88; const String file = 'breakpoint_in_parts_class_part.dart'; -code() { +void code() { final foo = Foo10('Foo!'); print(foo); } @@ -21,14 +21,14 @@ final stops = []; const expected = [ '$file:${LINE + 0}:5', // on 'print' - '$file:${LINE + 1}:3' // on class ending '}' + '$file:${LINE + 1}:3', // on class ending '}' ]; final tests = [ hasPausedAtStart, setBreakpointAtUriAndLine(file, LINE), runStepThroughProgramRecordingStops(stops), - checkRecordedStops(stops, expected) + checkRecordedStops(stops, expected), ]; void main([args = const []]) => runIsolateTests( diff --git a/pkg/vm_service/test/breakpoint_non_debuggable_library_test.dart b/pkg/vm_service/test/breakpoint_non_debuggable_library_test.dart index acff2892829..8cbebf1cfe4 100644 --- a/pkg/vm_service/test/breakpoint_non_debuggable_library_test.dart +++ b/pkg/vm_service/test/breakpoint_non_debuggable_library_test.dart @@ -15,7 +15,7 @@ const int LINE_A = 15; // print() within barz() const int LINE_B = 11; -testMain() { +void testMain() { test_pkg.fooz(); } @@ -26,7 +26,7 @@ var tests = [ final isolateId = isolateRef.id!; final isolate = await service.getIsolate(isolateId); - LibraryRef hasPartRef = isolate.libraries!.firstWhere( + final LibraryRef hasPartRef = isolate.libraries!.firstWhere( (LibraryRef library) => library.uri == file, ); @@ -37,7 +37,7 @@ var tests = [ // Breakpoints are allowed to be set (before marking library as // non-debuggable) but are not hit when running (after marking library // as non-debuggable). - ScriptRef script = hasPart.scripts!.firstWhere( + final ScriptRef script = hasPart.scripts!.firstWhere( (ScriptRef script) => script.uri == file, ); Breakpoint bpt = await service.addBreakpoint(isolateId, script.id!, LINE_A); @@ -73,7 +73,7 @@ var tests = [ hasStoppedAtExit, ]; -main(args) => runIsolateTests( +void main([args = const []]) => runIsolateTests( args, tests, 'breakpoint_non_debuggable_library_test.dart', diff --git a/pkg/vm_service/test/breakpoint_on_if_null_1_test.dart b/pkg/vm_service/test/breakpoint_on_if_null_1_test.dart index 40fe28ec6a8..e005a44532f 100644 --- a/pkg/vm_service/test/breakpoint_on_if_null_1_test.dart +++ b/pkg/vm_service/test/breakpoint_on_if_null_1_test.dart @@ -10,11 +10,11 @@ import 'common/test_helper.dart'; const int LINE = 18; const String file = 'breakpoint_on_if_null_1_test.dart'; -code() { +void code() { foo(42); } -foo(dynamic args) { +void foo(dynamic args) { if (args == null) { print('was null'); } @@ -26,9 +26,9 @@ foo(dynamic args) { } } -List stops = []; +final stops = []; -List expected = [ +const expected = [ '$file:${LINE + 0}:12', // on '==' '$file:${LINE + 3}:12', // on '!=' '$file:${LINE + 4}:5', // on 'print' @@ -37,20 +37,18 @@ List expected = [ '$file:${LINE + 9}:1', // on ending '}' ]; -var tests = [ +final tests = [ hasPausedAtStart, setBreakpointAtUriAndLine(file, LINE), runStepThroughProgramRecordingStops(stops), - checkRecordedStops(stops, expected) + checkRecordedStops(stops, expected), ]; -main(args) { - runIsolateTestsSynchronous( - args, - tests, - 'breakpoint_on_if_null_1_test.dart', - testeeConcurrent: code, - pauseOnStart: true, - pauseOnExit: true, - ); -} +void main([args = const []]) => runIsolateTests( + args, + tests, + 'breakpoint_on_if_null_1_test.dart', + testeeConcurrent: code, + pauseOnStart: true, + pauseOnExit: true, + ); diff --git a/pkg/vm_service/test/breakpoint_on_if_null_2_test.dart b/pkg/vm_service/test/breakpoint_on_if_null_2_test.dart index 247721a35df..784e8e9c424 100644 --- a/pkg/vm_service/test/breakpoint_on_if_null_2_test.dart +++ b/pkg/vm_service/test/breakpoint_on_if_null_2_test.dart @@ -12,12 +12,12 @@ const String file = 'breakpoint_on_if_null_2_test.dart'; dynamic compareWithMe = 43; -code() { +void code() { compareWithMe = null; foo(42); } -foo(dynamic args) { +void foo(dynamic args) { if (args == compareWithMe) { print('was null'); } @@ -29,9 +29,9 @@ foo(dynamic args) { } } -List stops = []; +final stops = []; -List expected = [ +const expected = [ '$file:${LINE + 0}:12', // on '==' '$file:${LINE + 3}:12', // on '!=' '$file:${LINE + 4}:5', // on 'print' @@ -40,20 +40,18 @@ List expected = [ '$file:${LINE + 9}:1', // on ending '}' ]; -var tests = [ +final tests = [ hasPausedAtStart, setBreakpointAtUriAndLine(file, LINE), runStepThroughProgramRecordingStops(stops), - checkRecordedStops(stops, expected) + checkRecordedStops(stops, expected), ]; -main(args) { - runIsolateTestsSynchronous( - args, - tests, - 'breakpoint_on_if_null_2_test.dart', - testeeConcurrent: code, - pauseOnStart: true, - pauseOnExit: true, - ); -} +void main([args = const []]) => runIsolateTests( + args, + tests, + 'breakpoint_on_if_null_2_test.dart', + testeeConcurrent: code, + pauseOnStart: true, + pauseOnExit: true, + ); diff --git a/pkg/vm_service/test/breakpoint_on_if_null_3_test.dart b/pkg/vm_service/test/breakpoint_on_if_null_3_test.dart index d89953f369f..90af570b7fc 100644 --- a/pkg/vm_service/test/breakpoint_on_if_null_3_test.dart +++ b/pkg/vm_service/test/breakpoint_on_if_null_3_test.dart @@ -10,11 +10,11 @@ import 'common/test_helper.dart'; const int LINE = 17; const String file = 'breakpoint_on_if_null_3_test.dart'; -code() { +void code() { foo(42); } -foo(dynamic args) { +void foo(dynamic args) { if (args == null) { print('was null'); } @@ -26,10 +26,10 @@ foo(dynamic args) { } } -List stops = []; +final stops = []; -List expected = [ - '$file:${LINE + 0}:13', // on 'args' +const expected = [ + '$file:${LINE + 0}:18', // on 'args' '$file:${LINE + 1}:12', // on '==' '$file:${LINE + 4}:12', // on '!=' '$file:${LINE + 5}:5', // on 'print' @@ -38,20 +38,18 @@ List expected = [ '$file:${LINE + 10}:1', // on ending '}' ]; -var tests = [ +final tests = [ hasPausedAtStart, setBreakpointAtUriAndLine(file, LINE), runStepThroughProgramRecordingStops(stops), - checkRecordedStops(stops, expected) + checkRecordedStops(stops, expected), ]; -main(args) { - runIsolateTestsSynchronous( - args, - tests, - 'breakpoint_on_if_null_3_test.dart', - testeeConcurrent: code, - pauseOnStart: true, - pauseOnExit: true, - ); -} +void main([args = const []]) => runIsolateTests( + args, + tests, + 'breakpoint_on_if_null_3_test.dart', + testeeConcurrent: code, + pauseOnStart: true, + pauseOnExit: true, + ); diff --git a/pkg/vm_service/test/breakpoint_on_if_null_4_test.dart b/pkg/vm_service/test/breakpoint_on_if_null_4_test.dart index f535092d1a6..17c7cb34983 100644 --- a/pkg/vm_service/test/breakpoint_on_if_null_4_test.dart +++ b/pkg/vm_service/test/breakpoint_on_if_null_4_test.dart @@ -12,12 +12,12 @@ const String file = 'breakpoint_on_if_null_4_test.dart'; dynamic compareWithMe = 43; -code() { +void code() { compareWithMe = null; foo(42); } -foo(dynamic args) { +void foo(dynamic args) { if (args == compareWithMe) { print('was null'); } @@ -29,10 +29,10 @@ foo(dynamic args) { } } -List stops = []; +final stops = []; -List expected = [ - '$file:${LINE + 0}:13', // on 'args' +const expected = [ + '$file:${LINE + 0}:18', // on 'args' '$file:${LINE + 1}:12', // on '==' '$file:${LINE + 4}:12', // on '!=' '$file:${LINE + 5}:5', // on 'print' @@ -41,20 +41,18 @@ List expected = [ '$file:${LINE + 10}:1', // on ending '}' ]; -var tests = [ +final tests = [ hasPausedAtStart, setBreakpointAtUriAndLine(file, LINE), runStepThroughProgramRecordingStops(stops), - checkRecordedStops(stops, expected) + checkRecordedStops(stops, expected), ]; -main(args) { - runIsolateTestsSynchronous( - args, - tests, - 'breakpoint_on_if_null_4_test.dart', - testeeConcurrent: code, - pauseOnStart: true, - pauseOnExit: true, - ); -} +void main([args = const []]) => runIsolateTests( + args, + tests, + 'breakpoint_on_if_null_4_test.dart', + testeeConcurrent: code, + pauseOnStart: true, + pauseOnExit: true, + ); diff --git a/pkg/vm_service/test/breakpoint_on_record_assignment_test.dart b/pkg/vm_service/test/breakpoint_on_record_assignment_test.dart index e1ab6d57c4f..377c96ac554 100644 --- a/pkg/vm_service/test/breakpoint_on_record_assignment_test.dart +++ b/pkg/vm_service/test/breakpoint_on_record_assignment_test.dart @@ -7,43 +7,49 @@ import 'common/service_test_common.dart'; import 'common/test_helper.dart'; -const int LINE = 14; +// AUTOGENERATED START +// +// Update these constants by running: +// +// dart pkg/vm_service/test/update_line_numbers.dart +// +const LINE_A = 22; +// AUTOGENERATED END + const String file = 'breakpoint_on_record_assignment_test.dart'; -testMain() { - (int, String name, bool) triple = (3, 'f', true); - ({int n, String s}) pair = (n: 2, s: 's'); - (bool, num, {int n, String s}) quad = (false, 3.14, n: 7, s: 'd'); +void testMain() { + final (int, String name, bool) triple = (3, 'f', true); // LINE_A + final ({int n, String s}) pair = (n: 2, s: 's'); + final (bool, num, {int n, String s}) quad = (false, 3.14, n: 7, s: 'd'); print('$pair $triple $quad'); } -var tests = [ +final tests = [ hasPausedAtStart, - setBreakpointAtUriAndLine(file, LINE), + setBreakpointAtUriAndLine(file, LINE_A), resumeIsolate, hasStoppedAtBreakpoint, - stoppedAtLine(LINE), - setBreakpointAtUriAndLine(file, LINE + 1), + stoppedAtLine(LINE_A), + setBreakpointAtUriAndLine(file, LINE_A + 1), resumeIsolate, hasStoppedAtBreakpoint, - stoppedAtLine(LINE + 1), - setBreakpointAtUriAndLine(file, LINE + 2), + stoppedAtLine(LINE_A + 1), + setBreakpointAtUriAndLine(file, LINE_A + 2), resumeIsolate, hasStoppedAtBreakpoint, - stoppedAtLine(LINE + 2), - setBreakpointAtUriAndLine(file, LINE + 3), + stoppedAtLine(LINE_A + 2), + setBreakpointAtUriAndLine(file, LINE_A + 3), resumeIsolate, hasStoppedAtBreakpoint, - stoppedAtLine(LINE + 3), + stoppedAtLine(LINE_A + 3), ]; -main(args) { - runIsolateTestsSynchronous( - args, - tests, - 'breakpoint_on_record_assignment_test.dart', - testeeConcurrent: testMain, - pauseOnStart: true, - pauseOnExit: true, - ); -} +void main([args = const []]) => runIsolateTests( + args, + tests, + 'breakpoint_on_record_assignment_test.dart', + testeeConcurrent: testMain, + pauseOnStart: true, + pauseOnExit: true, + ); diff --git a/pkg/vm_service/test/breakpoint_on_simple_conditions_test.dart b/pkg/vm_service/test/breakpoint_on_simple_conditions_test.dart index dd6e004a5f8..3fc76972f11 100644 --- a/pkg/vm_service/test/breakpoint_on_simple_conditions_test.dart +++ b/pkg/vm_service/test/breakpoint_on_simple_conditions_test.dart @@ -13,7 +13,7 @@ const int LINE_C = 22; const int LINE_D = 24; void testMain() { - bool foo = false; + final bool foo = false; if (foo) {} // LINE_A const bar = false; diff --git a/pkg/vm_service/test/breakpoint_partfile_test.dart b/pkg/vm_service/test/breakpoint_partfile_test.dart index 009956f92a1..e59279fc5ff 100644 --- a/pkg/vm_service/test/breakpoint_partfile_test.dart +++ b/pkg/vm_service/test/breakpoint_partfile_test.dart @@ -12,7 +12,7 @@ const int LINE = 9; const String breakpointFile = 'package:test_package/the_part_2.dart'; const String shortFile = 'the_part_2.dart'; -code() { +void code() { has_part.bar(); } @@ -20,14 +20,14 @@ final stops = []; const expected = [ '$shortFile:${LINE + 0}:3', // on 'print' - '$shortFile:${LINE + 1}:1' // on class ending '}' + '$shortFile:${LINE + 1}:1', // on class ending '}' ]; final tests = [ hasPausedAtStart, setBreakpointAtUriAndLine(breakpointFile, LINE), runStepThroughProgramRecordingStops(stops), - checkRecordedStops(stops, expected) + checkRecordedStops(stops, expected), ]; void main([args = const []]) => runIsolateTests( diff --git a/pkg/vm_service/test/breakpoint_two_args_checked_test.dart b/pkg/vm_service/test/breakpoint_two_args_checked_test.dart index 9ef720ff3a0..a524d1807ef 100644 --- a/pkg/vm_service/test/breakpoint_two_args_checked_test.dart +++ b/pkg/vm_service/test/breakpoint_two_args_checked_test.dart @@ -15,61 +15,72 @@ import 'package:vm_service/vm_service.dart'; import 'common/service_test_common.dart'; import 'common/test_helper.dart'; -const int LINE_A = 29; -const int LINE_B = 30; -const int LINE_C = 31; +// AUTOGENERATED START +// +// Update these constants by running: +// +// dart pkg/vm_service/test/update_line_numbers.dart +// +const LINE_A = 35; +const LINE_B = 37; +const LINE_C = 38; +const LINE_D = 39; +// AUTOGENERATED END class NotGeneric {} -testeeMain() { +void testeeMain() { final x = List.filled(1, null); final y = 7; - debugger(); + debugger(); // LINE_A print('Statement'); - x[0] = 3; // Line A. - x is NotGeneric; // Line B. - y & 4; // Line C. + x[0] = 3; // LINE_B + x is NotGeneric; // LINE_C + y & 4; // LINE_D } final tests = [ hasStoppedAtBreakpoint, + stoppedAtLine(LINE_A), // Add breakpoints. (VmService service, IsolateRef isolateRef) async { final isolateId = isolateRef.id!; final isolate = await service.getIsolate(isolateId); - Library rootLib = + final Library rootLib = await service.getObject(isolateId, isolate.rootLib!.id!) as Library; final script = await service.getObject(isolateId, rootLib.scripts![0].id!) as Script; final scriptId = script.id!; - final bpt1 = await service.addBreakpoint(isolateId, scriptId, LINE_A); + final bpt1 = await service.addBreakpoint(isolateId, scriptId, LINE_B); print(bpt1); expect(bpt1.resolved, isTrue); - expect(script.getLineNumberFromTokenPos(bpt1.location!.tokenPos), - equals(LINE_A)); + expect( + script.getLineNumberFromTokenPos(bpt1.location!.tokenPos), + equals(LINE_B), + ); - final bpt2 = await service.addBreakpoint(isolateId, scriptId, LINE_B); + final bpt2 = await service.addBreakpoint(isolateId, scriptId, LINE_C); print(bpt2); expect(bpt2.resolved, isTrue); - expect(script.getLineNumberFromTokenPos(bpt2.location!.tokenPos), - equals(LINE_B)); + expect( + script.getLineNumberFromTokenPos(bpt2.location!.tokenPos), + equals(LINE_C), + ); - final bpt3 = await service.addBreakpoint(isolateId, scriptId, LINE_C); + final bpt3 = await service.addBreakpoint(isolateId, scriptId, LINE_D); print(bpt3); expect(bpt3.resolved, isTrue); - expect(script.getLineNumberFromTokenPos(bpt3.location!.tokenPos), - equals(LINE_C)); + expect( + script.getLineNumberFromTokenPos(bpt3.location!.tokenPos), + equals(LINE_D), + ); }, resumeIsolate, - hasStoppedAtBreakpoint, - stoppedAtLine(LINE_A), - resumeIsolate, - hasStoppedAtBreakpoint, stoppedAtLine(LINE_B), resumeIsolate, @@ -77,9 +88,13 @@ final tests = [ hasStoppedAtBreakpoint, stoppedAtLine(LINE_C), resumeIsolate, + + hasStoppedAtBreakpoint, + stoppedAtLine(LINE_D), + resumeIsolate, ]; -main(args) => runIsolateTests( +void main([args = const []]) => runIsolateTests( args, tests, 'breakpoint_two_args_checked_test.dart', diff --git a/pkg/vm_service/test/breakpoints_with_mixin_lib3.dart b/pkg/vm_service/test/breakpoints_with_mixin_lib3.dart index 3bce7d28ef2..edcb9b945d8 100644 --- a/pkg/vm_service/test/breakpoints_with_mixin_lib3.dart +++ b/pkg/vm_service/test/breakpoints_with_mixin_lib3.dart @@ -3,13 +3,13 @@ // BSD-style license that can be found in the LICENSE file. mixin class Foo { - foo() { + void foo() { print('I should be breakable!'); } } class Bar { - bar() { + void bar() { print('I should be breakable too!'); } } diff --git a/pkg/vm_service/test/breakpoints_with_mixin_test.dart b/pkg/vm_service/test/breakpoints_with_mixin_test.dart index 75911a2db87..b8d05460354 100644 --- a/pkg/vm_service/test/breakpoints_with_mixin_test.dart +++ b/pkg/vm_service/test/breakpoints_with_mixin_test.dart @@ -15,13 +15,13 @@ const int lib3Bp1 = 7; const int lib3Bp2 = 13; void code() { - Test1 test1 = Test1(); + final Test1 test1 = Test1(); test1.foo(); - Test2 test2 = Test2(); + final Test2 test2 = Test2(); test2.foo(); - Foo foo = Foo(); + final Foo foo = Foo(); foo.foo(); - Bar bar = Bar(); + final Bar bar = Bar(); bar.bar(); test1.foo(); test2.foo(); @@ -29,9 +29,9 @@ void code() { bar.bar(); } -List stops = []; +final stops = []; -List expected = [ +const expected = [ '$lib3Filename:$lib3Bp1:5 ($testFilename:${testCodeLineStart + 2}:9)', '$lib3Filename:$lib3Bp1:5 ($testFilename:${testCodeLineStart + 4}:9)', '$lib3Filename:$lib3Bp1:5 ($testFilename:${testCodeLineStart + 6}:7)', @@ -42,21 +42,19 @@ List expected = [ '$lib3Filename:$lib3Bp2:5 ($testFilename:${testCodeLineStart + 12}:7)', ]; -var tests = [ +final tests = [ hasPausedAtStart, setBreakpointAtUriAndLine(lib3Filename, lib3Bp1), setBreakpointAtUriAndLine(lib3Filename, lib3Bp2), resumeProgramRecordingStops(stops, true), - checkRecordedStops(stops, expected) + checkRecordedStops(stops, expected), ]; -main(args) { - runIsolateTestsSynchronous( - args, - tests, - 'breakpoints_with_mixin_test.dart', - testeeConcurrent: code, - pauseOnStart: true, - pauseOnExit: true, - ); -} +void main([args = const []]) => runIsolateTests( + args, + tests, + 'breakpoints_with_mixin_test.dart', + testeeConcurrent: code, + pauseOnStart: true, + pauseOnExit: true, + ); diff --git a/pkg/vm_service/test/capture_stdio_test.dart b/pkg/vm_service/test/capture_stdio_test.dart index 8dd6f91602a..f8de6b3201e 100644 --- a/pkg/vm_service/test/capture_stdio_test.dart +++ b/pkg/vm_service/test/capture_stdio_test.dart @@ -90,7 +90,7 @@ var tests = [ }, ]; -main(args) => runIsolateTests( +Future main(args) => runIsolateTests( args, tests, 'capture_stdio_test.dart', diff --git a/pkg/vm_service/test/causal_async_stack_contents_test.dart b/pkg/vm_service/test/causal_async_stack_contents_test.dart index 2ef55ea866e..c06e19cbcfd 100644 --- a/pkg/vm_service/test/causal_async_stack_contents_test.dart +++ b/pkg/vm_service/test/causal_async_stack_contents_test.dart @@ -50,7 +50,7 @@ final tests = [ hasStoppedAtBreakpoint, stoppedAtLine(LINE_B), (VmService service, IsolateRef isolateRef) async { - Stack stack = await service.getStack(isolateRef.id!); + final Stack stack = await service.getStack(isolateRef.id!); // No causal frames because we are in a completely synchronous stack. expect(stack.asyncCausalFrames, isNull); }, @@ -61,7 +61,7 @@ final tests = [ hasStoppedAtBreakpoint, stoppedAtLine(LINE_A), (VmService service, IsolateRef isolateRef) async { - Stack stack = await service.getStack(isolateRef.id!); + final Stack stack = await service.getStack(isolateRef.id!); // Has causal frames (we are inside an async function) expect(stack.asyncCausalFrames, isNotNull); expect( @@ -77,7 +77,7 @@ final tests = [ hasStoppedAtBreakpoint, stoppedAtLine(LINE_C), (VmService service, IsolateRef isolateRef) async { - Stack stack = await service.getStack(isolateRef.id!); + final Stack stack = await service.getStack(isolateRef.id!); // Has causal frames (we are inside a function called by an async function) expect(stack.asyncCausalFrames, isNotNull); final asyncStack = stack.asyncCausalFrames!; diff --git a/pkg/vm_service/test/causal_async_stack_presence_test.dart b/pkg/vm_service/test/causal_async_stack_presence_test.dart index 28062dd98e3..b51d35a7fa1 100644 --- a/pkg/vm_service/test/causal_async_stack_presence_test.dart +++ b/pkg/vm_service/test/causal_async_stack_presence_test.dart @@ -49,7 +49,7 @@ final tests = [ hasStoppedAtBreakpoint, stoppedAtLine(LINE_B), (VmService service, IsolateRef isolateRef) async { - Stack stack = await service.getStack(isolateRef.id!); + final Stack stack = await service.getStack(isolateRef.id!); // No causal frames because we are in a completely synchronous stack. // Async function hasn't yielded yet. expect(stack.asyncCausalFrames, isNull); @@ -61,7 +61,7 @@ final tests = [ hasStoppedAtBreakpoint, stoppedAtLine(LINE_A), (VmService service, IsolateRef isolateRef) async { - Stack stack = await service.getStack(isolateRef.id!); + final Stack stack = await service.getStack(isolateRef.id!); // Async function has yielded once, so it's now running async. expect(stack.asyncCausalFrames, isNotNull); }, @@ -72,7 +72,7 @@ final tests = [ hasStoppedAtBreakpoint, stoppedAtLine(LINE_C), (VmService service, IsolateRef isolateRef) async { - Stack stack = await service.getStack(isolateRef.id!); + final Stack stack = await service.getStack(isolateRef.id!); // Has causal frames (we are inside a function called by an async function) expect(stack.asyncCausalFrames, isNotNull); }, diff --git a/pkg/vm_service/test/causal_async_star_stack_contents_test.dart b/pkg/vm_service/test/causal_async_star_stack_contents_test.dart index 88bc61c8173..7a689337a36 100644 --- a/pkg/vm_service/test/causal_async_star_stack_contents_test.dart +++ b/pkg/vm_service/test/causal_async_star_stack_contents_test.dart @@ -56,7 +56,7 @@ final tests = [ hasStoppedAtBreakpoint, stoppedAtLine(LINE_A), (VmService service, IsolateRef isolateRef) async { - Stack stack = await service.getStack(isolateRef.id!); + final Stack stack = await service.getStack(isolateRef.id!); // No causal frames because we are in a completely synchronous stack. expect(stack.asyncCausalFrames, isNotNull); final asyncStack = stack.asyncCausalFrames!; @@ -71,7 +71,7 @@ final tests = [ hasStoppedAtBreakpoint, stoppedAtLine(LINE_B), (VmService service, IsolateRef isolateRef) async { - Stack stack = await service.getStack(isolateRef.id!); + final Stack stack = await service.getStack(isolateRef.id!); // Has causal frames (we are inside an async function) expect(stack.asyncCausalFrames, isNotNull); final asyncStack = stack.asyncCausalFrames!; @@ -88,13 +88,15 @@ final tests = [ hasStoppedAtBreakpoint, stoppedAtLine(LINE_C), (VmService service, IsolateRef isolateRef) async { - Stack stack = await service.getStack(isolateRef.id!); + final Stack stack = await service.getStack(isolateRef.id!); // Has causal frames (we are inside a function called by an async function) expect(stack.asyncCausalFrames, isNotNull); final asyncStack = stack.asyncCausalFrames!; expect(asyncStack.length, greaterThanOrEqualTo(4)); final script = await service.getObject( - isolateRef.id!, asyncStack[0].location!.script!.id!) as Script; + isolateRef.id!, + asyncStack[0].location!.script!.id!, + ) as Script; expect(asyncStack[0].function!.name, contains('foobar')); expect( script.getLineNumberFromTokenPos(asyncStack[0].location!.tokenPos!), diff --git a/pkg/vm_service/test/causal_async_star_stack_presence_test.dart b/pkg/vm_service/test/causal_async_star_stack_presence_test.dart index 63403cabcf8..de9fa8b589a 100644 --- a/pkg/vm_service/test/causal_async_star_stack_presence_test.dart +++ b/pkg/vm_service/test/causal_async_star_stack_presence_test.dart @@ -10,22 +10,28 @@ import 'package:vm_service/vm_service.dart'; import 'common/service_test_common.dart'; import 'common/test_helper.dart'; -const LINE_A = 30; -const LINE_B = 23; -const LINE_C = 25; +// AUTOGENERATED START +// +// Update these constants by running: +// +// dart pkg/vm_service/test/update_line_numbers.dart +// +const LINE_0 = 28; +const LINE_B = 29; +const LINE_1 = 30; +const LINE_C = 31; +const LINE_2 = 35; +const LINE_A = 36; +// AUTOGENERATED END -const LINE_0 = 22; -const LINE_1 = 24; -const LINE_2 = 29; - -foobar() async* { +Stream foobar() async* { debugger(); // LINE_0. yield 1; // LINE_B. debugger(); // LINE_1. yield 2; // LINE_C. } -helper() async { +Future helper() async { debugger(); // LINE_2. print('helper'); // LINE_A. await for (var i in foobar()) { @@ -33,18 +39,18 @@ helper() async { } } -testMain() { +void testMain() { helper(); } -var tests = [ +final tests = [ hasStoppedAtBreakpoint, stoppedAtLine(LINE_2), stepOver, hasStoppedAtBreakpoint, stoppedAtLine(LINE_A), (VmService service, IsolateRef isolateRef) async { - Stack stack = await service.getStack(isolateRef.id!); + final Stack stack = await service.getStack(isolateRef.id!); // No causal frames because we are in a completely synchronous stack. expect(stack.asyncCausalFrames, isNull); }, @@ -55,7 +61,7 @@ var tests = [ hasStoppedAtBreakpoint, stoppedAtLine(LINE_B), (VmService service, IsolateRef isolateRef) async { - Stack stack = await service.getStack(isolateRef.id!); + final Stack stack = await service.getStack(isolateRef.id!); // Has causal frames (we are inside an async function) expect(stack.asyncCausalFrames, isNotNull); }, @@ -66,13 +72,13 @@ var tests = [ hasStoppedAtBreakpoint, stoppedAtLine(LINE_C), (VmService service, IsolateRef isolateRef) async { - Stack stack = await service.getStack(isolateRef.id!); + final Stack stack = await service.getStack(isolateRef.id!); // Has causal frames (we are inside a function called by an async function) expect(stack.asyncCausalFrames, isNotNull); }, ]; -main(args) => runIsolateTestsSynchronous( +void main([args = const []]) => runIsolateTests( args, tests, 'causal_async_star_stack_presence_test.dart', diff --git a/pkg/vm_service/test/code_test.dart b/pkg/vm_service/test/code_test.dart index 38038277b1f..56150b43cac 100644 --- a/pkg/vm_service/test/code_test.dart +++ b/pkg/vm_service/test/code_test.dart @@ -57,7 +57,7 @@ var tests = [ // Inspect code objects for top two frames. (VmService service, IsolateRef isolateRef) async { final isolateId = isolateRef.id!; - Stack stack = await service.getStack(isolateId); + final Stack stack = await service.getStack(isolateId); // Make sure we are in the right place. expect(stack.frames!.length, greaterThanOrEqualTo(3)); final frame0 = stack.frames![0]; @@ -82,7 +82,7 @@ var tests = [ }, ]; -main([args = const []]) => runIsolateTests( +Future main([args = const []]) => runIsolateTests( args, tests, 'code_test.dart', diff --git a/pkg/vm_service/test/column_breakpoint_test.dart b/pkg/vm_service/test/column_breakpoint_test.dart index f5aad125c55..3ceb6fe5aee 100644 --- a/pkg/vm_service/test/column_breakpoint_test.dart +++ b/pkg/vm_service/test/column_breakpoint_test.dart @@ -6,7 +6,7 @@ import 'common/service_test_common.dart'; import 'common/test_helper.dart'; void testMain() { - var b = [1, 2].map((i) => i == 0).toList(); + final b = [1, 2].map((i) => i == 0).toList(); print(b.length); } @@ -14,12 +14,12 @@ const int LINE = 9; const int COLUMN = 29; const String shortFile = 'column_breakpoint_test.dart'; -List stops = []; +final stops = []; -const List expected = [ - '$shortFile:${LINE + 0}:29', // on 'i == 0' - '$shortFile:${LINE + 0}:29', // iterate twice - '$shortFile:${LINE + 1}:11' //on 'b.length' +const expected = [ + '$shortFile:${LINE + 0}:33', // on 'i == 0' + '$shortFile:${LINE + 0}:33', // iterate twice + '$shortFile:${LINE + 1}:11', //on 'b.length' ]; final tests = [ @@ -30,13 +30,11 @@ final tests = [ checkRecordedStops(stops, expected), ]; -main(args) { - runIsolateTestsSynchronous( - args, - tests, - 'column_breakpoint_test.dart', - testeeConcurrent: testMain, - pauseOnStart: true, - pauseOnExit: true, - ); -} +void main([args = const []]) => runIsolateTests( + args, + tests, + 'column_breakpoint_test.dart', + testeeConcurrent: testMain, + pauseOnStart: true, + pauseOnExit: true, + ); diff --git a/pkg/vm_service/test/common/expect.dart b/pkg/vm_service/test/common/expect.dart index 02d4674cb21..88325149f18 100644 --- a/pkg/vm_service/test/common/expect.dart +++ b/pkg/vm_service/test/common/expect.dart @@ -36,7 +36,7 @@ class Expect { if (start < 0) start = 0; if (end > string.length) end = string.length; } - StringBuffer buf = StringBuffer(); + final StringBuffer buf = StringBuffer(); if (start > 0) buf.write('...'); _escapeSubstring(buf, string, 0, string.length); if (end < string.length) buf.write('...'); @@ -46,15 +46,20 @@ class Expect { /// Return the string with characters that are not printable ASCII characters /// escaped as either "\xXX" codes or "\uXXXX" codes. static String _escapeString(String string) { - StringBuffer buf = StringBuffer(); + final StringBuffer buf = StringBuffer(); _escapeSubstring(buf, string, 0, string.length); return buf.toString(); } - static _escapeSubstring(StringBuffer buf, String string, int start, int end) { + static void _escapeSubstring( + StringBuffer buf, + String string, + int start, + int end, + ) { const hexDigits = '0123456789ABCDEF'; for (int i = start; i < end; i++) { - int code = string.codeUnitAt(i); + final int code = string.codeUnitAt(i); if (0x20 <= code && code < 0x7F) { if (code == 0x5C) { buf.write(r'\\'); @@ -68,7 +73,7 @@ class Expect { } else { buf.write(r'\u{'); buf.write(code.toRadixString(16).toUpperCase()); - buf.write(r'}'); + buf.write('}'); } } } @@ -85,15 +90,15 @@ class Expect { if (expected.length < 20 && actual.length < 20) return ''; for (int i = 0; i < expected.length && i < actual.length; i++) { if (expected.codeUnitAt(i) != actual.codeUnitAt(i)) { - int start = i; + final int start = i; i++; while (i < expected.length && i < actual.length) { if (expected.codeUnitAt(i) == actual.codeUnitAt(i)) break; i++; } - int end = i; - var truncExpected = _truncateString(expected, start, end, 20); - var truncActual = _truncateString(actual, start, end, 20); + final int end = i; + final truncExpected = _truncateString(expected, start, end, 20); + final truncActual = _truncateString(actual, start, end, 20); return 'at index $start: Expected <$truncExpected>, ' 'Found: <$truncActual>'; } @@ -104,9 +109,9 @@ class Expect { /// Checks whether the expected and actual values are equal (using `==`). static void equals(dynamic expected, dynamic actual, [String reason = '']) { if (expected == actual) return; - String msg = _getMessage(reason); + final String msg = _getMessage(reason); if (expected is String && actual is String) { - String stringDifference = _stringDifference(expected, actual); + final String stringDifference = _stringDifference(expected, actual); if (stringDifference.isNotEmpty) { fail('Expect.equals($stringDifference$msg) fails.'); } @@ -119,28 +124,28 @@ class Expect { /// Checks whether the actual value is a bool and its value is true. static void isTrue(dynamic actual, [String reason = '']) { if (_identical(actual, true)) return; - String msg = _getMessage(reason); + final String msg = _getMessage(reason); fail('Expect.isTrue($actual$msg) fails.'); } /// Checks whether the actual value is a bool and its value is false. static void isFalse(dynamic actual, [String reason = '']) { if (_identical(actual, false)) return; - String msg = _getMessage(reason); + final String msg = _getMessage(reason); fail('Expect.isFalse($actual$msg) fails.'); } /// Checks whether [actual] is null. static void isNull(dynamic actual, [String reason = '']) { if (null == actual) return; - String msg = _getMessage(reason); + final String msg = _getMessage(reason); fail('Expect.isNull(actual: <$actual>$msg) fails.'); } /// Checks whether [actual] is not null. static void isNotNull(dynamic actual, [String reason = '']) { if (null != actual) return; - String msg = _getMessage(reason); + final String msg = _getMessage(reason); fail('Expect.isNotNull(actual: <$actual>$msg) fails.'); } diff --git a/pkg/vm_service/test/common/service_test_common.dart b/pkg/vm_service/test/common/service_test_common.dart index b1a3e7b5ff0..c5ed4e697fc 100644 --- a/pkg/vm_service/test/common/service_test_common.dart +++ b/pkg/vm_service/test/common/service_test_common.dart @@ -12,14 +12,16 @@ import 'package:test/test.dart'; import 'package:vm_service/vm_service.dart'; typedef IsolateTest = Future Function( - VmService service, IsolateRef isolate); + VmService service, + IsolateRef isolate, +); typedef VMTest = Future Function(VmService service); Future smartNext(VmService service, IsolateRef isolateRef) async { print('smartNext'); final isolate = await service.getIsolate(isolateRef.id!); - Event event = isolate.pauseEvent!; - if ((event.kind == EventKind.kPauseBreakpoint)) { + final Event event = isolate.pauseEvent!; + if (event.kind == EventKind.kPauseBreakpoint) { // TODO(bkonyi): remove needless refetching of isolate object. if (event.atAsyncSuspension ?? false) { return asyncNext(service, isolateRef); @@ -36,8 +38,8 @@ Future asyncNext(VmService service, IsolateRef isolateRef) async { final id = isolateRef.id!; final isolate = await service.getIsolate(id); final event = isolate.pauseEvent!; - if ((event.kind == EventKind.kPauseBreakpoint)) { - dynamic event = isolate.pauseEvent; + if (event.kind == EventKind.kPauseBreakpoint) { + final dynamic event = isolate.pauseEvent; if (!event.atAsyncSuspension) { throw 'No async continuation at this location'; } else { @@ -53,7 +55,7 @@ Future syncNext(VmService service, IsolateRef isolateRef) async { final id = isolateRef.id!; final isolate = await service.getIsolate(id); final event = isolate.pauseEvent!; - if ((event.kind == EventKind.kPauseBreakpoint)) { + if (event.kind == EventKind.kPauseBreakpoint) { await service.resume(id, step: 'Over'); } else { throw 'The program is already running'; @@ -65,7 +67,10 @@ Future syncNext(VmService service, IsolateRef isolateRef) async { // If another check is waiting on an event, it will no longer be notified of // the event, causing the test to hang. Future hasPausedFor( - VmService service, IsolateRef isolateRef, String kind) async { + VmService service, + IsolateRef isolateRef, + String kind, +) async { Completer? completer = Completer(); late StreamSubscription subscription; subscription = service.onDebugEvent.listen((event) async { @@ -88,7 +93,7 @@ Future hasPausedFor( final id = isolateRef.id!; final isolate = await service.getIsolate(id); final event = isolate.pauseEvent!; - if ((event.kind == kind)) { + if (event.kind == kind) { if (completer != null) { try { await service.streamCancel(EventStreams.kDebug); @@ -122,7 +127,9 @@ Future hasStoppedPostRequest(VmService service, IsolateRef isolate) { // If another check is waiting on an event, it will no longer be notified of // the event, causing the test to hang. Future hasStoppedWithUnhandledException( - VmService service, IsolateRef isolate) { + VmService service, + IsolateRef isolate, +) { return hasPausedFor(service, isolate, EventKind.kPauseException); } @@ -143,7 +150,9 @@ Future hasPausedAtStart(VmService service, IsolateRef isolate) { } Future markDartColonLibrariesDebuggable( - VmService service, IsolateRef isolateRef) async { + VmService service, + IsolateRef isolateRef, +) async { final isolateId = isolateRef.id!; final isolate = await service.getIsolate(isolateId); final requests = []; @@ -166,7 +175,8 @@ IsolateTest setBreakpointAtLine(int line) { (await service.getObject(isolateId, isolate.rootLib!.id!)) as Library; final script = lib.scripts!.first; - Breakpoint bpt = await service.addBreakpoint(isolateId, script.id!, line); + final Breakpoint bpt = + await service.addBreakpoint(isolateId, script.id!, line); print('Breakpoint is $bpt'); }; } @@ -174,7 +184,7 @@ IsolateTest setBreakpointAtLine(int line) { IsolateTest setBreakpointAtUriAndLine(String uri, int line) { return (VmService service, IsolateRef isolateRef) async { print('Setting breakpoint for line $line in $uri'); - Breakpoint bpt = + final Breakpoint bpt = await service.addBreakpointWithScriptUri(isolateRef.id!, uri, line); print('Breakpoint is $bpt'); expect(bpt, isNotNull); @@ -188,8 +198,8 @@ IsolateTest setBreakpointAtLineColumn(int line, int column) { final isolate = await service.getIsolate(isolateId); final lib = await service.getObject(isolateId, isolate.rootLib!.id!) as Library; - ScriptRef script = lib.scripts!.firstWhere((s) => s.uri == lib.uri); - Breakpoint bpt = await service.addBreakpoint( + final ScriptRef script = lib.scripts!.firstWhere((s) => s.uri == lib.uri); + final Breakpoint bpt = await service.addBreakpoint( isolateId, script.id!, line, @@ -218,7 +228,8 @@ IsolateTest stoppedAtLine(int line) { final top = frames[0]; final Script script = (await service.getObject(id, top.location!.script!.id!)) as Script; - int actualLine = script.getLineNumberFromTokenPos(top.location!.tokenPos!)!; + final int actualLine = + script.getLineNumberFromTokenPos(top.location!.tokenPos!)!; if (actualLine != line) { print('Actual: $actualLine Line: $line'); final sb = StringBuffer(); @@ -226,7 +237,8 @@ IsolateTest stoppedAtLine(int line) { sb.write('\nFull stack trace:\n'); for (Frame f in frames) { sb.write( - ' $f [${script.getLineNumberFromTokenPos(f.location!.tokenPos!)}]\n'); + ' $f [${script.getLineNumberFromTokenPos(f.location!.tokenPos!)}]\n', + ); } throw sb.toString(); } else { @@ -236,7 +248,7 @@ IsolateTest stoppedAtLine(int line) { } Future resumeIsolate(VmService service, IsolateRef isolate) async { - Completer completer = Completer(); + final Completer completer = Completer(); late StreamSubscription subscription; bool cancelStreamAfterResume = false; subscription = service.onDebugEvent.listen((event) async { @@ -324,7 +336,9 @@ Future stepOut(VmService service, IsolateRef isolateRef) async { } IsolateTest resumeProgramRecordingStops( - List recordStops, bool includeCaller) { + List recordStops, + bool includeCaller, +) { return (VmService service, IsolateRef isolateRef) async { final completer = Completer(); @@ -361,7 +375,7 @@ Future _locationToString( Frame frame, ) async { final location = frame.location!; - Script script = + final Script script = await service.getObject(isolateRef.id!, location.script!.id!) as Script; final scriptName = basename(script.uri!); final tokenPos = location.tokenPos!; @@ -381,8 +395,10 @@ IsolateTest runStepThroughProgramRecordingStops(List recordStops) { final frame = isolate.pauseEvent!.topFrame!; recordStops.add(await _locationToString(service, isolateRef, frame)); if (event.atAsyncSuspension ?? false) { - await service.resume(isolateRef.id!, - step: StepOption.kOverAsyncSuspension); + await service.resume( + isolateRef.id!, + step: StepOption.kOverAsyncSuspension, + ); } else { await service.resume(isolateRef.id!, step: StepOption.kOver); } @@ -422,31 +438,34 @@ IsolateTest runStepIntoThroughProgramRecordingStops(List recordStops) { } IsolateTest checkRecordedStops( - List recordStops, List expectedStops, - {bool removeDuplicates = false, - bool debugPrint = false, - String? debugPrintFile, - int? debugPrintLine}) { + List recordStops, + List expectedStops, { + bool removeDuplicates = false, + bool debugPrint = false, + String? debugPrintFile, + int? debugPrintLine, +}) { return (VmService service, IsolateRef isolate) async { if (debugPrint) { for (int i = 0; i < recordStops.length; i++) { - String line = recordStops[i]; + final String line = recordStops[i]; String output = line; - int firstColon = line.indexOf(':'); - int lastColon = line.lastIndexOf(':'); + final int firstColon = line.indexOf(':'); + final int lastColon = line.lastIndexOf(':'); if (debugPrintFile != null && debugPrintLine != null && firstColon > 0 && lastColon > 0) { - int lineNumber = int.parse(line.substring(firstColon + 1, lastColon)); - int relativeLineNumber = lineNumber - debugPrintLine; - var columnNumber = line.substring(lastColon + 1); - var file = line.substring(0, firstColon); + final int lineNumber = + int.parse(line.substring(firstColon + 1, lastColon)); + final int relativeLineNumber = lineNumber - debugPrintLine; + final columnNumber = line.substring(lastColon + 1); + final file = line.substring(0, firstColon); if (file == debugPrintFile) { output = '\$file:\${LINE+$relativeLineNumber}:$columnNumber'; } } - String comma = i == recordStops.length - 1 ? '' : ','; + final String comma = i == recordStops.length - 1 ? '' : ','; print("'$output'$comma"); } } @@ -478,14 +497,17 @@ IsolateTest checkRecordedStops( j++; } - expect(recordStops.length >= expectedStops.length, true, - reason: 'Expects at least ${expectedStops.length} breaks, ' - 'got ${recordStops.length}.'); + expect( + recordStops.length >= expectedStops.length, + true, + reason: 'Expects at least ${expectedStops.length} breaks, ' + 'got ${recordStops.length}.', + ); }; } List removeAdjacentDuplicates(List fromList) { - List result = []; + final List result = []; String? latestLine; for (String s in fromList) { if (s == latestLine) continue; diff --git a/pkg/vm_service/test/common/test_helper.dart b/pkg/vm_service/test/common/test_helper.dart index 514a15c3b15..08c958e2969 100644 --- a/pkg/vm_service/test/common/test_helper.dart +++ b/pkg/vm_service/test/common/test_helper.dart @@ -43,14 +43,15 @@ Uri _getTestUri(String script) { } class _ServiceTesteeRunner { - Future run( - {Function()? testeeBefore, - Function()? testeeConcurrent, - bool pauseOnStart = false, - bool pauseOnExit = false}) async { + Future run({ + Function()? testeeBefore, + Function()? testeeConcurrent, + bool pauseOnStart = false, + bool pauseOnExit = false, + }) async { if (!pauseOnStart) { if (testeeBefore != null) { - var result = testeeBefore(); + final result = testeeBefore(); if (result is Future) { await result; } @@ -58,7 +59,7 @@ class _ServiceTesteeRunner { print(''); // Print blank line to signal that testeeBefore has run. } if (testeeConcurrent != null) { - var result = testeeConcurrent(); + final result = testeeConcurrent(); if (result is Future) { await result; } @@ -69,11 +70,12 @@ class _ServiceTesteeRunner { } } - void runSync( - {void Function()? testeeBeforeSync, - void Function()? testeeConcurrentSync, - bool pauseOnStart = false, - bool pauseOnExit = false}) { + void runSync({ + void Function()? testeeBeforeSync, + void Function()? testeeConcurrentSync, + bool pauseOnStart = false, + bool pauseOnExit = false, + }) { if (!pauseOnStart) { if (testeeBeforeSync != null) { testeeBeforeSync(); @@ -113,24 +115,26 @@ class _ServiceTesteeLauncher { List? extraArgs, ) { return _spawnDartProcess( - pauseOnStart, - pauseOnExit, - pauseOnUnhandledExceptions, - testeeControlsServer, - useAuthToken, - experiments, - extraArgs); + pauseOnStart, + pauseOnExit, + pauseOnUnhandledExceptions, + testeeControlsServer, + useAuthToken, + experiments, + extraArgs, + ); } Future _spawnDartProcess( - bool pauseOnStart, - bool pauseOnExit, - bool pauseOnUnhandledExceptions, - bool testeeControlsServer, - bool useAuthToken, - List? experiments, - List? extraArgs) { - String dartExecutable = io.Platform.executable; + bool pauseOnStart, + bool pauseOnExit, + bool pauseOnUnhandledExceptions, + bool testeeControlsServer, + bool useAuthToken, + List? experiments, + List? extraArgs, + ) { + final String dartExecutable = io.Platform.executable; final fullArgs = []; if (pauseOnStart) { @@ -161,10 +165,13 @@ class _ServiceTesteeLauncher { return _spawnCommon(dartExecutable, fullArgs, {}); } - Future _spawnCommon(String executable, - List /*!*/ arguments, Map dartEnvironment) { - var environment = _TESTEE_SPAWN_ENV; - var bashEnvironment = StringBuffer(); + Future _spawnCommon( + String executable, + List /*!*/ arguments, + Map dartEnvironment, + ) { + final environment = _TESTEE_SPAWN_ENV; + final bashEnvironment = StringBuffer(); environment.forEach((k, v) => bashEnvironment.write('$k=$v ')); dartEnvironment.forEach((k, v) { arguments.insert(0, '-D$k=$v'); @@ -178,17 +185,24 @@ class _ServiceTesteeLauncher { } Future launch( - bool pauseOnStart, - bool pauseOnExit, - bool pauseOnUnhandledExceptions, - bool testeeControlsServer, - bool useAuthToken, - List? experiments, - List? extraArgs) { - return _spawnProcess(pauseOnStart, pauseOnExit, pauseOnUnhandledExceptions, - testeeControlsServer, useAuthToken, experiments, extraArgs) - .then((p) { - Completer completer = Completer(); + bool pauseOnStart, + bool pauseOnExit, + bool pauseOnUnhandledExceptions, + bool testeeControlsServer, + bool useAuthToken, + List? experiments, + List? extraArgs, + ) { + return _spawnProcess( + pauseOnStart, + pauseOnExit, + pauseOnUnhandledExceptions, + testeeControlsServer, + useAuthToken, + experiments, + extraArgs, + ).then((p) { + final Completer completer = Completer(); process = p; Uri? uri; bool blank = false; @@ -241,7 +255,7 @@ void setupAddresses(Uri /*!*/ serverAddress) { } class _ServiceTesterRunner { - Future run({ + Future run({ List? mainArgs, List? extraArgs, List? experiments, @@ -257,17 +271,24 @@ class _ServiceTesterRunner { bool allowForNonZeroExitCode = false, VmServiceFactory serviceFactory = VmService.defaultFactory, }) async { - var process = _ServiceTesteeLauncher(scriptName); + final process = _ServiceTesteeLauncher(scriptName); late VmService vm; late IsolateRef isolate; setUp(() async { await process - .launch(pauseOnStart, pauseOnExit, pauseOnUnhandledExceptions, - testeeControlsServer, useAuthToken, experiments, extraArgs) + .launch( + pauseOnStart, + pauseOnExit, + pauseOnUnhandledExceptions, + testeeControlsServer, + useAuthToken, + experiments, + extraArgs, + ) .then((Uri serverAddress) async { if (mainArgs!.contains('--gdb')) { - var pid = process.process!.pid; - var wait = Duration(seconds: 10); + final pid = process.process!.pid; + final wait = Duration(seconds: 10); print('Testee has pid $pid, waiting $wait before continuing'); io.sleep(wait); } @@ -289,7 +310,7 @@ class _ServiceTesterRunner { // Run vm tests. if (vmTests != null) { var testIndex = 1; - var totalTests = vmTests.length; + final totalTests = vmTests.length; for (var t in vmTests) { print('$name [$testIndex/$totalTests]'); await t(vm); @@ -300,7 +321,7 @@ class _ServiceTesterRunner { // Run isolate tests. if (isolateTests != null) { var testIndex = 1; - var totalTests = isolateTests.length; + final totalTests = isolateTests.length; for (var t in isolateTests) { print('$name [$testIndex/$totalTests]'); await t(vm, isolate); @@ -430,20 +451,22 @@ void runIsolateTestsSynchronous( assert(!pauseOnStart || testeeBefore == null); if (_isTestee()) { _ServiceTesteeRunner().runSync( - testeeBeforeSync: testeeBefore, - testeeConcurrentSync: testeeConcurrent, - pauseOnStart: pauseOnStart, - pauseOnExit: pauseOnExit); + testeeBeforeSync: testeeBefore, + testeeConcurrentSync: testeeConcurrent, + pauseOnStart: pauseOnStart, + pauseOnExit: pauseOnExit, + ); } else { _ServiceTesterRunner().run( - mainArgs: mainArgs, - scriptName: scriptName, - extraArgs: extraArgs, - isolateTests: tests, - pauseOnStart: pauseOnStart, - pauseOnExit: pauseOnExit, - verboseVm: verboseVm, - pauseOnUnhandledExceptions: pauseOnUnhandledExceptions); + mainArgs: mainArgs, + scriptName: scriptName, + extraArgs: extraArgs, + isolateTests: tests, + pauseOnStart: pauseOnStart, + pauseOnExit: pauseOnExit, + verboseVm: verboseVm, + pauseOnUnhandledExceptions: pauseOnUnhandledExceptions, + ); } } @@ -466,20 +489,22 @@ Future runVMTests( }) async { if (_isTestee()) { await _ServiceTesteeRunner().run( - testeeBefore: testeeBefore, - testeeConcurrent: testeeConcurrent, - pauseOnStart: pauseOnStart, - pauseOnExit: pauseOnExit); + testeeBefore: testeeBefore, + testeeConcurrent: testeeConcurrent, + pauseOnStart: pauseOnStart, + pauseOnExit: pauseOnExit, + ); } else { await _ServiceTesterRunner().run( - mainArgs: mainArgs, - scriptName: scriptName, - extraArgs: extraArgs, - vmTests: tests, - pauseOnStart: pauseOnStart, - pauseOnExit: pauseOnExit, - verboseVm: verboseVm, - pauseOnUnhandledExceptions: pauseOnUnhandledExceptions, - serviceFactory: serviceFactory); + mainArgs: mainArgs, + scriptName: scriptName, + extraArgs: extraArgs, + vmTests: tests, + pauseOnStart: pauseOnStart, + pauseOnExit: pauseOnExit, + verboseVm: verboseVm, + pauseOnUnhandledExceptions: pauseOnUnhandledExceptions, + serviceFactory: serviceFactory, + ); } } diff --git a/pkg/vm_service/test/contexts_test.dart b/pkg/vm_service/test/contexts_test.dart index 0273e259c38..1d080793831 100644 --- a/pkg/vm_service/test/contexts_test.dart +++ b/pkg/vm_service/test/contexts_test.dart @@ -18,28 +18,28 @@ late final Function fullBlock; late final Function fullBlockWithChain; Function genCleanBlock() { - block(x) => x; + dynamic block(x) => x; return block; } Function genCopyingBlock() { final x = 'I could be copied into the block'; - block() => x; + String block() => x; return block; } Function genFullBlock() { var x = 42; // I must captured in a context. - block() => x; + int block() => x; x++; return block; } Function genFullBlockWithChain() { var x = 420; // I must captured in a context. - outerBlock() { + int Function() outerBlock() { var y = 4200; - innerBlock() => x + y; + int innerBlock() => x + y; y++; return innerBlock; } diff --git a/pkg/vm_service/test/coverage_async_test.dart b/pkg/vm_service/test/coverage_async_test.dart index 9d4669fe652..1a36fde1aec 100644 --- a/pkg/vm_service/test/coverage_async_test.dart +++ b/pkg/vm_service/test/coverage_async_test.dart @@ -61,9 +61,9 @@ IsolateTest coverageTest(Map expectedRange) { final root = await service.getObject(isolateId, isolate.rootLib!.id!) as Library; - FuncRef funcRef = + final FuncRef funcRef = root.functions!.singleWhere((f) => f.name == 'wrapperFunction'); - Func func = await service.getObject(isolateId, funcRef.id!) as Func; + final Func func = await service.getObject(isolateId, funcRef.id!) as Func; final location = func.location!; final report = await service.getSourceReport( @@ -95,8 +95,8 @@ var tests = [ 'compiled': true, 'coverage': { 'hits': [], - 'misses': [27, 28, 28, 29, 29, 29, 30, 32, 32, 33] - } + 'misses': [27, 28, 28, 29, 29, 29, 30, 32, 32, 33], + }, }, ), resumeIsolate, @@ -109,13 +109,13 @@ var tests = [ 'compiled': true, 'coverage': { 'hits': [27, 28, 28, 29, 29, 29, 30, 32, 32, 33], - 'misses': [] - } + 'misses': [], + }, }, ), ]; -main([args = const []]) => runIsolateTests( +Future main([args = const []]) => runIsolateTests( args, tests, 'coverage_async_test.dart', diff --git a/pkg/vm_service/test/coverage_closure_call_test.dart b/pkg/vm_service/test/coverage_closure_call_test.dart index ec8402b917c..cfc0d91059d 100644 --- a/pkg/vm_service/test/coverage_closure_call_test.dart +++ b/pkg/vm_service/test/coverage_closure_call_test.dart @@ -55,8 +55,8 @@ final tests = [ 'compiled': true, 'coverage': { 'hits': [], - 'misses': [399, 443] - } + 'misses': [399, 443], + }, }; final location = func.location!; @@ -101,8 +101,8 @@ final tests = [ 'compiled': true, 'coverage': { 'hits': [399, 443], - 'misses': [] - } + 'misses': [], + }, }; final location = func.location!; diff --git a/pkg/vm_service/test/coverage_const_field_async_closure_test.dart b/pkg/vm_service/test/coverage_const_field_async_closure_test.dart index d5856a6339d..a714c97a224 100644 --- a/pkg/vm_service/test/coverage_const_field_async_closure_test.dart +++ b/pkg/vm_service/test/coverage_const_field_async_closure_test.dart @@ -52,7 +52,9 @@ var tests = [ final rootLib = await service.getObject(isolateId, isolate.rootLib!.id!) as Library; final script = await service.getObject( - isolateId, rootLib.scripts!.first.id!) as Script; + isolateId, + rootLib.scripts!.first.id!, + ) as Script; final report = await service.getSourceReport( isolateId, @@ -63,7 +65,7 @@ var tests = [ int match = 0; for (var range in report.ranges!) { for (int i in range.coverage!.hits!) { - int? line = script.getLineNumberFromTokenPos(i); + final int? line = script.getLineNumberFromTokenPos(i); if (line == null) { throw FormatException('token $i was missing source location'); } @@ -78,10 +80,10 @@ var tests = [ // Neither LINE nor Bar.field should be added into coverage. expect(match, 0); }, - resumeIsolate + resumeIsolate, ]; -main([args = const []]) => runIsolateTests( +Future main([args = const []]) => runIsolateTests( args, tests, 'coverage_const_field_async_closure_test.dart', diff --git a/pkg/vm_service/test/coverage_leaf_function_test.dart b/pkg/vm_service/test/coverage_leaf_function_test.dart index 043264b88cd..5e5954f1325 100644 --- a/pkg/vm_service/test/coverage_leaf_function_test.dart +++ b/pkg/vm_service/test/coverage_leaf_function_test.dart @@ -29,8 +29,10 @@ bool allRangesCompiled(coverage) { return true; } -IsolateTest coverageTest(Map expectedRange, - {required bool reportLines}) { +IsolateTest coverageTest( + Map expectedRange, { + required bool reportLines, +}) { return (VmService service, IsolateRef isolateRef) async { final isolateId = isolateRef.id!; final isolate = await service.getIsolate(isolateId); @@ -42,9 +44,9 @@ IsolateTest coverageTest(Map expectedRange, final root = await service.getObject(isolateId, isolate.rootLib!.id!) as Library; - FuncRef funcRef = + final FuncRef funcRef = root.functions!.singleWhere((f) => f.name == 'leafFunction'); - Func func = await service.getObject(isolateId, funcRef.id!) as Func; + final Func func = await service.getObject(isolateId, funcRef.id!) as Func; final location = func.location!; final report = await service.getSourceReport( @@ -76,8 +78,8 @@ var tests = [ 'compiled': true, 'coverage': { 'hits': [], - 'misses': [399] - } + 'misses': [399], + }, }, reportLines: false, ), @@ -89,8 +91,8 @@ var tests = [ 'compiled': true, 'coverage': { 'hits': [], - 'misses': [13] - } + 'misses': [13], + }, }, reportLines: true, ), @@ -104,8 +106,8 @@ var tests = [ 'compiled': true, 'coverage': { 'hits': [399], - 'misses': [] - } + 'misses': [], + }, }, reportLines: false, ), @@ -117,14 +119,14 @@ var tests = [ 'compiled': true, 'coverage': { 'hits': [13], - 'misses': [] - } + 'misses': [], + }, }, reportLines: true, ), ]; -main([args = const []]) => runIsolateTests( +Future main([args = const []]) => runIsolateTests( args, tests, 'coverage_leaf_function_test.dart', diff --git a/pkg/vm_service/test/coverage_optimized_function_test.dart b/pkg/vm_service/test/coverage_optimized_function_test.dart index 129fddc762d..aca425db862 100644 --- a/pkg/vm_service/test/coverage_optimized_function_test.dart +++ b/pkg/vm_service/test/coverage_optimized_function_test.dart @@ -65,7 +65,7 @@ var tests = [ }, ]; -main([args = const []]) => runIsolateTests( +Future main([args = const []]) => runIsolateTests( args, tests, 'coverage_optimized_function_test.dart', diff --git a/pkg/vm_service/test/cpu_samples_stream_test.dart b/pkg/vm_service/test/cpu_samples_stream_test.dart index 27e0d5dd3bd..dbf2e660526 100644 --- a/pkg/vm_service/test/cpu_samples_stream_test.dart +++ b/pkg/vm_service/test/cpu_samples_stream_test.dart @@ -10,14 +10,14 @@ import 'package:vm_service/vm_service.dart'; import 'common/test_helper.dart'; -fib(int n) { +int fib(int n) { if (n <= 1) { return n; } return fib(n - 1) + fib(n - 2); } -void testMain() async { +Future testMain() async { int i = 10; while (true) { ++i; @@ -62,7 +62,7 @@ var tests = [ }, ]; -main([args = const []]) async => await runIsolateTests( +void main([args = const []]) => runIsolateTests( args, tests, 'cpu_samples_stream_test.dart', diff --git a/pkg/vm_service/test/debugger_inspect_test.dart b/pkg/vm_service/test/debugger_inspect_test.dart index ab85371ab92..cc40c717316 100644 --- a/pkg/vm_service/test/debugger_inspect_test.dart +++ b/pkg/vm_service/test/debugger_inspect_test.dart @@ -47,7 +47,7 @@ final tests = [ }, ]; -main([args = const []]) => runIsolateTests( +Future main([args = const []]) => runIsolateTests( args, tests, 'debugger_inspect_test.dart', diff --git a/pkg/vm_service/test/debugging_inlined_finally_test.dart b/pkg/vm_service/test/debugging_inlined_finally_test.dart index ee66caca047..f67eacb990b 100644 --- a/pkg/vm_service/test/debugging_inlined_finally_test.dart +++ b/pkg/vm_service/test/debugging_inlined_finally_test.dart @@ -29,9 +29,9 @@ num Function() testFunction() { try { late int b; try { - for (int i = 0; i < 10;) { + for (final int i = 0; i < 10;) { // ignore: prefer_function_declarations_over_variables - x() => i + a + b; + int x() => i + a + b; return x; // LINE_B } } finally { diff --git a/pkg/vm_service/test/deferred_import_reload/v1/main.dart b/pkg/vm_service/test/deferred_import_reload/v1/main.dart index 734c166fed0..463392d8eb4 100644 --- a/pkg/vm_service/test/deferred_import_reload/v1/main.dart +++ b/pkg/vm_service/test/deferred_import_reload/v1/main.dart @@ -11,7 +11,7 @@ Future main(List args, SendPort port) async { await prefix1.loadLibrary(); // Notify the spawner that we've finished loading the library. port.send(null); - RawReceivePort _ = RawReceivePort(); + final RawReceivePort _ = RawReceivePort(); print('spawned isolate running'); } diff --git a/pkg/vm_service/test/deferred_import_reload_test.dart b/pkg/vm_service/test/deferred_import_reload_test.dart index 4bedaa273e6..633cf468697 100644 --- a/pkg/vm_service/test/deferred_import_reload_test.dart +++ b/pkg/vm_service/test/deferred_import_reload_test.dart @@ -60,7 +60,10 @@ Future invokeTest(VmService service, IsolateRef isolateRef) async { final isolateId = isolateRef.id!; final isolate = await service.getIsolate(isolateId); final result = await service.evaluate( - isolateId, isolate.rootLib!.id!, 'test()') as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'test()', + ) as InstanceRef; expect(result.kind, InstanceKind.kString); return result.valueAsString!; } diff --git a/pkg/vm_service/test/developer_extension_test.dart b/pkg/vm_service/test/developer_extension_test.dart index af3be960b61..5eac16b2ec0 100644 --- a/pkg/vm_service/test/developer_extension_test.dart +++ b/pkg/vm_service/test/developer_extension_test.dart @@ -16,28 +16,38 @@ Future handler(String method, Map parameters) { print('Invoked extension: $method'); switch (method) { case 'ext..delay': - var c = Completer(); + final c = Completer(); Timer(Duration(seconds: 1), () { - c.complete(ServiceExtensionResponse.result(jsonEncode({ - 'type': '_delayedType', - 'method': method, - 'parameters': parameters, - }))); + c.complete( + ServiceExtensionResponse.result( + jsonEncode({ + 'type': '_delayedType', + 'method': method, + 'parameters': parameters, + }), + ), + ); }); return c.future; case 'ext..error': return Future.value( - ServiceExtensionResponse.error( - ServiceExtensionResponse.extensionErrorMin, 'My error detail.')); + ServiceExtensionResponse.error( + ServiceExtensionResponse.extensionErrorMin, + 'My error detail.', + ), + ); case 'ext..exception': throw 'I always throw!'; case 'ext..success': return Future.value( - ServiceExtensionResponse.result(jsonEncode({ - 'type': '_extensionType', - 'method': method, - 'parameters': parameters, - }))); + ServiceExtensionResponse.result( + jsonEncode({ + 'type': '_extensionType', + 'method': method, + 'parameters': parameters, + }), + ), + ); } throw 'Unknown extension: $method'; } @@ -128,7 +138,7 @@ var tests = [ }, ]; -main([args = const []]) async => runIsolateTests( +void main([args = const []]) => runIsolateTests( args, tests, 'developer_extension_test.dart', diff --git a/pkg/vm_service/test/developer_service_get_isolate_id_test.dart b/pkg/vm_service/test/developer_service_get_isolate_id_test.dart index af67cfe5411..ffefce1ef26 100644 --- a/pkg/vm_service/test/developer_service_get_isolate_id_test.dart +++ b/pkg/vm_service/test/developer_service_get_isolate_id_test.dart @@ -34,10 +34,10 @@ Future testeeMain() async { } @pragma('vm:entry-point') -getSelfId() => selfId; +String getSelfId() => selfId; @pragma('vm:entry-point') -getChildId() => childId; +String getChildId() => childId; // tester state: late IsolateRef initialIsolate; @@ -69,7 +69,7 @@ var tests = [ initialIsolate = await service.getIsolate(initialIsolate.id!); // Grab the root library. - Library rootLib = await service.getObject( + final Library rootLib = await service.getObject( initialIsolate.id!, (initialIsolate as Isolate).rootLib!.id!, ) as Library; @@ -99,7 +99,7 @@ var tests = [ } ]; -main(args) async => runVMTests( +void main([args = const []]) => runVMTests( args, tests, 'developer_service_get_isolate_id_test.dart', diff --git a/pkg/vm_service/test/developer_service_get_object_id_test.dart b/pkg/vm_service/test/developer_service_get_object_id_test.dart index fd62a935671..c1e3e94647a 100644 --- a/pkg/vm_service/test/developer_service_get_object_id_test.dart +++ b/pkg/vm_service/test/developer_service_get_object_id_test.dart @@ -16,19 +16,24 @@ final tests = [ final isolateId = isolateRef.id!; final isolate = await service.getIsolate(isolateId); final evalResult = await service.evaluate( - isolateId, isolate.rootLib!.id!, 'abcString') as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'abcString', + ) as InstanceRef; final getObjectIdResult = Service.getObjectId(abcString)!; final objectFromEval = await service.getObject(isolateId, evalResult.id!) as Instance; final objectFromGetObjectId = await service.getObject(isolateId, getObjectIdResult) as Instance; - expect(objectFromEval.identityHashCode, - objectFromGetObjectId.identityHashCode); + expect( + objectFromEval.identityHashCode, + objectFromGetObjectId.identityHashCode, + ); expect(objectFromEval.valueAsString, objectFromGetObjectId.valueAsString); }, ]; -main([args = const []]) async => runIsolateTests( +void main([args = const []]) => runIsolateTests( args, tests, 'developer_service_get_object_id_test.dart', diff --git a/pkg/vm_service/test/enhanced_enum_test.dart b/pkg/vm_service/test/enhanced_enum_test.dart index bdc664aadf3..7f57b306638 100644 --- a/pkg/vm_service/test/enhanced_enum_test.dart +++ b/pkg/vm_service/test/enhanced_enum_test.dart @@ -133,7 +133,7 @@ final tests = [ 'interfaceSetter2=', 'staticMethod', 'staticGetter', - 'staticSetter=' + 'staticSetter=', ]), ); expect( @@ -196,7 +196,7 @@ final tests = [ }, (VmService service, _) async { // Ensure we can evaluate instance getters and methods. - dynamic e1 = await service.evaluate(isolateId, enumEClsId, 'e1'); + final dynamic e1 = await service.evaluate(isolateId, enumEClsId, 'e1'); expect(e1, isA()); final e1Id = e1.id!; @@ -238,7 +238,7 @@ final tests = [ }, (VmService service, _) async { // Ensure we can invoke instance methods. - dynamic e1 = await service.evaluate(isolateId, enumEClsId, 'e1'); + final dynamic e1 = await service.evaluate(isolateId, enumEClsId, 'e1'); expect(e1, isA()); final e1Id = e1.id!; @@ -261,7 +261,7 @@ final tests = [ }, (VmService service, _) async { // Ensure we can invoke static methods. - dynamic result = + final dynamic result = await service.evaluate(isolateId, enumEClsId, 'staticMethod()'); expect(result, isA()); expect(result.valueAsString, '42'); @@ -298,7 +298,7 @@ final tests = [ }, ]; -main([args = const []]) => runIsolateTests( +Future main([args = const []]) => runIsolateTests( args, tests, 'enhanced_enum_test.dart', diff --git a/pkg/vm_service/test/eval_internal_class_test.dart b/pkg/vm_service/test/eval_internal_class_test.dart index d04cf3f1951..c35733c0aa6 100644 --- a/pkg/vm_service/test/eval_internal_class_test.dart +++ b/pkg/vm_service/test/eval_internal_class_test.dart @@ -15,7 +15,7 @@ var tests = [ isolateId, isolate.rootLib!.id!, ) as Library; - Class classLibrary = await service.getObject( + final Class classLibrary = await service.getObject( isolateId, rootLib.classRef!.id!, ) as Class; @@ -23,7 +23,7 @@ var tests = [ { bool caughtExceptions = false; try { - dynamic result = await service.evaluate( + final dynamic result = await service.evaluate( isolateId, classLibrary.id!, '3 + 4', @@ -43,7 +43,7 @@ var tests = [ { bool caughtExceptions = false; try { - dynamic result = await service.evaluate( + final dynamic result = await service.evaluate( isolateId, classClass.id!, '3 + 4', @@ -65,7 +65,7 @@ var tests = [ .classRef! .id!, ) as Class; - dynamic result = await service.evaluate( + final dynamic result = await service.evaluate( isolateId, classArray.id!, '3 + 4', @@ -75,7 +75,7 @@ var tests = [ }, ]; -main([args = const []]) => runIsolateTests( +Future main([args = const []]) => runIsolateTests( args, tests, 'eval_internal_class_test.dart', diff --git a/pkg/vm_service/test/eval_issue_49209_test.dart b/pkg/vm_service/test/eval_issue_49209_test.dart index 917da4f25ee..e4f03d4fcc7 100644 --- a/pkg/vm_service/test/eval_issue_49209_test.dart +++ b/pkg/vm_service/test/eval_issue_49209_test.dart @@ -33,15 +33,18 @@ var tests = [ // Evaluate against top frame. (VmService service, IsolateRef isolateRef) async { final isolateId = isolateRef.id!; - var topFrame = 0; + final topFrame = 0; final dynamic result = await service.evaluateInFrame( - isolateId, topFrame, 'a.runtimeType.toString()'); + isolateId, + topFrame, + 'a.runtimeType.toString()', + ); print(result); expect(result.valueAsString, equals('A')); }, ]; -main([args = const []]) => runIsolateTests( +Future main([args = const []]) => runIsolateTests( args, tests, 'eval_issue_49209_test.dart', diff --git a/pkg/vm_service/test/eval_named_args_anywhere_test.dart b/pkg/vm_service/test/eval_named_args_anywhere_test.dart index 47a0e21f1a8..d862e460266 100644 --- a/pkg/vm_service/test/eval_named_args_anywhere_test.dart +++ b/pkg/vm_service/test/eval_named_args_anywhere_test.dart @@ -63,7 +63,7 @@ final tests = [ }, ]; -main([args = const []]) => runIsolateTests( +Future main([args = const []]) => runIsolateTests( args, tests, 'eval_named_args_anywhere_test.dart', diff --git a/pkg/vm_service/test/eval_regression_flutter20255_test.dart b/pkg/vm_service/test/eval_regression_flutter20255_test.dart index e0dd057d5ac..6adda0e2821 100644 --- a/pkg/vm_service/test/eval_regression_flutter20255_test.dart +++ b/pkg/vm_service/test/eval_regression_flutter20255_test.dart @@ -72,7 +72,7 @@ void testFunction() { } Future triggerEvaluation(VmService service, IsolateRef isolateRef) async { - Stack stack = await service.getStack(isolateRef.id!); + final Stack stack = await service.getStack(isolateRef.id!); // Make sure we are in the right place. expect(stack.frames!.length, greaterThanOrEqualTo(2)); @@ -105,7 +105,7 @@ final testSteps = [ resumeIsolate, ]; -main([args = const []]) => runIsolateTests( +Future main([args = const []]) => runIsolateTests( args, testSteps, 'eval_regression_flutter20255_test.dart', diff --git a/pkg/vm_service/test/eval_skip_breakpoint.dart b/pkg/vm_service/test/eval_skip_breakpoint.dart index 415f29c474d..9152292ebd5 100644 --- a/pkg/vm_service/test/eval_skip_breakpoint.dart +++ b/pkg/vm_service/test/eval_skip_breakpoint.dart @@ -10,20 +10,27 @@ import 'package:vm_service/vm_service.dart'; import 'common/service_test_common.dart'; import 'common/test_helper.dart'; -const int LINE_A = 22; -const int LINE_B = 17; +// AUTOGENERATED START +// +// Update these constants by running: +// +// dart pkg/vm_service/test/update_line_numbers.dart +// +const LINE_B = 24; +const LINE_A = 28; +// AUTOGENERATED END -bar() { - print('bar'); +void bar() { + print('bar'); // LINE_B } -testMain() { - debugger(); +void testMain() { + debugger(); // LINE_A bar(); print('Done'); } -var tests = [ +final tests = [ hasStoppedAtBreakpoint, stoppedAtLine(LINE_A), // Add breakpoint @@ -47,7 +54,7 @@ var tests = [ resumeIsolate, ]; -main([args = const []]) => runIsolateTests( +void main([args = const []]) => runIsolateTests( args, tests, 'eval_skip_breakpoint.dart', diff --git a/pkg/vm_service/test/eval_test.dart b/pkg/vm_service/test/eval_test.dart index 86a7cec6b90..798ef562b8c 100644 --- a/pkg/vm_service/test/eval_test.dart +++ b/pkg/vm_service/test/eval_test.dart @@ -29,12 +29,12 @@ void testFunction() { while (true) { if (++i % 100000000 == 0) { MyClass.method(10000); - (_MyClass()).foo(); + _MyClass().foo(); } } } -var tests = [ +final tests = [ hasStoppedAtBreakpoint, // Evaluate against library, class, and instance. @@ -57,8 +57,9 @@ var tests = [ print(result); expect(result.valueAsString, '105'); - await expectError(() => - service.evaluate(isolateId, lib.id!, 'globalVar + staticVar + 5')); + await expectError( + () => service.evaluate(isolateId, lib.id!, 'globalVar + staticVar + 5'), + ); result = await service.evaluate(isolateId, cls.id!, 'globalVar + staticVar + 5'); @@ -72,7 +73,8 @@ var tests = [ expect(result.valueAsString, '10005'); await expectError( - () => service.evaluate(isolateId, instance.id!, 'this + frog')); + () => service.evaluate(isolateId, instance.id!, 'this + frog'), + ); }, resumeIsolate, hasStoppedAtBreakpoint, @@ -94,7 +96,7 @@ var tests = [ } ]; -expectError(func) async { +Future expectError(func) async { bool gotException = false; dynamic result; try { @@ -109,7 +111,7 @@ expectError(func) async { } } -main([args = const []]) => runIsolateTests( +void main([args = const []]) => runIsolateTests( args, tests, 'eval_test.dart', diff --git a/pkg/vm_service/test/evaluate_activation_in_method_class_other.dart b/pkg/vm_service/test/evaluate_activation_in_method_class_other.dart index c1abce17e41..4a7b2c14a25 100644 --- a/pkg/vm_service/test/evaluate_activation_in_method_class_other.dart +++ b/pkg/vm_service/test/evaluate_activation_in_method_class_other.dart @@ -11,9 +11,9 @@ var topLevel = 'OtherLibrary'; class Superclass2 { final _instVar = 'Superclass2'; var instVar = 'Superclass2'; - method() => 'Superclass2'; - static staticMethod() => 'Superclass2'; - suppressWarning() => _instVar; + String method() => 'Superclass2'; + static String staticMethod() => 'Superclass2'; + String suppressWarning() => _instVar; } class Superclass1 extends Superclass2 { @@ -22,12 +22,12 @@ class Superclass1 extends Superclass2 { @override var instVar = 'Superclass1'; @override - method() => 'Superclass1'; - static staticMethod() => 'Superclass1'; + String method() => 'Superclass1'; + static String staticMethod() => 'Superclass1'; - test() { + void test() { // ignore: no_leading_underscores_for_local_identifiers - var _local = 'Superclass1'; + final _local = 'Superclass1'; debugger(); // Suppress unused variable warning. print(_local); diff --git a/pkg/vm_service/test/evaluate_activation_in_method_class_test.dart b/pkg/vm_service/test/evaluate_activation_in_method_class_test.dart index 64edccff463..45d96756732 100644 --- a/pkg/vm_service/test/evaluate_activation_in_method_class_test.dart +++ b/pkg/vm_service/test/evaluate_activation_in_method_class_test.dart @@ -23,24 +23,24 @@ class Subclass extends Superclass1 { @override var instVar = 'Subclass'; @override - method() => 'Subclass'; - static staticMethod() => 'Subclass'; + String method() => 'Subclass'; + static String staticMethod() => 'Subclass'; @override - suppressWarning() => _instVar; + String suppressWarning() => _instVar; } -testeeDo() { - var obj = Subclass(); +void testeeDo() { + final obj = Subclass(); obj.test(); } -Future testerDo(VmService service, IsolateRef isolateRef) async { +Future testerDo(VmService service, IsolateRef isolateRef) async { await hasStoppedAtBreakpoint(service, isolateRef); final isolateId = isolateRef.id!; // Make sure we are in the right place. - var stack = await service.getStack(isolateId); - var topFrame = 0; + final stack = await service.getStack(isolateId); + final topFrame = 0; expect( stack.frames![topFrame].function!.name, equals('test'), @@ -101,7 +101,7 @@ Future testerDo(VmService service, IsolateRef isolateRef) async { expect(result.valueAsString, equals('OtherLibrary')); } -main([args = const []]) => runIsolateTests( +void main([args = const []]) => runIsolateTests( args, [testerDo], 'evaluate_activation_in_method_class_test.dart', diff --git a/pkg/vm_service/test/evaluate_class_type_parameters_test.dart b/pkg/vm_service/test/evaluate_class_type_parameters_test.dart index ec56441a6a4..f90c5e14eef 100644 --- a/pkg/vm_service/test/evaluate_class_type_parameters_test.dart +++ b/pkg/vm_service/test/evaluate_class_type_parameters_test.dart @@ -8,22 +8,29 @@ import 'package:vm_service/vm_service.dart'; import 'common/service_test_common.dart'; import 'common/test_helper.dart'; -const LINE_A = 16; -const LINE_B = LINE_A + 6; +// AUTOGENERATED START +// +// Update these constants by running: +// +// dart pkg/vm_service/test/update_line_numbers.dart +// +const LINE_A = 23; +const LINE_B = 29; +// AUTOGENERATED END class A { void foo() { - debugger(); + debugger(); // LINE_A } } class B extends A { void bar() { - debugger(); + debugger(); // LINE_B } } -testFunction() { +void testFunction() { final v = B(); v.bar(); v.foo(); diff --git a/pkg/vm_service/test/evaluate_fold_on_list_test.dart b/pkg/vm_service/test/evaluate_fold_on_list_test.dart index 7e12baaa16e..c7d9d983739 100644 --- a/pkg/vm_service/test/evaluate_fold_on_list_test.dart +++ b/pkg/vm_service/test/evaluate_fold_on_list_test.dart @@ -11,9 +11,11 @@ import 'common/service_test_common.dart'; import 'common/test_helper.dart'; void testFunction() { - List x = ['a', 'b', 'c']; - int xCombinedLength = x.fold( - 0, (previousValue, element) => previousValue + element.length); + final List x = ['a', 'b', 'c']; + final int xCombinedLength = x.fold( + 0, + (previousValue, element) => previousValue + element.length, + ); debugger(); print('xCombinedLength = $xCombinedLength'); } diff --git a/pkg/vm_service/test/evaluate_function_type_parameters_test.dart b/pkg/vm_service/test/evaluate_function_type_parameters_test.dart index 583c6f874b2..3d3888d7386 100644 --- a/pkg/vm_service/test/evaluate_function_type_parameters_test.dart +++ b/pkg/vm_service/test/evaluate_function_type_parameters_test.dart @@ -8,42 +8,49 @@ import 'package:vm_service/vm_service.dart'; import 'common/service_test_common.dart'; import 'common/test_helper.dart'; -const LINE_A = 18; -const LINE_B = LINE_A + 3; -const LINE_C = LINE_B + 6; -const LINE_D = LINE_C + 8; -const LINE_E = LINE_D + 4; +// AUTOGENERATED START +// +// Update these constants by running: +// +// dart pkg/vm_service/test/update_line_numbers.dart +// +const LINE_A = 25; +const LINE_B = 28; +const LINE_C = 34; +const LINE_D = 42; +const LINE_E = 46; +// AUTOGENERATED END -topLevel() { - debugger(); +void topLevel() { + debugger(); // LINE_A void inner1(TInt x) { - debugger(); + debugger(); // LINE_B } inner1(3); void inner2() { - debugger(); + debugger(); // LINE_C } inner2(); } class A { - foo() { - debugger(); + void foo() { + debugger(); // LINE_D } - bar(T t) { - debugger(); + void bar(T t) { + debugger(); // LINE_E } } void testMain() { topLevel(); - (A()).foo(); - (A()).bar(42); + A().foo(); + A().bar(42); } final tests = [ @@ -52,7 +59,11 @@ final tests = [ (VmService service, IsolateRef isolateRef) async { final isolateId = isolateRef.id!; await evaluateInFrameAndExpect( - service, isolateId, 'S.toString()', 'String'); + service, + isolateId, + 'S.toString()', + 'String', + ); }, resumeIsolate, hasStoppedAtBreakpoint, diff --git a/pkg/vm_service/test/evaluate_in_async_activation_test.dart b/pkg/vm_service/test/evaluate_in_async_activation_test.dart index 5465b3ceba3..0b2b2694297 100644 --- a/pkg/vm_service/test/evaluate_in_async_activation_test.dart +++ b/pkg/vm_service/test/evaluate_in_async_activation_test.dart @@ -13,11 +13,11 @@ import 'common/test_helper.dart'; const LINE_A = 19; const LINE_B = LINE_A + 2; -testFunction() async { - var x = 3; - var y = 4; +Future testFunction() async { + final x = 3; + final y = 4; debugger(); - var z = await Future(() => x + y); + final z = await Future(() => x + y); debugger(); return z; } diff --git a/pkg/vm_service/test/evaluate_in_async_star_activation_test.dart b/pkg/vm_service/test/evaluate_in_async_star_activation_test.dart index 74b765f3eb2..1e21ab8d572 100644 --- a/pkg/vm_service/test/evaluate_in_async_star_activation_test.dart +++ b/pkg/vm_service/test/evaluate_in_async_star_activation_test.dart @@ -29,10 +29,8 @@ Stream generator() async* { yield z; } -testFunction() async { - await for (var _ in generator()) { - {} - } +Future testFunction() async { + await for (var _ in generator()) {} } final tests = [ diff --git a/pkg/vm_service/test/evaluate_in_frame_with_scope_test.dart b/pkg/vm_service/test/evaluate_in_frame_with_scope_test.dart index 2292dd1b62d..80a3243c4a6 100644 --- a/pkg/vm_service/test/evaluate_in_frame_with_scope_test.dart +++ b/pkg/vm_service/test/evaluate_in_frame_with_scope_test.dart @@ -29,7 +29,7 @@ void testeeMain() { } int foo(x, y) { - var local = x + y; + final local = x + y; debugger(); // LINE_A return local; } @@ -95,10 +95,15 @@ final tests = [ ); try { - await service.evaluate(isolateId, rootLibId, 'x + y', scope: { - 'x': rootLibId, - 'y': rootLibId, - }); + await service.evaluate( + isolateId, + rootLibId, + 'x + y', + scope: { + 'x': rootLibId, + 'y': rootLibId, + }, + ); fail('Evaluated against a VM-internal object'); } on RPCError catch (e) { expect(e.code, RPCErrorKind.kExpressionCompilationError.code); @@ -109,15 +114,20 @@ final tests = [ } try { - await service.evaluate(isolateId, rootLibId, 'x + y', scope: { - 'not&an&identifier': thing1.id!, - }); + await service.evaluate( + isolateId, + rootLibId, + 'x + y', + scope: { + 'not&an&identifier': thing1.id!, + }, + ); fail('Evaluated with an invalid identifier'); } on RPCError catch (e) { expect(e.code, RPCErrorKind.kExpressionCompilationError.code); expect( e.details, - contains('invalid \'scope\' parameter'), + contains("invalid 'scope' parameter"), ); } }, diff --git a/pkg/vm_service/test/evaluate_in_mixin_application_alias_frame_test.dart b/pkg/vm_service/test/evaluate_in_mixin_application_alias_frame_test.dart index 471d0f2d75b..e768a8fcf43 100644 --- a/pkg/vm_service/test/evaluate_in_mixin_application_alias_frame_test.dart +++ b/pkg/vm_service/test/evaluate_in_mixin_application_alias_frame_test.dart @@ -12,22 +12,29 @@ import 'package:vm_service/vm_service.dart'; import 'common/service_test_common.dart'; import 'common/test_helper.dart'; -const LINE_A = 23; +// AUTOGENERATED START +// +// Update these constants by running: +// +// dart pkg/vm_service/test/update_line_numbers.dart +// +const LINE_A = 30; +// AUTOGENERATED END class S {} mixin class M { static String? foo; - bar() { + void bar() { foo = 'theExpectedValue'; - debugger(); + debugger(); // LINE_A } } // MA=S&M -> S -> Object class MA = S with M; -testeeMain() { +void testeeMain() { MA().bar(); } diff --git a/pkg/vm_service/test/evaluate_in_mixin_application_frame_test.dart b/pkg/vm_service/test/evaluate_in_mixin_application_frame_test.dart index a3ed49022c9..7e8a2d2cae4 100644 --- a/pkg/vm_service/test/evaluate_in_mixin_application_frame_test.dart +++ b/pkg/vm_service/test/evaluate_in_mixin_application_frame_test.dart @@ -12,22 +12,29 @@ import 'package:vm_service/vm_service.dart'; import 'common/service_test_common.dart'; import 'common/test_helper.dart'; -const LINE_A = 23; +// AUTOGENERATED START +// +// Update these constants by running: +// +// dart pkg/vm_service/test/update_line_numbers.dart +// +const LINE_A = 30; +// AUTOGENERATED END class S {} mixin class M { static String? foo; - bar() { + void bar() { foo = 'theExpectedValue'; - debugger(); + debugger(); // LINE_A } } // MA2 -> S&M -> S -> Object class MA extends S with M {} -testeeMain() { +void testeeMain() { MA().bar(); } diff --git a/pkg/vm_service/test/evaluate_inside_closures_test.dart b/pkg/vm_service/test/evaluate_inside_closures_test.dart index 9571cdb7e5d..dab8c8375c0 100644 --- a/pkg/vm_service/test/evaluate_inside_closures_test.dart +++ b/pkg/vm_service/test/evaluate_inside_closures_test.dart @@ -32,8 +32,8 @@ class C { void use(_) {} -testMain() { - C c = C(); +void testMain() { + final C c = C(); C.staticMethod(); c.instanceMethod(); } @@ -49,7 +49,10 @@ final tests = [ expect(xRef.valueAsString, '56'); InstanceRef staticFieldRef = await service.evaluateInFrame( - isolateId, 0, 'staticField += 1') as InstanceRef; + isolateId, + 0, + 'staticField += 1', + ) as InstanceRef; expect(staticFieldRef.valueAsString, '13'); staticFieldRef = await service.evaluateInFrame(isolateId, 0, 'staticField') as InstanceRef; @@ -75,21 +78,33 @@ final tests = [ expect(yRef.valueAsString, '78'); InstanceRef staticFieldRef = await service.evaluateInFrame( - isolateId, 0, 'staticField += 1') as InstanceRef; + isolateId, + 0, + 'staticField += 1', + ) as InstanceRef; expect(staticFieldRef.valueAsString, '14'); staticFieldRef = await service.evaluateInFrame(isolateId, 0, 'staticField') as InstanceRef; expect(staticFieldRef.valueAsString, '14'); InstanceRef instanceFieldRef = await service.evaluateInFrame( - isolateId, 0, 'instanceField += 1') as InstanceRef; + isolateId, + 0, + 'instanceField += 1', + ) as InstanceRef; expect(instanceFieldRef.valueAsString, '35'); instanceFieldRef = await service.evaluateInFrame( - isolateId, 0, 'instanceField') as InstanceRef; + isolateId, + 0, + 'instanceField', + ) as InstanceRef; expect(instanceFieldRef.valueAsString, '35'); } ]; -main([args = const []]) async => - runIsolateTests(args, tests, 'evaluate_inside_closures_test.dart', - testeeConcurrent: testMain); +void main([args = const []]) => runIsolateTests( + args, + tests, + 'evaluate_inside_closures_test.dart', + testeeConcurrent: testMain, + ); diff --git a/pkg/vm_service/test/evaluate_type_with_extension_test.dart b/pkg/vm_service/test/evaluate_type_with_extension_test.dart index 381892df481..cb96c2403fc 100644 --- a/pkg/vm_service/test/evaluate_type_with_extension_test.dart +++ b/pkg/vm_service/test/evaluate_type_with_extension_test.dart @@ -11,15 +11,15 @@ import 'common/test_helper.dart'; extension on String { String printAndReturnHello() { - String response = "Hello from String '$this'"; + final String response = "Hello from String '$this'"; print(response); return response; } } void testFunction() { - String x = 'hello'; - String value = x.printAndReturnHello(); + final String x = 'hello'; + final String value = x.printAndReturnHello(); debugger(); print('value = $value'); } diff --git a/pkg/vm_service/test/evaluate_variable_of_raw_type_test.dart b/pkg/vm_service/test/evaluate_variable_of_raw_type_test.dart index 9a361f1e879..e3995720358 100644 --- a/pkg/vm_service/test/evaluate_variable_of_raw_type_test.dart +++ b/pkg/vm_service/test/evaluate_variable_of_raw_type_test.dart @@ -9,7 +9,7 @@ import 'common/service_test_common.dart'; import 'common/test_helper.dart'; void testFunction() { - List v = [1, 2, '3']; + final List v = [1, 2, '3']; debugger(); print('v = $v'); } diff --git a/pkg/vm_service/test/evaluate_with_escaping_closure_test.dart b/pkg/vm_service/test/evaluate_with_escaping_closure_test.dart index 1057f645feb..082fc635c49 100644 --- a/pkg/vm_service/test/evaluate_with_escaping_closure_test.dart +++ b/pkg/vm_service/test/evaluate_with_escaping_closure_test.dart @@ -10,7 +10,7 @@ import 'common/test_helper.dart'; dynamic escapedClosure; -testeeMain() {} +void testeeMain() {} final tests = [ (VmService service, IsolateRef isolateRef) async { diff --git a/pkg/vm_service/test/evaluate_with_scope_test.dart b/pkg/vm_service/test/evaluate_with_scope_test.dart index fe51ae92975..126ce0abf56 100644 --- a/pkg/vm_service/test/evaluate_with_scope_test.dart +++ b/pkg/vm_service/test/evaluate_with_scope_test.dart @@ -10,14 +10,18 @@ import 'common/test_helper.dart'; int? thing1; int? thing2; -testeeMain() { +void testeeMain() { thing1 = 3; thing2 = 4; } -Future evaluate(VmService service, isolate, target, x, y) async => - await service.evaluate(isolate!.id!!, target.id!, 'x + y', - scope: {'x': x.id!, 'y': y.id!}); +Future evaluate(VmService service, isolate, target, x, y) async => + await service.evaluate( + isolate!.id!!, + target.id!, + 'x + y', + scope: {'x': x.id!, 'y': y.id!}, + ) as InstanceRef; final tests = [ (VmService service, IsolateRef isolateRef) async { @@ -26,15 +30,17 @@ final tests = [ final Library lib = (await service.getObject(isolateId, isolate.rootLib!.id!)) as Library; - final Field field1 = (await service.getObject(isolateId, - lib.variables!.singleWhere((v) => v.name == 'thing1').id!)) as Field; - final thing1 = - (await service.getObject(isolateId, field1.staticValue!.id!)); + final Field field1 = (await service.getObject( + isolateId, + lib.variables!.singleWhere((v) => v.name == 'thing1').id!, + )) as Field; + final thing1 = await service.getObject(isolateId, field1.staticValue!.id!); - final Field field2 = (await service.getObject(isolateId, - lib.variables!.singleWhere((v) => v.name == 'thing2').id!)) as Field; - final thing2 = - (await service.getObject(isolateId, field2.staticValue!.id!)); + final Field field2 = (await service.getObject( + isolateId, + lib.variables!.singleWhere((v) => v.name == 'thing2').id!, + )) as Field; + final thing2 = await service.getObject(isolateId, field2.staticValue!.id!); var result = await evaluate(service, isolate, lib, thing1, thing2); expect(result.valueAsString, equals('7')); @@ -45,15 +51,21 @@ final tests = [ print(result); } catch (e) { didThrow = true; - expect(e.toString(), - contains('Cannot evaluate against a VM-internal object')); + expect( + e.toString(), + contains('Cannot evaluate against a VM-internal object'), + ); } expect(didThrow, isTrue); didThrow = false; try { - result = await service.evaluate(isolateId, lib.id!, 'x + y', - scope: {'not&an&id!entifier': thing1.id!}); + result = await service.evaluate( + isolateId, + lib.id!, + 'x + y', + scope: {'not&an&id!entifier': thing1.id!}, + ) as InstanceRef; print(result); } catch (e) { didThrow = true; @@ -63,7 +75,7 @@ final tests = [ } ]; -main([args = const []]) => runIsolateTests( +Future main([args = const []]) => runIsolateTests( args, tests, 'evaluate_with_scope_test.dart', diff --git a/pkg/vm_service/test/external_compilation_service_script.dart b/pkg/vm_service/test/external_compilation_service_script.dart index 08165237ec2..bccd7b844ea 100644 --- a/pkg/vm_service/test/external_compilation_service_script.dart +++ b/pkg/vm_service/test/external_compilation_service_script.dart @@ -4,6 +4,6 @@ import 'dart:developer'; -main() { +void main() { debugger(); } diff --git a/pkg/vm_service/test/external_compilation_service_test.dart b/pkg/vm_service/test/external_compilation_service_test.dart index 41e8ab0209d..69745cf8f6f 100644 --- a/pkg/vm_service/test/external_compilation_service_test.dart +++ b/pkg/vm_service/test/external_compilation_service_test.dart @@ -83,7 +83,10 @@ void main() { await waitForRunnableIsolate(service, isolate); try { await service.evaluate( - isolate.id!, isolate.libraries!.first.id!, '1 + 1'); + isolate.id!, + isolate.libraries!.first.id!, + '1 + 1', + ); } catch (_) { // ignore error } diff --git a/pkg/vm_service/test/external_service_asynchronous_invocation_test.dart b/pkg/vm_service/test/external_service_asynchronous_invocation_test.dart index 4962579c29d..1edee0f2685 100644 --- a/pkg/vm_service/test/external_service_asynchronous_invocation_test.dart +++ b/pkg/vm_service/test/external_service_asynchronous_invocation_test.dart @@ -68,11 +68,13 @@ Future testSuccessService( // check requests while they arrive expect(params[paramKey + end], paramValue + end); // answer later - completions.add(() => responseCompleter.complete({ - 'result': { - resultKey + end: resultValue + end, - }, - })); + completions.add( + () => responseCompleter.complete({ + 'result': { + resultKey + end: resultValue + end, + }, + }), + ); } // Shuffle and respond out of order. diff --git a/pkg/vm_service/test/fetch_all_types_test.dart b/pkg/vm_service/test/fetch_all_types_test.dart index a6164907275..df3da275811 100644 --- a/pkg/vm_service/test/fetch_all_types_test.dart +++ b/pkg/vm_service/test/fetch_all_types_test.dart @@ -10,13 +10,13 @@ import 'common/test_helper.dart'; var tests = [ (VmService service, IsolateRef isolateRef) async { - var profile = await service.getAllocationProfile(isolateRef.id!); + final profile = await service.getAllocationProfile(isolateRef.id!); for (var entry in profile.members!) { if (entry.instancesCurrent == 0) continue; - var classRef = entry.classRef!; + final classRef = entry.classRef!; print(classRef); - var instanceSet = + final instanceSet = await service.getInstances(isolateRef.id!, classRef.id!, 10); for (var instance in instanceSet.instances!) { await service.getObject(isolateRef.id!, instance.id!); @@ -25,7 +25,7 @@ var tests = [ }, ]; -main(args) => runIsolateTests( +Future main(args) => runIsolateTests( args, tests, 'fetch_all_types_test.dart', diff --git a/pkg/vm_service/test/file_service_test.dart b/pkg/vm_service/test/file_service_test.dart index 59ff37e418c..1e635967b61 100644 --- a/pkg/vm_service/test/file_service_test.dart +++ b/pkg/vm_service/test/file_service_test.dart @@ -71,8 +71,10 @@ final tests = [ (VmService service, IsolateRef isolateRef) async { final isolateId = isolateRef.id!; try { - await service.callServiceExtension('ext.dart.io.setup', - isolateId: isolateId); + await service.callServiceExtension( + 'ext.dart.io.setup', + isolateId: isolateId, + ); final result = await service.getOpenFiles(isolateId); expect(result.files.length, 2); diff --git a/pkg/vm_service/test/gc_test.dart b/pkg/vm_service/test/gc_test.dart index 84a41735f4c..1ab7a0684db 100644 --- a/pkg/vm_service/test/gc_test.dart +++ b/pkg/vm_service/test/gc_test.dart @@ -9,7 +9,7 @@ import 'package:vm_service/vm_service.dart'; import 'common/test_helper.dart'; void script() { - grow(int iterations, int size, Duration duration) { + void grow(int iterations, int size, Duration duration) { if (iterations <= 0) { return; } @@ -22,7 +22,7 @@ void script() { final tests = [ (VmService service, IsolateRef isolateRef) async { - Completer completer = Completer(); + final Completer completer = Completer(); // Expect at least this many GC events. int gcCountdown = 3; late final StreamSubscription sub; diff --git a/pkg/vm_service/test/get_allocation_profile_rpc_test.dart b/pkg/vm_service/test/get_allocation_profile_rpc_test.dart index 82467322a31..5d5da830f96 100644 --- a/pkg/vm_service/test/get_allocation_profile_rpc_test.dart +++ b/pkg/vm_service/test/get_allocation_profile_rpc_test.dart @@ -65,7 +65,7 @@ var tests = [ }, ]; -main([args = const []]) async => runIsolateTests( +void main([args = const []]) => runIsolateTests( args, tests, 'get_allocation_profile_rpc_test.dart', diff --git a/pkg/vm_service/test/get_allocation_traces_test.dart b/pkg/vm_service/test/get_allocation_traces_test.dart index e85759217d9..86fc621c99c 100644 --- a/pkg/vm_service/test/get_allocation_traces_test.dart +++ b/pkg/vm_service/test/get_allocation_traces_test.dart @@ -23,7 +23,7 @@ class Bar { } void test() { - List l = []; + final List l = []; debugger(); // Toggled on for Foo. // Traced allocation. @@ -43,7 +43,7 @@ Future getClassFromRootLib( String className, ) async { final isolate = await service.getIsolate(isolateRef.id!); - Library rootLib = + final Library rootLib = (await service.getObject(isolate.id!, isolate.rootLib!.id!)) as Library; for (ClassRef cls in rootLib.classes!) { if (cls.name == className) { @@ -92,8 +92,10 @@ final tests = [ expect(instances.totalCount, 1); final instance = instances.instances!.first as InstanceRef; expect(instance.identityHashCode != 0, isTrue); - expect(instance.identityHashCode, - profileResponse.samples!.first.identityHashCode); + expect( + instance.identityHashCode, + profileResponse.samples!.first.identityHashCode, + ); await service.setTraceClassAllocation(isolate.id!, fooClass.id!, false); @@ -114,12 +116,12 @@ final tests = [ (VmService service, IsolateRef isolate) async { // Ensure the allocation of `Bar()` was recorded. - final profileResponse = (await service.getAllocationTraces(isolate.id!)); + final profileResponse = await service.getAllocationTraces(isolate.id!); expect(profileResponse.samples!.length, 2); }, ]; -main(args) async => runIsolateTests( +void main([args = const []]) => runIsolateTests( args, tests, 'get_allocation_traces_test.dart', diff --git a/pkg/vm_service/test/get_cpu_samples_rpc_test.dart b/pkg/vm_service/test/get_cpu_samples_rpc_test.dart index 6db717b1857..ed58b052f77 100644 --- a/pkg/vm_service/test/get_cpu_samples_rpc_test.dart +++ b/pkg/vm_service/test/get_cpu_samples_rpc_test.dart @@ -7,19 +7,19 @@ import 'package:vm_service/vm_service.dart'; import 'common/test_helper.dart'; -fib(n) { +int fib(n) { if (n < 0) return 0; if (n == 0) return 1; return fib(n - 1) + fib(n - 2); } -testeeDo() { +void testeeDo() { print('Testee doing something.'); fib(30); print('Testee did something.'); } -Future checkSamples(VmService service, IsolateRef isolate) async { +Future checkSamples(VmService service, IsolateRef isolate) async { // Grab all the samples. final isolateId = isolate.id!; final result = await service.getCpuSamples(isolateId, 0, ~0); @@ -27,8 +27,11 @@ Future checkSamples(VmService service, IsolateRef isolate) async { final isString = TypeMatcher(); final isInt = TypeMatcher(); final isList = TypeMatcher(); - expect(result.functions!.length, greaterThan(10), - reason: 'Should have many functions!'); + expect( + result.functions!.length, + greaterThan(10), + reason: 'Should have many functions!', + ); final samples = result.samples!; expect(samples.length, greaterThan(10), reason: 'Should have many samples'); @@ -46,16 +49,16 @@ Future checkSamples(VmService service, IsolateRef isolate) async { expect(sample.stack, isList); } -var tests = [ - ((VmService service, IsolateRef i) => checkSamples(service, i)), +final tests = [ + checkSamples, ]; -var vmArgs = [ +const vmArgs = [ '--profiler=true', '--profile-vm=false', // So this also works with KBC. ]; -main([args = const []]) async => runIsolateTests( +void main([args = const []]) => runIsolateTests( args, tests, 'get_cpu_samples_rpc_test.dart', diff --git a/pkg/vm_service/test/get_flag_list_rpc_test.dart b/pkg/vm_service/test/get_flag_list_rpc_test.dart index 8049299f116..e77b6f65195 100644 --- a/pkg/vm_service/test/get_flag_list_rpc_test.dart +++ b/pkg/vm_service/test/get_flag_list_rpc_test.dart @@ -30,7 +30,9 @@ final tests = [ // Modify a flag with the wrong value type. (VmService service) async { final Error result = (await service.setFlag( - 'pause_isolates_on_start', 'not-boolean')) as Error; + 'pause_isolates_on_start', + 'not-boolean', + )) as Error; expect(result.message, equals('Cannot set flag: invalid value')); }, diff --git a/pkg/vm_service/test/get_http_profile_test.dart b/pkg/vm_service/test/get_http_profile_test.dart index 5531d2dfbc4..8e2aeaeb574 100644 --- a/pkg/vm_service/test/get_http_profile_test.dart +++ b/pkg/vm_service/test/get_http_profile_test.dart @@ -58,10 +58,12 @@ Uri randomlyAddRequestParams(Uri uri) { possiblePathSegments.sublist(0, rng.nextInt(possiblePathSegments.length)); uri = uri.replace(pathSegments: segmentSubset); if (rng.nextInt(3) == 0) { - uri = uri.replace(queryParameters: { - 'foo': 'bar', - 'year': '2019', - }); + uri = uri.replace( + queryParameters: { + 'foo': 'bar', + 'year': '2019', + }, + ); } return uri; } @@ -78,7 +80,8 @@ Future startServer() async { } // Randomly delay response. await Future.delayed( - Duration(milliseconds: rng.nextInt(maxResponseDelayMs))); + Duration(milliseconds: rng.nextInt(maxResponseDelayMs)), + ); await response.close(); }); return server; @@ -305,7 +308,7 @@ void hasDefaultRequestHeaders(HttpProfile profile) { } void hasCustomRequestHeaders(HttpProfile profile) { - var requests = profile.requests.where((e) => e.method == 'GET').toList(); + final requests = profile.requests.where((e) => e.method == 'GET').toList(); for (final request in requests) { // Some requests are unable to complete due to the server closing after a // random delay. Don't try and inspect the request data from these diff --git a/pkg/vm_service/test/get_instances_as_array_rpc_test.dart b/pkg/vm_service/test/get_instances_as_array_rpc_test.dart index 97bea9e7fbd..0aeee659b50 100644 --- a/pkg/vm_service/test/get_instances_as_array_rpc_test.dart +++ b/pkg/vm_service/test/get_instances_as_array_rpc_test.dart @@ -44,9 +44,11 @@ final tests = [ const [], ); - Future instanceCount(String className, - {bool includeSubclasses = false, - bool includeImplementors = false}) async { + Future instanceCount( + String className, { + bool includeSubclasses = false, + bool includeImplementors = false, + }) async { final objectId = rootLib.classes!.singleWhere((cls) => cls.name == className).id!; final result = await service.getInstancesAsList( diff --git a/pkg/vm_service/test/get_instances_as_list_rpc_expression_evaluation_on_internal_test.dart b/pkg/vm_service/test/get_instances_as_list_rpc_expression_evaluation_on_internal_test.dart index cddd35fd030..29d02705517 100644 --- a/pkg/vm_service/test/get_instances_as_list_rpc_expression_evaluation_on_internal_test.dart +++ b/pkg/vm_service/test/get_instances_as_list_rpc_expression_evaluation_on_internal_test.dart @@ -25,7 +25,8 @@ final tests = [ if (error.code == 113 && error.message == 'Expression compilation error' && error.details.contains( - "invalid 'targetId' parameter: Cannot evaluate against a VM-internal object")) { + "invalid 'targetId' parameter: Cannot evaluate against a VM-internal object", + )) { gotError = true; return Response(); } else { @@ -47,5 +48,8 @@ final tests = [ } ]; -main([args = const []]) async => runIsolateTests(args, tests, - 'get_instances_as_list_rpc_expression_evaluation_on_internal_test.dart'); +void main([args = const []]) => runIsolateTests( + args, + tests, + 'get_instances_as_list_rpc_expression_evaluation_on_internal_test.dart', + ); diff --git a/pkg/vm_service/test/get_instances_as_list_rpc_test.dart b/pkg/vm_service/test/get_instances_as_list_rpc_test.dart index 36c4a0d31d6..c1429aca9aa 100644 --- a/pkg/vm_service/test/get_instances_as_list_rpc_test.dart +++ b/pkg/vm_service/test/get_instances_as_list_rpc_test.dart @@ -53,9 +53,11 @@ IsolateTest expectInstanceCounts( isolate.rootLib!.id!, ) as Library; - Future instanceCount(String className, - {bool includeSubclasses = false, - bool includeImplementers = false}) async { + Future instanceCount( + String className, { + bool includeSubclasses = false, + bool includeImplementers = false, + }) async { final result = await service.getInstancesAsList( isolateId, rootLib.classes! diff --git a/pkg/vm_service/test/get_instances_rpc_test.dart b/pkg/vm_service/test/get_instances_rpc_test.dart index cb92a8215ec..39a468858e6 100644 --- a/pkg/vm_service/test/get_instances_rpc_test.dart +++ b/pkg/vm_service/test/get_instances_rpc_test.dart @@ -41,9 +41,10 @@ void testMain() { } IsolateTest expectInstanceCounts( - int numInstances, - int numInstancesWhenIncludingSubclasses, - int numInstancesWhenIncludingImplementers) { + int numInstances, + int numInstancesWhenIncludingSubclasses, + int numInstancesWhenIncludingImplementers, +) { return (VmService service, IsolateRef isolateRef) async { final isolateId = isolateRef.id!; final isolate = await service.getIsolate(isolateId); @@ -52,9 +53,11 @@ IsolateTest expectInstanceCounts( isolate.rootLib!.id!, ) as Library; - Future instanceCount(String className, - {bool includeSubclasses = false, - bool includeImplementers = false}) async { + Future instanceCount( + String className, { + bool includeSubclasses = false, + bool includeImplementers = false, + }) async { final result = await service.getInstances( isolateId, rootLib.classes!.singleWhere((cls) => cls.name == className).id!, diff --git a/pkg/vm_service/test/get_isolate_group_memory_usage.dart b/pkg/vm_service/test/get_isolate_group_memory_usage.dart index dcef7b43fc0..36e6074b083 100644 --- a/pkg/vm_service/test/get_isolate_group_memory_usage.dart +++ b/pkg/vm_service/test/get_isolate_group_memory_usage.dart @@ -24,15 +24,17 @@ var tests = [ } on RPCError catch (e) { caughtException = true; expect( - e.details, - contains( - "getMemoryUsage: invalid 'isolateGroupId' parameter: badid")); + e.details, + contains( + "getMemoryUsage: invalid 'isolateGroupId' parameter: badid", + ), + ); } expect(caughtException, isTrue); }, ]; -main(args) async => runVMTests( +void main([args = const []]) => runVMTests( args, tests, 'get_isolate_group_memory_usage.dart', diff --git a/pkg/vm_service/test/get_isolate_pause_event_rpc_test.dart b/pkg/vm_service/test/get_isolate_pause_event_rpc_test.dart index 471a2174a78..8b777b490b0 100644 --- a/pkg/vm_service/test/get_isolate_pause_event_rpc_test.dart +++ b/pkg/vm_service/test/get_isolate_pause_event_rpc_test.dart @@ -7,7 +7,7 @@ import 'package:vm_service/vm_service.dart'; import 'common/test_helper.dart'; -var tests = [ +final tests = [ (VmService service) async { final vm = await service.getVM(); final result = await service.getIsolatePauseEvent(vm.isolates!.first.id!); @@ -33,7 +33,7 @@ var tests = [ }, ]; -main(args) async => runVMTests( +void main([args = const []]) => runVMTests( args, tests, 'get_isolate_pause_event_rpc_test.dart', diff --git a/pkg/vm_service/test/get_isolate_rpc_test.dart b/pkg/vm_service/test/get_isolate_rpc_test.dart index 95f82dfaaf0..0024b75406b 100644 --- a/pkg/vm_service/test/get_isolate_rpc_test.dart +++ b/pkg/vm_service/test/get_isolate_rpc_test.dart @@ -7,7 +7,7 @@ import 'package:vm_service/vm_service.dart'; import 'common/test_helper.dart'; -var tests = [ +final tests = [ (VmService service) async { final vm = await service.getVM(); final result = await service.getIsolate(vm.isolates!.first.id!); @@ -55,7 +55,7 @@ var tests = [ }, ]; -main([args = const []]) async => runVMTests( +void main([args = const []]) => runVMTests( args, tests, 'get_isolate_rpc_test.dart', diff --git a/pkg/vm_service/test/get_memory_usage_test.dart b/pkg/vm_service/test/get_memory_usage_test.dart index ccaea5cdd33..3466b8f44ff 100644 --- a/pkg/vm_service/test/get_memory_usage_test.dart +++ b/pkg/vm_service/test/get_memory_usage_test.dart @@ -7,7 +7,7 @@ import 'package:vm_service/vm_service.dart'; import 'common/test_helper.dart'; -var tests = [ +final tests = [ (VmService service) async { final vm = await service.getVM(); final result = await service.getMemoryUsage(vm.isolates!.first.id!); @@ -22,14 +22,16 @@ var tests = [ fail('Unreachable'); } on RPCError catch (e) { caughtException = true; - expect(e.details, - contains("getMemoryUsage: invalid 'isolateId' parameter: badid")); + expect( + e.details, + contains("getMemoryUsage: invalid 'isolateId' parameter: badid"), + ); } expect(caughtException, isTrue); }, ]; -main([args = const []]) async => runVMTests( +void main([args = const []]) => runVMTests( args, tests, 'get_memory_usage_test.dart', diff --git a/pkg/vm_service/test/get_object_rpc_test.dart b/pkg/vm_service/test/get_object_rpc_test.dart index f2731fae88f..5d1f52e8a0e 100644 --- a/pkg/vm_service/test/get_object_rpc_test.dart +++ b/pkg/vm_service/test/get_object_rpc_test.dart @@ -3,6 +3,8 @@ // BSD-style license that can be found in the LICENSE file. // @dart=3.0 +// ignore_for_file: library_private_types_in_public_api + library get_object_rpc_test; import 'dart:collection'; @@ -60,43 +62,44 @@ void warmup() { } @pragma('vm:entry-point') -getChattanooga() => 'Chattanooga'; +String getChattanooga() => 'Chattanooga'; @pragma('vm:entry-point') -getList() => [3, 2, 1]; +List getList() => [3, 2, 1]; @pragma('vm:entry-point') -getMap() => {'x': 3, 'y': 4, 'z': 5}; +Map getMap() => {'x': 3, 'y': 4, 'z': 5}; @pragma('vm:entry-point') -getSet() => {6, 7, 8}; +Set getSet() => {6, 7, 8}; @pragma('vm:entry-point') -getUint8List() => Uint8List.fromList([3, 2, 1]); +Uint8List getUint8List() => Uint8List.fromList([3, 2, 1]); @pragma('vm:entry-point') -getUint64List() => Uint64List.fromList([3, 2, 1]); +Uint64List getUint64List() => Uint64List.fromList([3, 2, 1]); @pragma('vm:entry-point') -getRecord() => (1, x: 2, 3.0, y: 4.0); +(int, double, {int x, double y}) getRecord() => (1, x: 2, 3.0, y: 4.0); @pragma('vm:entry-point') -getDummyClass() => _DummyClass(); +_DummyClass getDummyClass() => _DummyClass(); @pragma('vm:entry-point') -getDummyFinalClass() => _DummyFinalClass(); +_DummyFinalClass getDummyFinalClass() => _DummyFinalClass(); @pragma('vm:entry-point') -getDummyGenericSubClass() => _DummyGenericSubClass(); +_DummyGenericSubClass getDummyGenericSubClass() => + _DummyGenericSubClass(); @pragma('vm:entry-point') -getDummyInterfaceClass() => _DummyInterfaceClass(); +_DummyInterfaceClass getDummyInterfaceClass() => _DummyInterfaceClass(); @pragma('vm:entry-point') -getDummyClassWithMixins() => _DummyClassWithMixins(); +_DummyClassWithMixins getDummyClassWithMixins() => _DummyClassWithMixins(); @pragma('vm:entry-point') -getUserTag() => UserTag('Test Tag'); +UserTag getUserTag() => UserTag('Test Tag'); var tests = [ // null object. @@ -144,7 +147,11 @@ var tests = [ final isolate = await service.getIsolate(isolateId); // Call eval to get a Dart String. final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getChattanooga', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getChattanooga', + [], + ) as InstanceRef; final objectId = evalResult.id!; final result = await service.getObject(isolateId, objectId) as Instance; expect(result.kind, InstanceKind.kString); @@ -165,7 +172,11 @@ var tests = [ final isolate = await service.getIsolate(isolateId); // Call eval to get a Dart String. final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getChattanooga', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getChattanooga', + [], + ) as InstanceRef; final objectId = evalResult.id!; final result = await service.getObject(isolateId, objectId, count: 4) as Instance; @@ -187,10 +198,18 @@ var tests = [ final isolate = await service.getIsolate(isolateId); // Call eval to get a Dart String. final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getChattanooga', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getChattanooga', + [], + ) as InstanceRef; final objectId = evalResult.id!; - final result = await service.getObject(isolateId, objectId, - offset: 4, count: 6) as Instance; + final result = await service.getObject( + isolateId, + objectId, + offset: 4, + count: 6, + ) as Instance; expect(result.kind, InstanceKind.kString); expect(result.json!['_vmType'], equals('String')); expect(result.id, startsWith('objects/')); @@ -209,10 +228,18 @@ var tests = [ final isolate = await service.getIsolate(isolateId); // Call eval to get a Dart String. final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getChattanooga', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getChattanooga', + [], + ) as InstanceRef; final objectId = evalResult.id!; - final result = await service.getObject(isolateId, objectId, - offset: 100, count: 2) as Instance; + final result = await service.getObject( + isolateId, + objectId, + offset: 100, + count: 2, + ) as Instance; expect(result.kind, InstanceKind.kString); expect(result.json!['_vmType'], equals('String')); expect(result.id, startsWith('objects/')); @@ -295,8 +322,12 @@ var tests = [ final evalResult = await service .invoke(isolateId, isolate.rootLib!.id!, 'getList', []) as InstanceRef; final objectId = evalResult.id!; - final result = await service.getObject(isolateId, objectId, - offset: 2, count: 2) as Instance; + final result = await service.getObject( + isolateId, + objectId, + offset: 2, + count: 2, + ) as Instance; expect(result.kind, InstanceKind.kList); expect(result.json!['_vmType'], equals('GrowableObjectArray')); expect(result.id, startsWith('objects/')); @@ -322,8 +353,12 @@ var tests = [ final evalResult = await service .invoke(isolateId, isolate.rootLib!.id!, 'getList', []) as InstanceRef; final objectId = evalResult.id!; - final result = await service.getObject(isolateId, objectId, - offset: 100, count: 2) as Instance; + final result = await service.getObject( + isolateId, + objectId, + offset: 100, + count: 2, + ) as Instance; expect(result.kind, InstanceKind.kList); expect(result.json!['_vmType'], equals('GrowableObjectArray')); expect(result.id, startsWith('objects/')); @@ -422,8 +457,12 @@ var tests = [ final evalResult = await service .invoke(isolateId, isolate.rootLib!.id!, 'getMap', []) as InstanceRef; final objectId = evalResult.id!; - final result = await service.getObject(isolateId, objectId, - offset: 2, count: 2) as Instance; + final result = await service.getObject( + isolateId, + objectId, + offset: 2, + count: 2, + ) as Instance; expect(result.kind, InstanceKind.kMap); expect(result.json!['_vmType'], equals('Map')); expect(result.id, startsWith('objects/')); @@ -452,8 +491,12 @@ var tests = [ final evalResult = await service .invoke(isolateId, isolate.rootLib!.id!, 'getMap', []) as InstanceRef; final objectId = evalResult.id!; - final result = await service.getObject(isolateId, objectId, - offset: 100, count: 2) as Instance; + final result = await service.getObject( + isolateId, + objectId, + offset: 100, + count: 2, + ) as Instance; expect(result.kind, InstanceKind.kMap); expect(result.json!['_vmType'], equals('Map')); expect(result.id, startsWith('objects/')); @@ -505,7 +548,11 @@ var tests = [ final isolate = await service.getIsolate(isolateId); // Call eval to get a Dart list. final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getUint8List', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getUint8List', + [], + ) as InstanceRef; final objectId = evalResult.id!; final result = await service.getObject(isolateId, objectId) as Instance; expect(result.kind, InstanceKind.kUint8List); @@ -519,7 +566,7 @@ var tests = [ expect(result.offset, isNull); expect(result.count, isNull); expect(result.bytes, equals('AwIB')); - Uint8List bytes = base64Decode(result.bytes!); + final Uint8List bytes = base64Decode(result.bytes!); expect(bytes.buffer.asUint8List().toString(), equals('[3, 2, 1]')); }, @@ -529,7 +576,11 @@ var tests = [ final isolate = await service.getIsolate(isolateId); // Call eval to get a Dart list. final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getUint8List', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getUint8List', + [], + ) as InstanceRef; final objectId = evalResult.id!; final result = await service.getObject(isolateId, objectId, count: 2) as Instance; @@ -544,7 +595,7 @@ var tests = [ expect(result.offset, isNull); expect(result.count, equals(2)); expect(result.bytes, equals('AwI=')); - Uint8List bytes = base64Decode(result.bytes!); + final Uint8List bytes = base64Decode(result.bytes!); expect(bytes.buffer.asUint8List().toString(), equals('[3, 2]')); }, @@ -554,10 +605,18 @@ var tests = [ final isolate = await service.getIsolate(isolateId); // Call eval to get a Dart list. final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getUint8List', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getUint8List', + [], + ) as InstanceRef; final objectId = evalResult.id!; - final result = await service.getObject(isolateId, objectId, - offset: 2, count: 2) as Instance; + final result = await service.getObject( + isolateId, + objectId, + offset: 2, + count: 2, + ) as Instance; expect(result.kind, InstanceKind.kUint8List); expect(result.json!['_vmType'], equals('TypedData')); expect(result.id, startsWith('objects/')); @@ -569,7 +628,7 @@ var tests = [ expect(result.offset, equals(2)); expect(result.count, equals(1)); expect(result.bytes, equals('AQ==')); - Uint8List bytes = base64Decode(result.bytes!); + final Uint8List bytes = base64Decode(result.bytes!); expect(bytes.buffer.asUint8List().toString(), equals('[1]')); }, @@ -579,10 +638,18 @@ var tests = [ final isolate = await service.getIsolate(isolateId); // Call eval to get a Dart list. final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getUint8List', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getUint8List', + [], + ) as InstanceRef; final objectId = evalResult.id!; - final result = await service.getObject(isolateId, objectId, - offset: 100, count: 2) as Instance; + final result = await service.getObject( + isolateId, + objectId, + offset: 100, + count: 2, + ) as Instance; expect(result.kind, InstanceKind.kUint8List); expect(result.json!['_vmType'], equals('TypedData')); expect(result.id, startsWith('objects/')); @@ -602,7 +669,11 @@ var tests = [ final isolate = await service.getIsolate(isolateId); // Call eval to get a Dart list. final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getUint64List', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getUint64List', + [], + ) as InstanceRef; final objectId = evalResult.id!; final result = await service.getObject(isolateId, objectId) as Instance; expect(result.kind, InstanceKind.kUint64List); @@ -616,7 +687,7 @@ var tests = [ expect(result.offset, isNull); expect(result.count, isNull); expect(result.bytes, equals('AwAAAAAAAAACAAAAAAAAAAEAAAAAAAAA')); - Uint8List bytes = base64Decode(result.bytes!); + final Uint8List bytes = base64Decode(result.bytes!); expect(bytes.buffer.asUint64List().toString(), equals('[3, 2, 1]')); }, @@ -626,7 +697,11 @@ var tests = [ final isolate = await service.getIsolate(isolateId); // Call eval to get a Dart list. final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getUint64List', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getUint64List', + [], + ) as InstanceRef; final objectId = evalResult.id!; final result = await service.getObject(isolateId, objectId, count: 2) as Instance; @@ -641,7 +716,7 @@ var tests = [ expect(result.offset, isNull); expect(result.count, equals(2)); expect(result.bytes, equals('AwAAAAAAAAACAAAAAAAAAA==')); - Uint8List bytes = base64Decode(result.bytes!); + final Uint8List bytes = base64Decode(result.bytes!); expect(bytes.buffer.asUint64List().toString(), equals('[3, 2]')); }, @@ -651,10 +726,18 @@ var tests = [ final isolate = await service.getIsolate(isolateId); // Call eval to get a Dart list. final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getUint64List', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getUint64List', + [], + ) as InstanceRef; final objectId = evalResult.id!; - final result = await service.getObject(isolateId, objectId, - offset: 2, count: 2) as Instance; + final result = await service.getObject( + isolateId, + objectId, + offset: 2, + count: 2, + ) as Instance; expect(result.kind, InstanceKind.kUint64List); expect(result.json!['_vmType'], equals('TypedData')); expect(result.id, startsWith('objects/')); @@ -666,7 +749,7 @@ var tests = [ expect(result.offset, equals(2)); expect(result.count, equals(1)); expect(result.bytes, equals('AQAAAAAAAAA=')); - Uint8List bytes = base64Decode(result.bytes!); + final Uint8List bytes = base64Decode(result.bytes!); expect(bytes.buffer.asUint64List().toString(), equals('[1]')); }, @@ -676,10 +759,18 @@ var tests = [ final isolate = await service.getIsolate(isolateId); // Call eval to get a Dart list. final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getUint64List', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getUint64List', + [], + ) as InstanceRef; final objectId = evalResult.id!; - final result = await service.getObject(isolateId, objectId, - offset: 100, count: 2) as Instance; + final result = await service.getObject( + isolateId, + objectId, + offset: 100, + count: 2, + ) as Instance; expect(result.kind, InstanceKind.kUint64List); expect(result.json!['_vmType'], equals('TypedData')); expect(result.id, startsWith('objects/')); @@ -724,7 +815,8 @@ var tests = [ expect(result.size, isPositive); expect(result.length, 4); final fieldsMap = HashMap.fromEntries( - result.fields!.map((f) => MapEntry(f.name, f.value))); + result.fields!.map((f) => MapEntry(f.name, f.value)), + ); expect(fieldsMap.keys.length, result.length); // [BoundField]s have fields with type [dynamic], and such fields have // broken [toJson()] in the past. So, we make the following call just to @@ -814,7 +906,11 @@ var tests = [ final isolateId = isolateRef.id!; final isolate = await service.getIsolate(isolateId); final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getDummyClass', + [], + ) as InstanceRef; final objectId = evalResult.id!; final result = await service.getObject(isolateId, objectId) as Instance; expect(result.kind, InstanceKind.kPlainInstance); @@ -826,16 +922,21 @@ var tests = [ expect(result.size, isPositive); expect(result.length, 3); final fieldsMap = HashMap.fromEntries( - result.fields!.map((f) => MapEntry(f.name, f.value))); + result.fields!.map((f) => MapEntry(f.name, f.value)), + ); expect(fieldsMap.keys.length, result.length); expect(fieldsMap.containsKey('dummyList'), true); expect((fieldsMap['dummyList'] as InstanceRef).kind, InstanceKind.kList); expect(fieldsMap.containsKey('dummyLateVarWithInit'), true); - expect((fieldsMap['dummyLateVarWithInit'] as Sentinel).kind, - SentinelKind.kNotInitialized); + expect( + (fieldsMap['dummyLateVarWithInit'] as Sentinel).kind, + SentinelKind.kNotInitialized, + ); expect(fieldsMap.containsKey('dummyLateVar'), true); - expect((fieldsMap['dummyLateVar'] as Sentinel).kind, - SentinelKind.kNotInitialized); + expect( + (fieldsMap['dummyLateVar'] as Sentinel).kind, + SentinelKind.kNotInitialized, + ); }, // An abstract base mixin class. @@ -844,7 +945,11 @@ var tests = [ final isolate = await service.getIsolate(isolateId); // Use invoke to get a reference to an instance of [_DummyClass]. final invokeResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getDummyClass', + [], + ) as InstanceRef; final derivedClass = await service.getObject(isolateId, invokeResult.classRef!.id!) as Class; final baseClassRef = derivedClass.superClass!; @@ -884,7 +989,11 @@ var tests = [ final isolate = await service.getIsolate(isolateId); // Use invoke to get a reference to an instance of [_DummyClass]. final invokeResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getDummyClass', + [], + ) as InstanceRef; final result = await service.getObject(isolateId, invokeResult.classRef!.id!) as Class; expect(result.id, startsWith('classes/')); @@ -921,8 +1030,11 @@ var tests = [ final isolate = await service.getIsolate(isolateId); // Use invoke to get a reference to an instance of [_DummyGenericSubClass]. final invokeResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getDummyGenericSubClass', []) - as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getDummyGenericSubClass', + [], + ) as InstanceRef; final result = await service.getObject(isolateId, invokeResult.classRef!.id!) as Class; expect(result.id, startsWith('classes/')); @@ -997,8 +1109,11 @@ var tests = [ final isolate = await service.getIsolate(isolateId); // Use invoke to get a reference to an instance of [_DummyInterfaceClass]. final invokeResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getDummyInterfaceClass', []) - as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getDummyInterfaceClass', + [], + ) as InstanceRef; final derivedClass = await service.getObject(isolateId, invokeResult.classRef!.id!) as Class; final baseClassRef = derivedClass.superClass!; @@ -1038,8 +1153,11 @@ var tests = [ final isolate = await service.getIsolate(isolateId); // Use invoke to get a reference to an instance of [_DummyInterfaceClass]. final invokeResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getDummyInterfaceClass', []) - as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getDummyInterfaceClass', + [], + ) as InstanceRef; final result = await service.getObject(isolateId, invokeResult.classRef!.id!) as Class; expect(result.id, startsWith('classes/')); @@ -1076,16 +1194,23 @@ var tests = [ final isolate = await service.getIsolate(isolateId); // Use invoke to get a reference to an instance of [_DummyClassWithMixins]. final dummyClassInstanceRef = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getDummyClassWithMixins', []) - as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getDummyClassWithMixins', + [], + ) as InstanceRef; final dummyClass = await service.getObject( - isolateId, dummyClassInstanceRef.classRef!.id!) as Class; + isolateId, + dummyClassInstanceRef.classRef!.id!, + ) as Class; final dummyClassWithTwoMixinsApplied = await service.getObject(isolateId, dummyClass.superClass!.id!) as Class; expect(dummyClassWithTwoMixinsApplied.id, startsWith('classes/')); - expect(dummyClassWithTwoMixinsApplied.name, - '__DummyClassWithMixins&Object&_DummyBaseMixin&_DummyMixin'); + expect( + dummyClassWithTwoMixinsApplied.name, + '__DummyClassWithMixins&Object&_DummyBaseMixin&_DummyMixin', + ); expect(dummyClassWithTwoMixinsApplied.isAbstract, true); expect(dummyClassWithTwoMixinsApplied.isConst, true); expect(dummyClassWithTwoMixinsApplied.isSealed, false); @@ -1105,23 +1230,31 @@ var tests = [ final dummyClassWithTwoMixinsAppliedJson = dummyClassWithTwoMixinsApplied.json!; expect( - dummyClassWithTwoMixinsAppliedJson['_vmName'], - startsWith( - '__DummyClassWithMixins&Object&_DummyBaseMixin&_DummyMixin@')); + dummyClassWithTwoMixinsAppliedJson['_vmName'], + startsWith( + '__DummyClassWithMixins&Object&_DummyBaseMixin&_DummyMixin@', + ), + ); expect(dummyClassWithTwoMixinsAppliedJson['_finalized'], true); expect(dummyClassWithTwoMixinsAppliedJson['_implemented'], false); expect(dummyClassWithTwoMixinsAppliedJson['_patch'], false); expect(dummyClassWithTwoMixinsApplied.interfaces!.length, 1); - expect(dummyClassWithTwoMixinsApplied.interfaces!.first, - dummyClassWithTwoMixinsApplied.mixin!); + expect( + dummyClassWithTwoMixinsApplied.interfaces!.first, + dummyClassWithTwoMixinsApplied.mixin!, + ); final dummyMixinType = await service.getObject( - isolateId, dummyClassWithTwoMixinsApplied.mixin!.id!) as Instance; + isolateId, + dummyClassWithTwoMixinsApplied.mixin!.id!, + ) as Instance; expect(dummyMixinType.kind, InstanceKind.kType); expect(dummyMixinType.id, startsWith('classes/')); expect(dummyMixinType.name, '_DummyMixin'); final dummyMixinClass = await service.getObject( - isolateId, dummyMixinType.typeClass!.id!) as Class; + isolateId, + dummyMixinType.typeClass!.id!, + ) as Class; expect(dummyMixinClass.id, startsWith('classes/')); expect(dummyMixinClass.name, '_DummyMixin'); expect(dummyMixinClass.isAbstract, true); @@ -1149,10 +1282,14 @@ var tests = [ expect(dummyMixinClassJson['_patch'], false); final dummyClassWithOneMixinApplied = await service.getObject( - isolateId, dummyClassWithTwoMixinsApplied.superClass!.id!) as Class; + isolateId, + dummyClassWithTwoMixinsApplied.superClass!.id!, + ) as Class; expect(dummyClassWithOneMixinApplied.id, startsWith('classes/')); - expect(dummyClassWithOneMixinApplied.name, - '__DummyClassWithMixins&Object&_DummyBaseMixin'); + expect( + dummyClassWithOneMixinApplied.name, + '__DummyClassWithMixins&Object&_DummyBaseMixin', + ); expect(dummyClassWithOneMixinApplied.isAbstract, true); expect(dummyClassWithOneMixinApplied.isConst, true); expect(dummyClassWithOneMixinApplied.isSealed, false); @@ -1171,22 +1308,30 @@ var tests = [ expect(dummyClassWithOneMixinApplied.subclasses!.length, 1); final dummyClassWithOneMixinAppliedJson = dummyClassWithOneMixinApplied.json!; - expect(dummyClassWithOneMixinAppliedJson['_vmName'], - startsWith('__DummyClassWithMixins&Object&_DummyBaseMixin@')); + expect( + dummyClassWithOneMixinAppliedJson['_vmName'], + startsWith('__DummyClassWithMixins&Object&_DummyBaseMixin@'), + ); expect(dummyClassWithOneMixinAppliedJson['_finalized'], true); expect(dummyClassWithOneMixinAppliedJson['_implemented'], false); expect(dummyClassWithOneMixinAppliedJson['_patch'], false); expect(dummyClassWithOneMixinApplied.interfaces!.length, 1); - expect(dummyClassWithOneMixinApplied.interfaces!.first, - dummyClassWithOneMixinApplied.mixin!); + expect( + dummyClassWithOneMixinApplied.interfaces!.first, + dummyClassWithOneMixinApplied.mixin!, + ); final dummyBaseMixinType = await service.getObject( - isolateId, dummyClassWithOneMixinApplied.mixin!.id!) as Instance; + isolateId, + dummyClassWithOneMixinApplied.mixin!.id!, + ) as Instance; expect(dummyBaseMixinType.kind, InstanceKind.kType); expect(dummyBaseMixinType.id, startsWith('classes/')); expect(dummyBaseMixinType.name, '_DummyBaseMixin'); final dummyBaseMixinClass = await service.getObject( - isolateId, dummyBaseMixinType.typeClass!.id!) as Class; + isolateId, + dummyBaseMixinType.typeClass!.id!, + ) as Class; expect(dummyBaseMixinClass.id, startsWith('classes/')); expect(dummyBaseMixinClass.name, '_DummyBaseMixin'); expect(dummyBaseMixinClass.isAbstract, true); @@ -1233,7 +1378,11 @@ var tests = [ final isolate = await service.getIsolate(isolateId); // Call eval to get a class id. final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getDummyClass', + [], + ) as InstanceRef; final objectId = '${evalResult.classRef!.id!}/types/0'; final result = await service.getObject(isolateId, objectId) as Instance; expect(result.kind, InstanceKind.kType); @@ -1249,7 +1398,11 @@ var tests = [ final isolateId = isolateRef.id!; final isolate = await service.getIsolate(isolateId); final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getDummyClass', + [], + ) as InstanceRef; final objectId = '${evalResult.classRef!.id!}/types/9999999'; try { await service.getObject(isolateId, objectId); @@ -1267,7 +1420,11 @@ var tests = [ // Call [invoke] to get an [InstanceRef], and then use the ID of its // [classRef] field to build a function ID. final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getDummyClass', + [], + ) as InstanceRef; final objectId = '${evalResult.classRef!.id!}/functions/dummyFunction'; final result = await service.getObject(isolateId, objectId) as Func; expect(result.id, equals(objectId)); @@ -1305,7 +1462,11 @@ var tests = [ // Call [invoke] to get an [InstanceRef], and then use the ID of its // [classRef] field to build a function ID. final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getDummyClass', + [], + ) as InstanceRef; final objectId = '${evalResult.classRef!.id!}/functions/dummyGenericFunction'; final result = await service.getObject(isolateId, objectId) as Func; @@ -1345,7 +1506,11 @@ var tests = [ final isolate = await service.getIsolate(isolateId); // Call eval to get a class id. final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getDummyClass', + [], + ) as InstanceRef; final objectId = evalResult.classRef!.id!; final result = await service.getObject(isolateId, objectId) as Class; expect(result.id, startsWith('classes/')); @@ -1398,7 +1563,11 @@ var tests = [ final isolate = await service.getIsolate(isolateId); // Call eval to get a class id. final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getDummyClass', + [], + ) as InstanceRef; final objectId = '${evalResult.classRef!.id!}/functions/invalid'; try { await service.getObject(isolateId, objectId); @@ -1415,7 +1584,11 @@ var tests = [ final isolate = await service.getIsolate(isolateId); // Call eval to get a class id. final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getDummyClass', + [], + ) as InstanceRef; final objectId = '${evalResult.classRef!.id!}/fields/dummyVar'; final result = await service.getObject(isolateId, objectId) as Field; expect(result.id, equals(objectId)); @@ -1438,7 +1611,11 @@ var tests = [ // Call [invoke] to get an [InstanceRef], and then use the ID of its // [classRef] field to build a function ID. final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getDummyClass', + [], + ) as InstanceRef; final objectId = "${evalResult.classRef!.id!}/functions/get${Uri.encodeComponent(':')}dummyVarGetter"; final result = await service.getObject(isolateId, objectId) as Func; @@ -1473,7 +1650,11 @@ var tests = [ // Call [invoke] to get an [InstanceRef], and then use the ID of its // [classRef] field to build a function ID. final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getDummyClass', + [], + ) as InstanceRef; final objectId = "${evalResult.classRef!.id!}/functions/set${Uri.encodeComponent(':')}dummyVarSetter"; final result = await service.getObject(isolateId, objectId) as Func; @@ -1510,7 +1691,11 @@ var tests = [ // Call [invoke] to get an [InstanceRef], and then use the ID of its // [classRef] field to build a function ID. final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getDummyClass', + [], + ) as InstanceRef; final objectId = '${evalResult.classRef!.id!}/field_inits/dummyVarWithInit'; final result = await service.getObject(isolateId, objectId) as Func; expect(result.id, equals(objectId)); @@ -1543,7 +1728,11 @@ var tests = [ // Call [invoke] to get an [InstanceRef], and then use the ID of its // [classRef] field to build a function ID. final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getDummyClass', + [], + ) as InstanceRef; final objectId = '${evalResult.classRef!.id!}/field_inits/dummyLateVarWithInit'; final result = await service.getObject(isolateId, objectId) as Func; @@ -1576,7 +1765,11 @@ var tests = [ final isolate = await service.getIsolate(isolateId); // Call eval to get a class id. final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getDummyClass', + [], + ) as InstanceRef; final objectId = '${evalResult.classRef!.id!}/field_inits/dummyLateVar'; try { await service.getObject(isolateId, objectId); @@ -1591,15 +1784,20 @@ var tests = [ final isolateId = isolateRef.id!; final isolate = await service.getIsolate(isolateId); final flagList = await service.getFlagList(); - if (!flagList.flags!.any((flag) => - flag.name == 'use_field_guards' && flag.valueAsString == 'true')) { + if (!flagList.flags!.any( + (flag) => flag.name == 'use_field_guards' && flag.valueAsString == 'true', + )) { // Skip the test if guards are not enabled. return; } // Call eval to get a class id. final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getDummyClass', + [], + ) as InstanceRef; final objectId = '${evalResult.classRef!.id!}/fields/dummyList'; final result = await service.getObject(isolateId, objectId) as Field; expect(result.id, equals(objectId)); @@ -1620,7 +1818,11 @@ var tests = [ final isolate = await service.getIsolate(isolateId); // Call eval to get a class id. final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getDummyClass', + [], + ) as InstanceRef; final objectId = '${evalResult.classRef!.id!}/fields/mythicalField'; try { await service.getObject(isolateId, objectId); @@ -1649,7 +1851,11 @@ var tests = [ final isolate = await service.getIsolate(isolateId); // Call eval to get a class id. final evalResult = await service.invoke( - isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'getDummyClass', + [], + ) as InstanceRef; final objectId = '${evalResult.classRef!.id!}/functions/dummyFunction'; final funcResult = await service.getObject(isolateId, objectId) as Func; final result = @@ -1683,6 +1889,9 @@ var tests = [ }, ]; -main([args = const []]) async => - runIsolateTests(args, tests, 'get_object_rpc_test.dart', - testeeBefore: warmup); +void main([args = const []]) => runIsolateTests( + args, + tests, + 'get_object_rpc_test.dart', + testeeBefore: warmup, + ); diff --git a/pkg/vm_service/test/get_perfetto_cpu_samples_rpc_test.dart b/pkg/vm_service/test/get_perfetto_cpu_samples_rpc_test.dart index a3895e02f90..0d2d03b1fc0 100644 --- a/pkg/vm_service/test/get_perfetto_cpu_samples_rpc_test.dart +++ b/pkg/vm_service/test/get_perfetto_cpu_samples_rpc_test.dart @@ -33,7 +33,8 @@ int computeTimeExtentNanos(List packets, int timeOrigin) { } int largestExtent = packetsWithPerfSamples[0].timestamp.toInt() - timeOrigin; for (var i = 0; i < packetsWithPerfSamples.length; i++) { - int duration = packetsWithPerfSamples[i].timestamp.toInt() - timeOrigin; + final int duration = + packetsWithPerfSamples[i].timestamp.toInt() - timeOrigin; if (duration > largestExtent) { largestExtent = duration; } @@ -42,7 +43,8 @@ int computeTimeExtentNanos(List packets, int timeOrigin) { } Iterable extractPerfSamplesFromTracePackets( - List packets) { + List packets, +) { return packets .where((packet) => packet.hasPerfSample()) .map((packet) => packet.perfSample); @@ -81,18 +83,24 @@ final tests = [ final timeOriginNanos = computeTimeOriginNanos(packets); final timeExtentNanos = computeTimeExtentNanos(packets, timeOriginNanos); // Query for the samples within the time window. - final filteredResult = await service.getPerfettoCpuSamples(isolateRef.id!, - timeOriginMicros: timeOriginNanos ~/ 1000, - timeExtentMicros: timeExtentNanos ~/ 1000); + final filteredResult = await service.getPerfettoCpuSamples( + isolateRef.id!, + timeOriginMicros: timeOriginNanos ~/ 1000, + timeExtentMicros: timeExtentNanos ~/ 1000, + ); // Verify that we have the same number of [PerfSample]s. final filteredTrace = Trace.fromBuffer(base64Decode(filteredResult.samples!)); - expect(extractPerfSamplesFromTracePackets(filteredTrace.packet).length, - extractPerfSamplesFromTracePackets(packets).length); + expect( + extractPerfSamplesFromTracePackets(filteredTrace.packet).length, + extractPerfSamplesFromTracePackets(packets).length, + ); }, ]; -main([args = const []]) async { - await runIsolateTests(args, tests, 'get_perfetto_cpu_samples_rpc_test.dart', - extraArgs: ['--profiler=true']); -} +void main([args = const []]) => runIsolateTests( + args, + tests, + 'get_perfetto_cpu_samples_rpc_test.dart', + extraArgs: ['--profiler=true'], + ); diff --git a/pkg/vm_service/test/get_perfetto_vm_timeline_rpc_test.dart b/pkg/vm_service/test/get_perfetto_vm_timeline_rpc_test.dart index 376592d27c1..1cfec638820 100644 --- a/pkg/vm_service/test/get_perfetto_vm_timeline_rpc_test.dart +++ b/pkg/vm_service/test/get_perfetto_vm_timeline_rpc_test.dart @@ -20,8 +20,10 @@ void primeTimeline() { final parentTask = TimelineTask.withTaskId(42); final task = TimelineTask(parent: parentTask, filterKey: 'testFilter'); task.start('TASK1', arguments: {'task1-start-key': 'task1-start-value'}); - task.instant('ITASK', - arguments: {'task1-instant-key': 'task1-instant-value'}); + task.instant( + 'ITASK', + arguments: {'task1-instant-key': 'task1-instant-value'}, + ); task.finish(arguments: {'task1-finish-key': 'task1-finish-value'}); final flow = Flow.begin(id: 123); @@ -34,23 +36,27 @@ void primeTimeline() { } Iterable extractTrackEventsFromTracePackets( - List packets) { + List packets, +) { return packets .where((packet) => packet.hasTrackEvent()) .map((packet) => packet.trackEvent); } Map mapFromListOfDebugAnnotations( - List debugAnnotations) { - return HashMap.fromEntries(debugAnnotations.map((a) { - if (a.hasStringValue()) { - return MapEntry(a.name, a.stringValue); - } else if (a.hasLegacyJsonValue()) { - return MapEntry(a.name, a.legacyJsonValue); - } else { - throw 'We should not be writing annotations without values'; - } - })); + List debugAnnotations, +) { + return HashMap.fromEntries( + debugAnnotations.map((a) { + if (a.hasStringValue()) { + return MapEntry(a.name, a.stringValue); + } else if (a.hasLegacyJsonValue()) { + return MapEntry(a.name, a.legacyJsonValue); + } else { + throw 'We should not be writing annotations without values'; + } + }), + ); } void checkThatAllEventsHaveIsolateNumbers(Iterable events) { @@ -72,14 +78,21 @@ bool mapContains(Map map, Map submap) { } int countNumberOfEventsOfType( - Iterable events, TrackEvent_Type type) { + Iterable events, + TrackEvent_Type type, +) { return events.where((event) { return event.type == type; }).length; } -bool eventsContains(Iterable events, TrackEvent_Type type, - {String? name, int? flowId, Map? arguments}) { +bool eventsContains( + Iterable events, + TrackEvent_Type type, { + String? name, + int? flowId, + Map? arguments, +}) { return events.any((event) { if (event.type != type) { return false; @@ -95,8 +108,10 @@ bool eventsContains(Iterable events, TrackEvent_Type type, return arguments == null; } else { final Map dartArguments = jsonDecode( - mapFromListOfDebugAnnotations( - event.debugAnnotations)['Dart Arguments']!); + mapFromListOfDebugAnnotations( + event.debugAnnotations, + )['Dart Arguments']!, + ); if (arguments == null) { return dartArguments.isEmpty; } else { @@ -129,7 +144,7 @@ int computeTimeExtentNanos(List packets, int timeOrigin) { } int largestExtent = packetsWithEvents[0].timestamp.toInt() - timeOrigin; for (var i = 0; i < packetsWithEvents.length; i++) { - int duration = packetsWithEvents[i].timestamp.toInt() - timeOrigin; + final int duration = packetsWithEvents[i].timestamp.toInt() - timeOrigin; if (duration > largestExtent) { largestExtent = duration; } @@ -154,70 +169,105 @@ final tests = [ countNumberOfEventsOfType(events, TrackEvent_Type.TYPE_SLICE_END), ); expect( - eventsContains(events, TrackEvent_Type.TYPE_INSTANT, - name: 'ISYNC', arguments: {'fruit': 'banana'}), - true); + eventsContains( + events, + TrackEvent_Type.TYPE_INSTANT, + name: 'ISYNC', + arguments: {'fruit': 'banana'}, + ), + true, + ); expect( - eventsContains(events, TrackEvent_Type.TYPE_SLICE_BEGIN, name: 'apple'), - true); + eventsContains(events, TrackEvent_Type.TYPE_SLICE_BEGIN, name: 'apple'), + true, + ); expect( - eventsContains(events, TrackEvent_Type.TYPE_SLICE_BEGIN, - name: 'TASK1', - arguments: { - 'filterKey': 'testFilter', - 'task1-start-key': 'task1-start-value', - 'parentId': 42.toRadixString(16) - }), - true); + eventsContains( + events, + TrackEvent_Type.TYPE_SLICE_BEGIN, + name: 'TASK1', + arguments: { + 'filterKey': 'testFilter', + 'task1-start-key': 'task1-start-value', + 'parentId': 42.toRadixString(16), + }, + ), + true, + ); expect( - eventsContains(events, TrackEvent_Type.TYPE_SLICE_END, arguments: { + eventsContains( + events, + TrackEvent_Type.TYPE_SLICE_END, + arguments: { 'filterKey': 'testFilter', 'task1-finish-key': 'task1-finish-value', - }), - true); + }, + ), + true, + ); expect( - eventsContains(events, TrackEvent_Type.TYPE_INSTANT, - name: 'ITASK', - arguments: { - 'filterKey': 'testFilter', - 'task1-instant-key': 'task1-instant-value', - }), - true); + eventsContains( + events, + TrackEvent_Type.TYPE_INSTANT, + name: 'ITASK', + arguments: { + 'filterKey': 'testFilter', + 'task1-instant-key': 'task1-instant-value', + }, + ), + true, + ); expect( - eventsContains(events, TrackEvent_Type.TYPE_SLICE_BEGIN, - name: 'peach', flowId: 123), - true); + eventsContains( + events, + TrackEvent_Type.TYPE_SLICE_BEGIN, + name: 'peach', + flowId: 123, + ), + true, + ); expect( - eventsContains(events, TrackEvent_Type.TYPE_SLICE_BEGIN, - name: 'watermelon', flowId: 123), - true); + eventsContains( + events, + TrackEvent_Type.TYPE_SLICE_BEGIN, + name: 'watermelon', + flowId: 123, + ), + true, + ); expect( - eventsContains(events, TrackEvent_Type.TYPE_SLICE_BEGIN, - name: 'pear', flowId: 123), - true); + eventsContains( + events, + TrackEvent_Type.TYPE_SLICE_BEGIN, + name: 'pear', + flowId: 123, + ), + true, + ); // Calculate the time window of events. final timeOriginNanos = computeTimeOriginNanos(packets); final timeExtentNanos = computeTimeExtentNanos(packets, timeOriginNanos); // Query for the timeline with the time window. final filteredResult = await service.getPerfettoVMTimeline( - timeOriginMicros: timeOriginNanos ~/ 1000, - timeExtentMicros: timeExtentNanos ~/ 1000); + timeOriginMicros: timeOriginNanos ~/ 1000, + timeExtentMicros: timeExtentNanos ~/ 1000, + ); // Verify that we have the same number of events. final filteredTrace = Trace.fromBuffer(base64Decode(filteredResult.trace!)); - expect(extractTrackEventsFromTracePackets(filteredTrace.packet).length, - events.length); + expect( + extractTrackEventsFromTracePackets(filteredTrace.packet).length, + events.length, + ); }, ]; -main([args = const []]) async { - await runVMTests( - args, tests, 'get_perfetto_vm_timeline_rpc_test.dart', - testeeBefore: primeTimeline, - // TODO(derekx): runtime/observatory/tests/service/get_vm_timeline_rpc_test - // runs with --complete-timeline, but for performance reasons, we cannot do - // the same until this [runVMTests] method supports the [executableArgs] and - // [compileToKernelFirst] parameters. - extraArgs: ['--timeline-streams=Dart'], - ); -} +void main([args = const []]) => runVMTests( + args, tests, 'get_perfetto_vm_timeline_rpc_test.dart', + testeeBefore: primeTimeline, + // TODO(derekx): runtime/observatory/tests/service/get_vm_timeline_rpc_test + // runs with --complete-timeline, but for performance reasons, we cannot do + // the same until this [runVMTests] method supports the [executableArgs] and + // [compileToKernelFirst] parameters. + extraArgs: ['--timeline-streams=Dart'], + ); diff --git a/pkg/vm_service/test/get_retaining_path_rpc_test.dart b/pkg/vm_service/test/get_retaining_path_rpc_test.dart index 435cbcb7363..027fd397304 100644 --- a/pkg/vm_service/test/get_retaining_path_rpc_test.dart +++ b/pkg/vm_service/test/get_retaining_path_rpc_test.dart @@ -59,62 +59,62 @@ void warmup() { } @pragma('vm:entry-point') // Prevent obfuscation -getGlobalObject() => globalObject; +_TestClass getGlobalObject() => globalObject; @pragma('vm:entry-point') // Prevent obfuscation _TestClass? takeTarget1() { - var tmp = target1; + final tmp = target1; target1 = null; return tmp; } @pragma('vm:entry-point') // Prevent obfuscation _TestClass? takeTarget2() { - var tmp = target2; + final tmp = target2; target2 = null; return tmp; } @pragma('vm:entry-point') // Prevent obfuscation _TestClass? takeTarget3() { - var tmp = target3; + final tmp = target3; target3 = null; return tmp; } @pragma('vm:entry-point') // Prevent obfuscation _TestClass? takeTarget4() { - var tmp = target4; + final tmp = target4; target4 = null; return tmp; } @pragma('vm:entry-point') // Prevent obfuscation _TestClass? takeTarget5() { - var tmp = target5; + final tmp = target5; target5 = null; return tmp; } @pragma('vm:entry-point') // Prevent obfuscation _TestClass? takeExpandoTarget() { - var tmp = target6; + final tmp = target6; target6 = null; - var tmp2 = _TestClass(); + final tmp2 = _TestClass(); expando[tmp!] = tmp2; return tmp2; } @pragma('vm:entry-point') // Prevent obfuscation _TestClass? takeWeakReachableTarget() { - var tmp = target7; + final tmp = target7; target7 = null; return tmp; } @pragma('vm:entry-point') // Prevent obfuscation _TestClass? takeWeakUnreachableTarget() { - var tmp = target8; + final tmp = target8; target8 = null; return tmp; } diff --git a/pkg/vm_service/test/get_stack_limit_rpc_test.dart b/pkg/vm_service/test/get_stack_limit_rpc_test.dart index 57e7b902b52..4e9ce876c28 100644 --- a/pkg/vm_service/test/get_stack_limit_rpc_test.dart +++ b/pkg/vm_service/test/get_stack_limit_rpc_test.dart @@ -62,7 +62,7 @@ final tests = [ 'bar', 'foo', 'bar', - 'foo' + 'foo', ]); final fullStackLength = frames.length; @@ -88,7 +88,7 @@ final tests = [ 'bar', 'foo', 'bar', - 'foo' + 'foo', ]); // Try a limit < actual stack depth and expect to get a stack of depth diff --git a/pkg/vm_service/test/get_stack_test.dart b/pkg/vm_service/test/get_stack_test.dart index f7daf2169ff..74fe751f2c2 100644 --- a/pkg/vm_service/test/get_stack_test.dart +++ b/pkg/vm_service/test/get_stack_test.dart @@ -46,7 +46,10 @@ Future func10() async { } void expectFrame( - final frame, final kindExpectation, final codeNameExpectation) { + final frame, + final kindExpectation, + final codeNameExpectation, +) { expect(frame.kind, kindExpectation); expect(frame.code?.name, codeNameExpectation); } @@ -54,7 +57,10 @@ void expectFrame( void expectFrames(final frames, final expectKindAndCodeName) { for (int i = 0; i < expectKindAndCodeName.length; i++) { expectFrame( - frames[i], expectKindAndCodeName[i][0], expectKindAndCodeName[i][1]); + frames[i], + expectKindAndCodeName[i][0], + expectKindAndCodeName[i][1], + ); } } diff --git a/pkg/vm_service/test/get_user_level_retaining_path_rpc_test.dart b/pkg/vm_service/test/get_user_level_retaining_path_rpc_test.dart index ddc7e857c2a..edff937d5b3 100644 --- a/pkg/vm_service/test/get_user_level_retaining_path_rpc_test.dart +++ b/pkg/vm_service/test/get_user_level_retaining_path_rpc_test.dart @@ -14,7 +14,7 @@ class _TestConst { const _TestConst(); } -_topLevelClosure() {} +void _topLevelClosure() {} @pragma('vm:entry-point') // Prevent obfuscation late final _TestConst x; diff --git a/pkg/vm_service/test/get_version_rpc_test.dart b/pkg/vm_service/test/get_version_rpc_test.dart index d8ce3d78210..cdfedb4d124 100644 --- a/pkg/vm_service/test/get_version_rpc_test.dart +++ b/pkg/vm_service/test/get_version_rpc_test.dart @@ -15,7 +15,7 @@ var tests = [ }, ]; -main([args = const []]) async => await runVMTests( +Future main([args = const []]) async => await runVMTests( args, tests, 'get_version_rpc_test.dart', diff --git a/pkg/vm_service/test/heap_snapshot_graph_test.dart b/pkg/vm_service/test/heap_snapshot_graph_test.dart index 042fc355f8d..8f1a127d802 100644 --- a/pkg/vm_service/test/heap_snapshot_graph_test.dart +++ b/pkg/vm_service/test/heap_snapshot_graph_test.dart @@ -20,8 +20,8 @@ void script() { // Create 3 instances of Foo, with out-degrees // 0 (for b), 1 (for a), and 2 (for staticFoo). r = Foo(); - var a = Foo(); - var b = Foo(); + final a = Foo(); + final b = Foo(); r.left = a; r.right = b; a.left = b; @@ -32,7 +32,7 @@ void script() { lst[1] = List.filled(1234569, null); } -var tests = [ +final tests = [ (VmService service, IsolateRef isolate) async { final snapshotGraph = await HeapSnapshotGraph.getSnapshot(service, isolate); expect(snapshotGraph.name, 'main'); @@ -42,7 +42,7 @@ var tests = [ int actualShallowSize = 0; int actualRefCount = 0; - for (var o in snapshotGraph.objects) { + for (final o in snapshotGraph.objects) { // -1 is the CID used by the sentinel. expect(o.classId >= -1, isTrue); expect(o.data, isNotNull); @@ -78,7 +78,7 @@ var tests = [ int foosFound = 0; int fooClassId = -1; for (int i = 0; i < snapshotGraph.classes.length; i++) { - HeapSnapshotClass c = snapshotGraph.classes[i]; + final HeapSnapshotClass c = snapshotGraph.classes[i]; if (c.name == 'Foo' && c.libraryUri.toString().endsWith('heap_snapshot_graph_test.dart')) { foosFound++; @@ -89,7 +89,7 @@ var tests = [ // It knows about "Foo" objects. foosFound = 0; - for (var o in snapshotGraph.objects) { + for (final o in snapshotGraph.objects) { if (o.classId == 0) continue; if (o.classId == fooClassId) { foosFound++; @@ -104,7 +104,7 @@ var tests = [ }, ]; -main([args = const []]) async => runIsolateTests( +void main([args = const []]) => runIsolateTests( args, tests, 'heap_snapshot_graph_test.dart', diff --git a/pkg/vm_service/test/http_enable_timeline_logging_service_test.dart b/pkg/vm_service/test/http_enable_timeline_logging_service_test.dart index 9a97597ff79..b6ac8cec546 100644 --- a/pkg/vm_service/test/http_enable_timeline_logging_service_test.dart +++ b/pkg/vm_service/test/http_enable_timeline_logging_service_test.dart @@ -57,7 +57,7 @@ var tests = [ }, ]; -main([args = const []]) async => runIsolateTests( +void main([args = const []]) => runIsolateTests( args, tests, 'http_enable_timeline_logging_service_test.dart', diff --git a/pkg/vm_service/test/http_invocations/http_get_isolate_group_rpc_common.dart b/pkg/vm_service/test/http_invocations/http_get_isolate_group_rpc_common.dart index a29e8c4f0ca..9649a7ef9d9 100644 --- a/pkg/vm_service/test/http_invocations/http_get_isolate_group_rpc_common.dart +++ b/pkg/vm_service/test/http_invocations/http_get_isolate_group_rpc_common.dart @@ -28,9 +28,10 @@ Future testeeBefore() async { try { final result = createServiceObject( await makeHttpServiceRequest( - serverUri: serverUri, - method: 'getIsolateGroup', - params: {'isolateGroupId': await getIsolateGroupId(serverUri)}), + serverUri: serverUri, + method: 'getIsolateGroup', + params: {'isolateGroupId': await getIsolateGroupId(serverUri)}, + ), ['IsolateGroup'], )! as IsolateGroup; Expect.isTrue(result.id!.startsWith('isolateGroups/')); diff --git a/pkg/vm_service/test/inbound_references_test.dart b/pkg/vm_service/test/inbound_references_test.dart index b43a445700d..4341e7fac66 100644 --- a/pkg/vm_service/test/inbound_references_test.dart +++ b/pkg/vm_service/test/inbound_references_test.dart @@ -54,11 +54,13 @@ final tests = [ // Assert inst is referenced by at least n, array, and the top-level // field e. - hasReferenceSuchThat((r) => - r.parentField != null && - r.parentField!.name == 'edge' && - r.source is InstanceRef && - (r.source as InstanceRef).classRef!.name == 'Node'); + hasReferenceSuchThat( + (r) => + r.parentField != null && + r.parentField!.name == 'edge' && + r.source is InstanceRef && + (r.source as InstanceRef).classRef!.name == 'Node', + ); hasReferenceSuchThat( (r) => r.parentListIndex == 1 && diff --git a/pkg/vm_service/test/invoke_test.dart b/pkg/vm_service/test/invoke_test.dart index ae2430a1a85..6406b5bcbbf 100644 --- a/pkg/vm_service/test/invoke_test.dart +++ b/pkg/vm_service/test/invoke_test.dart @@ -55,7 +55,7 @@ var tests = [ final apple = await service.getObject(isolateId, field.staticValue!.id!); fieldRef = lib.variables!.singleWhere((field) => field.name == 'banana'); field = await service.getObject(isolateId, fieldRef.id!) as Field; - Instance banana = + final Instance banana = await service.getObject(isolateId, field.staticValue!.id!) as Instance; dynamic result = @@ -67,21 +67,29 @@ var tests = [ expect(result.valueAsString, equals('foobar2apple')); result = await service.invoke( - isolateId, instance.id!, 'instanceFunction', [apple.id!, banana.id!]); + isolateId, + instance.id!, + 'instanceFunction', + [apple.id!, banana.id!], + ); expect(result.valueAsString, equals('foobar3applebanana')); // Wrong arity. - await expectError(() => service - .invoke(isolateId, instance.id!, 'instanceFunction', [apple.id!])); + await expectError( + () => service + .invoke(isolateId, instance.id!, 'instanceFunction', [apple.id!]), + ); // No such target. - await expectError(() => service - .invoke(isolateId, instance.id!, 'functionDoesNotExist', [apple.id!])); + await expectError( + () => service + .invoke(isolateId, instance.id!, 'functionDoesNotExist', [apple.id!]), + ); }, resumeIsolate, ]; Future expectError(func) async { - dynamic result = await func(); + final dynamic result = await func(); expect(result.type == 'Error' || result.type == '@Error', isTrue); } diff --git a/pkg/vm_service/test/isolate_exit_resume_test.dart b/pkg/vm_service/test/isolate_exit_resume_test.dart index b6f6f7a3c17..222d95b160a 100644 --- a/pkg/vm_service/test/isolate_exit_resume_test.dart +++ b/pkg/vm_service/test/isolate_exit_resume_test.dart @@ -19,7 +19,7 @@ Future _compute() async { print('compute is done'); } -void testMain() async { +Future testMain() async { await iso.Isolate.run(_compute); print('Done'); } diff --git a/pkg/vm_service/test/issue_27238_test.dart b/pkg/vm_service/test/issue_27238_test.dart index ceb7b3afe12..c1ded19b696 100644 --- a/pkg/vm_service/test/issue_27238_test.dart +++ b/pkg/vm_service/test/issue_27238_test.dart @@ -9,14 +9,21 @@ import 'dart:developer'; import 'common/service_test_common.dart'; import 'common/test_helper.dart'; -const int LINE_0 = 20; -const int LINE_A = LINE_0 + 1; -const int LINE_B = LINE_A + 3; -const int LINE_C = LINE_B + 1; -const int LINE_D = LINE_C + 2; -const int LINE_E = LINE_D + 1; +// AUTOGENERATED START +// +// Update these constants by running: +// +// dart pkg/vm_service/test/update_line_numbers.dart +// +const LINE_0 = 27; +const LINE_A = 28; +const LINE_B = 31; +const LINE_C = 32; +const LINE_D = 34; +const LINE_E = 35; +// AUTOGENERATED END -testMain() async { +Future testMain() async { debugger(); // LINE_0. final future1 = Future.value(); // LINE_A. final future2 = Future.value(); diff --git a/pkg/vm_service/test/library_dependency_test.dart b/pkg/vm_service/test/library_dependency_test.dart index ba7737c2dd3..734f78cf927 100644 --- a/pkg/vm_service/test/library_dependency_test.dart +++ b/pkg/vm_service/test/library_dependency_test.dart @@ -41,7 +41,7 @@ final tests = [ }, ]; -main([args = const []]) => runIsolateTests( +Future main([args = const []]) => runIsolateTests( args, tests, 'library_dependency_test.dart', diff --git a/pkg/vm_service/test/local_variable_declaration_test.dart b/pkg/vm_service/test/local_variable_declaration_test.dart index 3e0c2f243ff..984c0010a38 100644 --- a/pkg/vm_service/test/local_variable_declaration_test.dart +++ b/pkg/vm_service/test/local_variable_declaration_test.dart @@ -108,7 +108,7 @@ bool _isIdentifierChar(int c) { } int? guessTokenLength(Script script, int line, int column) { - String source = getLine(script, line)!; + final String source = getLine(script, line)!; int pos = column; if (pos >= source.length) { diff --git a/pkg/vm_service/test/logging_test.dart b/pkg/vm_service/test/logging_test.dart index d6c7e92c006..adb0f751f17 100644 --- a/pkg/vm_service/test/logging_test.dart +++ b/pkg/vm_service/test/logging_test.dart @@ -11,27 +11,36 @@ import 'package:vm_service/vm_service.dart'; import 'common/service_test_common.dart'; import 'common/test_helper.dart'; -const LINE_A = 32; -const LINE_B = LINE_A + 2; +// AUTOGENERATED START +// +// Update these constants by running: +// +// dart pkg/vm_service/test/update_line_numbers.dart +// +const LINE_A = 41; +const LINE_B = 43; +// AUTOGENERATED END void init() { Logger.root.level = Level.ALL; Logger.root.onRecord.listen((logRecord) { - log(logRecord.message, - time: logRecord.time, - sequenceNumber: logRecord.sequenceNumber, - level: logRecord.level.value, - name: logRecord.loggerName, - zone: null, - error: logRecord.error, - stackTrace: logRecord.stackTrace); + log( + logRecord.message, + time: logRecord.time, + sequenceNumber: logRecord.sequenceNumber, + level: logRecord.level.value, + name: logRecord.loggerName, + zone: null, + error: logRecord.error, + stackTrace: logRecord.stackTrace, + ); }); } void run() { - debugger(); + debugger(); // LINE_A Logger.root.fine('Hey Buddy!'); - debugger(); + debugger(); // LINE_B Logger.root.info('YES'); } diff --git a/pkg/vm_service/test/mark_main_isolate_as_system_isolate_test.dart b/pkg/vm_service/test/mark_main_isolate_as_system_isolate_test.dart index 6219ebf90da..c24d67bbe4d 100644 --- a/pkg/vm_service/test/mark_main_isolate_as_system_isolate_test.dart +++ b/pkg/vm_service/test/mark_main_isolate_as_system_isolate_test.dart @@ -11,9 +11,13 @@ import 'package:vm_service/vm_service.dart' as service; import 'common/service_test_common.dart'; import 'common/test_helper.dart'; -testMain() async { - await Isolate.spawnUri(Platform.script, ['--selftest'], null, - debugName: 'foo'); +Future testMain() async { + await Isolate.spawnUri( + Platform.script, + ['--selftest'], + null, + debugName: 'foo', + ); } var tests = [ @@ -28,12 +32,12 @@ var tests = [ resumeIsolate, ]; -main([args = const []]) { +void main([args = const []]) { if (args.length > 0 && args[0] == '--selftest') { debugger(); return; } - return runIsolateTests( + runIsolateTests( args, tests, 'mark_main_isolate_as_system_isolate_test.dart', diff --git a/pkg/vm_service/test/mirror_references_test.dart b/pkg/vm_service/test/mirror_references_test.dart index 9da6ea386bb..92fc1b31254 100644 --- a/pkg/vm_service/test/mirror_references_test.dart +++ b/pkg/vm_service/test/mirror_references_test.dart @@ -16,9 +16,10 @@ dynamic /*MirrorReference*/ ref; void script() { foo = Foo(); - ClassMirror fooClassMirror = reflectClass(Foo); - InstanceMirror fooClassMirrorMirror = reflect(fooClassMirror); - LibraryMirror libmirrors = fooClassMirrorMirror.type.owner as LibraryMirror; + final ClassMirror fooClassMirror = reflectClass(Foo); + final InstanceMirror fooClassMirrorMirror = reflect(fooClassMirror); + final LibraryMirror libmirrors = + fooClassMirrorMirror.type.owner as LibraryMirror; ref = reflect(fooClassMirror) .getField(MirrorSystem.getSymbol('_reflectee', libmirrors)) .reflectee; diff --git a/pkg/vm_service/test/network_profiling_test.dart b/pkg/vm_service/test/network_profiling_test.dart index 6f41e2a6f85..fa0ff05cc5c 100644 --- a/pkg/vm_service/test/network_profiling_test.dart +++ b/pkg/vm_service/test/network_profiling_test.dart @@ -45,15 +45,15 @@ Future setup() async {} Future socketTest() async { // Socket - var serverSocket = await io.ServerSocket.bind(localhost, 0); - var socket = await io.Socket.connect(localhost, serverSocket.port); + final serverSocket = await io.ServerSocket.bind(localhost, 0); + final socket = await io.Socket.connect(localhost, serverSocket.port); socket.write(content); await socket.flush(); socket.destroy(); // rawDatagram final doneCompleter = Completer(); - var server = await io.RawDatagramSocket.bind(localhost, 0); + final server = await io.RawDatagramSocket.bind(localhost, 0); server.listen((io.RawSocketEvent event) { if (event == io.RawSocketEvent.read) { server.receive(); @@ -62,9 +62,12 @@ Future socketTest() async { } } }); - var client = await io.RawDatagramSocket.bind(localhost, 0); + final client = await io.RawDatagramSocket.bind(localhost, 0); client.send( - utf8.encode(udpContent), io.InternetAddress(localhost), server.port); + utf8.encode(udpContent), + io.InternetAddress(localhost), + server.port, + ); client.send([1, 2, 3], io.InternetAddress(localhost), server.port); // Wait for datagram to arrive. @@ -108,7 +111,7 @@ var tests = [ // TODO(bkonyi): fully port observatory test for socket profiling. ]; -main([args = const []]) async => runIsolateTests( +void main([args = const []]) => runIsolateTests( args, tests, 'network_profiling_test.dart', diff --git a/pkg/vm_service/test/next_through_assign_call_test.dart b/pkg/vm_service/test/next_through_assign_call_test.dart index 4ddccbc79f5..2106e60a344 100644 --- a/pkg/vm_service/test/next_through_assign_call_test.dart +++ b/pkg/vm_service/test/next_through_assign_call_test.dart @@ -24,7 +24,7 @@ void code() { print(b); a = foo(); print(a); - int? d = foo(); + final int d = foo(); print(d); int? e = foo(), f, g = foo(); print(e); @@ -45,7 +45,7 @@ const expected = [ '$file:${LINE_A + 4}:3', // on call to 'print' '$file:${LINE_A + 5}:7', // on call to 'foo' '$file:${LINE_A + 6}:3', // on call to 'print' - '$file:${LINE_A + 7}:12', // on call to 'foo' + '$file:${LINE_A + 7}:17', // on call to 'foo' '$file:${LINE_A + 8}:3', // on call to 'print' '$file:${LINE_A + 9}:12', // on first call to 'foo' '$file:${LINE_A + 9}:19', // on variable 'f' @@ -53,14 +53,14 @@ const expected = [ '$file:${LINE_A + 10}:3', // on call to 'print' '$file:${LINE_A + 11}:3', // on call to 'print' '$file:${LINE_A + 12}:3', // on call to 'print' - '$file:${LINE_A + 13}:1' // on ending '}' + '$file:${LINE_A + 13}:1', // on ending '}' ]; final tests = [ hasPausedAtStart, setBreakpointAtLine(LINE_A), runStepThroughProgramRecordingStops(stops), - checkRecordedStops(stops, expected) + checkRecordedStops(stops, expected), ]; void main([args = const []]) => runIsolateTests( diff --git a/pkg/vm_service/test/next_through_assign_int_test.dart b/pkg/vm_service/test/next_through_assign_int_test.dart index 1fbebc0a32c..74adc13503f 100644 --- a/pkg/vm_service/test/next_through_assign_int_test.dart +++ b/pkg/vm_service/test/next_through_assign_int_test.dart @@ -23,7 +23,7 @@ void code() { print(b); a = 42; print(a); - int? d = 42; + final int d = 42; print(d); int? e = 41, f, g = 42; print(e); @@ -40,7 +40,7 @@ const expected = [ '$file:${LINE_A + 4}:3', // on call to 'print' '$file:${LINE_A + 5}:3', // on 'a' '$file:${LINE_A + 6}:3', // on call to 'print' - '$file:${LINE_A + 7}:10', // on '=' + '$file:${LINE_A + 7}:15', // on '=' '$file:${LINE_A + 8}:3', // on call to 'print' '$file:${LINE_A + 9}:10', // on first '=' '$file:${LINE_A + 9}:16', // on 'f' @@ -55,7 +55,7 @@ final tests = [ hasPausedAtStart, setBreakpointAtLine(LINE_A), runStepThroughProgramRecordingStops(stops), - checkRecordedStops(stops, expected) + checkRecordedStops(stops, expected), ]; void main([args = const []]) => runIsolateTests( diff --git a/pkg/vm_service/test/next_through_call_on_field_in_class_test.dart b/pkg/vm_service/test/next_through_call_on_field_in_class_test.dart index 67ada286e6f..e1874fb610b 100644 --- a/pkg/vm_service/test/next_through_call_on_field_in_class_test.dart +++ b/pkg/vm_service/test/next_through_call_on_field_in_class_test.dart @@ -39,7 +39,7 @@ const expected = [ '$file:${LINE_A + 2}:7', // on "foo" '$file:${LINE_A + 3}:7', // on "fooMethod" '$file:${LINE_A + 4}:7', // on "foo" - '$file:${LINE_A + 5}:1' // on ending '}' + '$file:${LINE_A + 5}:1', // on ending '}' ]; final tests = [ diff --git a/pkg/vm_service/test/next_through_call_on_field_test.dart b/pkg/vm_service/test/next_through_call_on_field_test.dart index 0ff673e5b6f..191603584aa 100644 --- a/pkg/vm_service/test/next_through_call_on_field_test.dart +++ b/pkg/vm_service/test/next_through_call_on_field_test.dart @@ -34,14 +34,14 @@ const expected = [ '$file:${LINE_A + 1}:3', // on 'foo' '$file:${LINE_A + 2}:3', // on 'fooMethod' '$file:${LINE_A + 3}:6', // after 'foo' (on invisible '.call') - '$file:${LINE_A + 4}:1' // on ending '}' + '$file:${LINE_A + 4}:1', // on ending '}' ]; final tests = [ hasPausedAtStart, setBreakpointAtLine(LINE_A), runStepThroughProgramRecordingStops(stops), - checkRecordedStops(stops, expected) + checkRecordedStops(stops, expected), ]; void main([args = const []]) => runIsolateTests( diff --git a/pkg/vm_service/test/next_through_call_on_static_field_in_class_test.dart b/pkg/vm_service/test/next_through_call_on_static_field_in_class_test.dart index ae072b2a113..869e42771e8 100644 --- a/pkg/vm_service/test/next_through_call_on_static_field_in_class_test.dart +++ b/pkg/vm_service/test/next_through_call_on_static_field_in_class_test.dart @@ -36,14 +36,14 @@ const expected = [ '$file:${LINE_A + 1}:7', // on 'foo' '$file:${LINE_A + 2}:7', // on 'fooMethod' '$file:${LINE_A + 3}:10', // after 'foo' (on invisible '.call') - '$file:${LINE_A + 4}:1' // on ending '}' + '$file:${LINE_A + 4}:1', // on ending '}' ]; final tests = [ hasPausedAtStart, setBreakpointAtLine(LINE_A), runStepThroughProgramRecordingStops(stops), - checkRecordedStops(stops, expected) + checkRecordedStops(stops, expected), ]; void main([args = const []]) => runIsolateTests( diff --git a/pkg/vm_service/test/next_through_catch_test.dart b/pkg/vm_service/test/next_through_catch_test.dart index ce3827d9578..fe6c39df982 100644 --- a/pkg/vm_service/test/next_through_catch_test.dart +++ b/pkg/vm_service/test/next_through_catch_test.dart @@ -41,14 +41,14 @@ const expected = [ '$file:${LINE_A + 8}:5', // on 'throw' '$file:${LINE_A + 10}:5', // on call to 'print' '$file:${LINE_A + 11}:5', // on call to 'print' - '$file:${LINE_A + 13}:1' // on ending '}' + '$file:${LINE_A + 13}:1', // on ending '}' ]; final tests = [ hasPausedAtStart, setBreakpointAtLine(LINE_A), runStepThroughProgramRecordingStops(stops), - checkRecordedStops(stops, expected) + checkRecordedStops(stops, expected), ]; void main([args = const []]) => runIsolateTests( diff --git a/pkg/vm_service/test/next_through_closure_test.dart b/pkg/vm_service/test/next_through_closure_test.dart index 91ba7af8bc5..bf5e31a0e2a 100644 --- a/pkg/vm_service/test/next_through_closure_test.dart +++ b/pkg/vm_service/test/next_through_closure_test.dart @@ -17,7 +17,7 @@ const LINE_A = 22; const file = 'next_through_closure_test.dart'; int codeXYZ(int i) { - x() => + int x() => // some comment here to allow this formatting i * i; // LINE_A return x(); @@ -32,14 +32,14 @@ const expected = [ '$file:${LINE_A + 0}:9', // on '*' '$file:${LINE_A + 0}:7', // on first 'i' '$file:${LINE_A + 1}:3', // on 'return' - '$file:${LINE_A + 6}:1' // on ending '}' + '$file:${LINE_A + 6}:1', // on ending '}' ]; final tests = [ hasPausedAtStart, setBreakpointAtLine(LINE_A), runStepThroughProgramRecordingStops(stops), - checkRecordedStops(stops, expected) + checkRecordedStops(stops, expected), ]; void main([args = const []]) => runIsolateTests( diff --git a/pkg/vm_service/test/next_through_create_list_and_map_test.dart b/pkg/vm_service/test/next_through_create_list_and_map_test.dart index 5ec4019a2b8..d4aecbb6d4a 100644 --- a/pkg/vm_service/test/next_through_create_list_and_map_test.dart +++ b/pkg/vm_service/test/next_through_create_list_and_map_test.dart @@ -22,26 +22,26 @@ void code() { 1234567891, 1234567892, 1234567893, - 1234567894 + 1234567894, ]; final myConstList = const [ 1234567890, 1234567891, 1234567892, 1234567893, - 1234567894 + 1234567894, ]; final myMap = { 1: 42, 2: 43, 33242344: 432432432, - 443243232: 543242454 + 443243232: 543242454, }; final myConstMap = const { 1: 42, 2: 43, 33242344: 432432432, - 443243232: 543242454 + 443243232: 543242454, }; print(myList); print(myConstList); @@ -83,14 +83,14 @@ const expected = [ '$file:${LINE_A + 32}:3', // End (on ending '}') - '$file:${LINE_A + 33}:1' + '$file:${LINE_A + 33}:1', ]; final tests = [ hasPausedAtStart, setBreakpointAtLine(LINE_A), runStepThroughProgramRecordingStops(stops), - checkRecordedStops(stops, expected) + checkRecordedStops(stops, expected), ]; void main([args = const []]) => runIsolateTests( diff --git a/pkg/vm_service/test/next_through_for_each_loop_test.dart b/pkg/vm_service/test/next_through_for_each_loop_test.dart index 8c2637d11de..12ae3c6fd9c 100644 --- a/pkg/vm_service/test/next_through_for_each_loop_test.dart +++ b/pkg/vm_service/test/next_through_for_each_loop_test.dart @@ -51,7 +51,7 @@ const expected = [ // End: Apparently we go to data again, then on the final '}' '$file:${LINE_A + 1}:27', - '$file:${LINE_A + 4}:1' + '$file:${LINE_A + 4}:1', ]; final tests = [ diff --git a/pkg/vm_service/test/next_through_for_loop_with_break_and_continue_test.dart b/pkg/vm_service/test/next_through_for_loop_with_break_and_continue_test.dart index 0a3d877357a..1f04205a03c 100644 --- a/pkg/vm_service/test/next_through_for_loop_with_break_and_continue_test.dart +++ b/pkg/vm_service/test/next_through_for_loop_with_break_and_continue_test.dart @@ -66,7 +66,7 @@ const expected = [ // End (on call to 'print' and on ending '}') '$file:${LINE_A + 10}:3', - '$file:${LINE_A + 11}:1' + '$file:${LINE_A + 11}:1', ]; final tests = [ diff --git a/pkg/vm_service/test/next_through_function_expression_test.dart b/pkg/vm_service/test/next_through_function_expression_test.dart index c172e1ea85a..b8fe057b626 100644 --- a/pkg/vm_service/test/next_through_function_expression_test.dart +++ b/pkg/vm_service/test/next_through_function_expression_test.dart @@ -33,7 +33,7 @@ const expected = [ '$file:${LINE_A + 0}:17', // on 'i' in 'codeXYZ(int i)' '$file:${LINE_A + 1}:3', // on 'int' '$file:${LINE_A + 5}:10', // on 'innerOne()' call - '$file:${LINE_A + 5}:3' // on 'return' + '$file:${LINE_A + 5}:3', // on 'return' ]; final tests = [ diff --git a/pkg/vm_service/test/next_through_implicit_call_test.dart b/pkg/vm_service/test/next_through_implicit_call_test.dart index 8adcb4db878..1d265f60bfc 100644 --- a/pkg/vm_service/test/next_through_implicit_call_test.dart +++ b/pkg/vm_service/test/next_through_implicit_call_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// ignore_for_file: unnecessary_parenthesis + import 'common/service_test_common.dart'; import 'common/test_helper.dart'; @@ -11,7 +13,7 @@ import 'common/test_helper.dart'; // // dart pkg/vm_service/test/update_line_numbers.dart // -const LINE_A = 26; +const LINE_A = 28; // AUTOGENERATED END const file = 'next_through_implicit_call_test.dart'; @@ -29,7 +31,7 @@ void code() { a[0](); (a[0])(); final b = [ - [foo, foo] + [foo, foo], ]; b[0][1](); (b[0][1])(); diff --git a/pkg/vm_service/test/next_through_is_and_as_test.dart b/pkg/vm_service/test/next_through_is_and_as_test.dart index 91c60ce1c31..48d1b778d75 100644 --- a/pkg/vm_service/test/next_through_is_and_as_test.dart +++ b/pkg/vm_service/test/next_through_is_and_as_test.dart @@ -21,7 +21,7 @@ void code() { final hex = 0x42; if (i is int) { print('i is int'); - int x = i as int; + final int x = i as int; if (x.isEven) { print("it's even even!"); } else { @@ -34,7 +34,7 @@ void code() { // ignore: unnecessary_type_check_true if (hex is int) { print('hex is int'); - int x = hex as dynamic; + final int x = hex as dynamic; if (x.isEven) { print("it's even even!"); } else { @@ -56,11 +56,11 @@ const expected = [ '$file:${LINE_A + 12}:5', // on call to 'print' '$file:${LINE_A + 15}:11', // in 'is' '$file:${LINE_A + 16}:5', // on call to 'print' - '$file:${LINE_A + 17}:11', // on '=' + '$file:${LINE_A + 17}:17', // on '=' '$file:${LINE_A + 18}:11', // on 'isEven' '$file:${LINE_A + 19}:7', // on call to 'print' '$file:${LINE_A + 25}:11', // on 'is!' - '$file:${LINE_A + 28}:1' // on ending '}' + '$file:${LINE_A + 28}:1', // on ending '}' ]; final tests = [ diff --git a/pkg/vm_service/test/next_through_new_test.dart b/pkg/vm_service/test/next_through_new_test.dart index 4966caf1e25..15c496aaf6c 100644 --- a/pkg/vm_service/test/next_through_new_test.dart +++ b/pkg/vm_service/test/next_through_new_test.dart @@ -29,7 +29,7 @@ final stops = []; const expected = [ '$file:${LINE_A + 0}:9', // on '(' in 'code()' '$file:${LINE_A + 1}:13', // on 'Foo' - '$file:${LINE_A + 2}:3' // on 'return' + '$file:${LINE_A + 2}:3', // on 'return' ]; final tests = [ diff --git a/pkg/vm_service/test/next_through_operator_bracket_test.dart b/pkg/vm_service/test/next_through_operator_bracket_test.dart index bb19f73626e..57294a138fb 100644 --- a/pkg/vm_service/test/next_through_operator_bracket_test.dart +++ b/pkg/vm_service/test/next_through_operator_bracket_test.dart @@ -36,7 +36,7 @@ const expected = [ '$file:${LINE_A + 0}:13', // on 'Class2()' '$file:${LINE_A + 1}:4', // on '[' '$file:${LINE_A + 2}:5', // on 'code' - '$file:${LINE_A + 3}:1' // on ending '}' + '$file:${LINE_A + 3}:1', // on ending '}' ]; final tests = [ diff --git a/pkg/vm_service/test/next_through_simple_async_test.dart b/pkg/vm_service/test/next_through_simple_async_test.dart index c1750057b8d..3aab1572049 100644 --- a/pkg/vm_service/test/next_through_simple_async_test.dart +++ b/pkg/vm_service/test/next_through_simple_async_test.dart @@ -18,7 +18,7 @@ const LINE_A = 21; const file = 'next_through_simple_async_test.dart'; -void code() /* LINE_A */ async { +Future code() /* LINE_A */ async { final f = File(Platform.script.toFilePath()); final modified = await f.lastModified(); final exists = await f.exists(); @@ -32,7 +32,7 @@ void foo() { final stops = []; const expected = [ - '$file:${LINE_A + 0}:10', // on '(' in code()' + '$file:${LINE_A + 0}:18', // on '(' in code()' '$file:${LINE_A + 1}:27', // on 'script' '$file:${LINE_A + 1}:34', // on 'toFilePath' '$file:${LINE_A + 1}:13', // on File diff --git a/pkg/vm_service/test/next_through_simple_linear_test.dart b/pkg/vm_service/test/next_through_simple_linear_test.dart index 7c43aa9e1ba..6842b7f9b30 100644 --- a/pkg/vm_service/test/next_through_simple_linear_test.dart +++ b/pkg/vm_service/test/next_through_simple_linear_test.dart @@ -27,7 +27,7 @@ const expected = [ '$file:${LINE_A + 0}:3', // on call to 'print' '$file:${LINE_A + 1}:3', // on call to 'print' '$file:${LINE_A + 2}:3', // on call to 'print' - '$file:${LINE_A + 3}:1' // on ending '}' + '$file:${LINE_A + 3}:1', // on ending '}' ]; final tests = [ diff --git a/pkg/vm_service/test/notify_debugger_on_exception_yielding_test.dart b/pkg/vm_service/test/notify_debugger_on_exception_yielding_test.dart index f89f43c6328..e34fe3f3deb 100644 --- a/pkg/vm_service/test/notify_debugger_on_exception_yielding_test.dart +++ b/pkg/vm_service/test/notify_debugger_on_exception_yielding_test.dart @@ -50,7 +50,7 @@ Iterable throwFromSyncStar() sync* { yield 7; } -void testMain() async { +Future testMain() async { await throwFromAsync(); await for (var _ in throwFromAsyncStar()) {/*ignore*/} for (var _ in throwFromSyncStar()) {/*ignore*/} diff --git a/pkg/vm_service/test/pause_on_exception_from_slow_path_test.dart b/pkg/vm_service/test/pause_on_exception_from_slow_path_test.dart index 90b4e414afb..8b631343e2a 100644 --- a/pkg/vm_service/test/pause_on_exception_from_slow_path_test.dart +++ b/pkg/vm_service/test/pause_on_exception_from_slow_path_test.dart @@ -13,7 +13,7 @@ class X { String get y => _y; } -void testeeMain() async { +Future testeeMain() async { final x = X(); x._y = ''; for (int i = 0; i < 2000; i++) { diff --git a/pkg/vm_service/test/pause_on_exceptions_legacy_test.dart b/pkg/vm_service/test/pause_on_exceptions_legacy_test.dart index 382f4d0ad1b..b03e289c418 100644 --- a/pkg/vm_service/test/pause_on_exceptions_legacy_test.dart +++ b/pkg/vm_service/test/pause_on_exceptions_legacy_test.dart @@ -9,11 +9,11 @@ import 'package:vm_service/vm_service.dart'; import 'common/test_helper.dart'; -doThrow() { +Never doThrow() { throw 'TheException'; // Line 13. } -doCaught() { +String? doCaught() { try { doThrow(); } catch (e) { @@ -21,8 +21,9 @@ doCaught() { } } -doUncaught() { +String doUncaught() { doThrow(); + // ignore: dead_code return 'end of doUncaught'; } @@ -52,8 +53,12 @@ final tests = [ }); await service.streamListen(EventStreams.kDebug); - test(String pauseMode, String expression, bool shouldPause, - bool shouldBeCaught) async { + Future test( + String pauseMode, + String expression, + bool shouldPause, + bool shouldBeCaught, + ) async { print('Evaluating $expression with pause on $pauseMode exception'); // ignore: deprecated_member_use_from_same_package @@ -105,7 +110,7 @@ final tests = [ }, ]; -main([args = const []]) => runIsolateTests( +Future main([args = const []]) => runIsolateTests( args, tests, 'pause_on_exceptions_test.dart', diff --git a/pkg/vm_service/test/pause_on_exceptions_test.dart b/pkg/vm_service/test/pause_on_exceptions_test.dart index 294f3d03478..f788eddd0fc 100644 --- a/pkg/vm_service/test/pause_on_exceptions_test.dart +++ b/pkg/vm_service/test/pause_on_exceptions_test.dart @@ -9,11 +9,11 @@ import 'package:vm_service/vm_service.dart'; import 'common/test_helper.dart'; -doThrow() { +Never doThrow() { throw 'TheException'; // Line 13. } -doCaught() { +String doCaught() { try { doThrow(); } catch (e) { @@ -21,8 +21,9 @@ doCaught() { } } -doUncaught() { +String doUncaught() { doThrow(); + // ignore: dead_code return 'end of doUncaught'; } @@ -52,12 +53,18 @@ final tests = [ }); await service.streamListen(EventStreams.kDebug); - test(String pauseMode, String expression, bool shouldPause, - bool shouldBeCaught) async { + Future test( + String pauseMode, + String expression, + bool shouldPause, + bool shouldBeCaught, + ) async { print('Evaluating $expression with pause on $pauseMode exception'); - await service.setIsolatePauseMode(isolate.id!, - exceptionPauseMode: pauseMode); + await service.setIsolatePauseMode( + isolate.id!, + exceptionPauseMode: pauseMode, + ); late Completer t; if (shouldPause) { @@ -105,7 +112,7 @@ final tests = [ }, ]; -main([args = const []]) => runIsolateTests( +void main([args = const []]) => runIsolateTests( args, tests, 'pause_on_exceptions_test.dart', diff --git a/pkg/vm_service/test/pause_on_unhandled_async_exceptions3_test.dart b/pkg/vm_service/test/pause_on_unhandled_async_exceptions3_test.dart index a5b7d5c4053..8c0be0cbff0 100644 --- a/pkg/vm_service/test/pause_on_unhandled_async_exceptions3_test.dart +++ b/pkg/vm_service/test/pause_on_unhandled_async_exceptions3_test.dart @@ -22,11 +22,11 @@ const LINE_B = 31; const LINE_C = 34; // AUTOGENERATED END -throwException() async { +Future throwException() async { throw 'exception'; // LINE_A } -testeeMain() async { +Future testeeMain() async { try { await throwException(); // LINE_B } finally { diff --git a/pkg/vm_service/test/pause_on_unhandled_async_exceptions_test.dart b/pkg/vm_service/test/pause_on_unhandled_async_exceptions_test.dart index 4c000fc7f3d..3e3bb901881 100644 --- a/pkg/vm_service/test/pause_on_unhandled_async_exceptions_test.dart +++ b/pkg/vm_service/test/pause_on_unhandled_async_exceptions_test.dart @@ -16,7 +16,7 @@ import 'common/test_helper.dart'; // // dart pkg/vm_service/test/update_line_numbers.dart // -const LINE_A = 63; +const LINE_A = 66; // AUTOGENERATED END class Foo {} @@ -33,14 +33,17 @@ Future asyncThrower() async { doThrow(); } -void testeeMain() async { +Future testeeMain() async { try { // This is a regression case for https://dartbug.com/53334: // we should recognize `then(..., onError: ...)` as a catch // all exception handler. - await asyncThrower().then((v) => v, onError: (e, st) { - // Caught and ignored. - }); + await asyncThrower().then( + (v) => v, + onError: (e, st) { + // Caught and ignored. + }, + ); await asyncThrower().onError((error, stackTrace) { // Caught and ignored. diff --git a/pkg/vm_service/test/pause_on_unhandled_async_exceptions_zones_test.dart b/pkg/vm_service/test/pause_on_unhandled_async_exceptions_zones_test.dart index ef745e7c2cf..6ca2a275fc5 100644 --- a/pkg/vm_service/test/pause_on_unhandled_async_exceptions_zones_test.dart +++ b/pkg/vm_service/test/pause_on_unhandled_async_exceptions_zones_test.dart @@ -17,7 +17,7 @@ import 'common/test_helper.dart'; // // dart pkg/vm_service/test/update_line_numbers.dart // -const LINE_A = 64; +const LINE_A = 67; // AUTOGENERATED END class Foo {} @@ -39,9 +39,12 @@ Future testeeMain() async { // This is a regression case for https://dartbug.com/53334: // we should recognize `then(..., onError: ...)` as a catch // all exception handler. - await asyncThrower().then((v) => v, onError: (e, st) { - // Caught and ignored. - }); + await asyncThrower().then( + (v) => v, + onError: (e, st) { + // Caught and ignored. + }, + ); await asyncThrower().onError((error, stackTrace) { // Caught and ignored. diff --git a/pkg/vm_service/test/private_rpcs/allocations_test.dart b/pkg/vm_service/test/private_rpcs/allocations_test.dart index 344e447544b..43c3f7ce722 100644 --- a/pkg/vm_service/test/private_rpcs/allocations_test.dart +++ b/pkg/vm_service/test/private_rpcs/allocations_test.dart @@ -24,10 +24,12 @@ void script() { var tests = [ (VmService service, IsolateRef isolateRef) async { - var profile = await service.callMethod('_getAllocationProfile', - isolateId: isolateRef.id!) as AllocationProfile; + final profile = await service.callMethod( + '_getAllocationProfile', + isolateId: isolateRef.id!, + ) as AllocationProfile; print(profile.runtimeType); - var classHeapStats = profile.members!.singleWhere((stats) { + final classHeapStats = profile.members!.singleWhere((stats) { return stats.classRef!.name == 'Foo'; }); expect(classHeapStats.instancesCurrent, 3); @@ -35,7 +37,7 @@ var tests = [ }, ]; -main(args) => runIsolateTests( +Future main(args) => runIsolateTests( args, tests, 'allocations_test.dart', diff --git a/pkg/vm_service/test/private_rpcs/breakpoint_gc_test.dart b/pkg/vm_service/test/private_rpcs/breakpoint_gc_test.dart index b06b9bead05..d1f5c424176 100644 --- a/pkg/vm_service/test/private_rpcs/breakpoint_gc_test.dart +++ b/pkg/vm_service/test/private_rpcs/breakpoint_gc_test.dart @@ -14,14 +14,14 @@ const String file = 'breakpoint_gc_test.dart'; int foo() => 42; -testeeMain() { +dynamic testeeMain() { foo(); // static call - dynamic list = [1, 2, 3]; + final dynamic list = [1, 2, 3]; list.clear(); // instance call print(list); - dynamic local = list; // debug step check = runtime call + final dynamic local = list; // debug step check = runtime call return local; } diff --git a/pkg/vm_service/test/private_rpcs/dev_fs_http_put_test.dart b/pkg/vm_service/test/private_rpcs/dev_fs_http_put_test.dart index a9b14bfebf3..21855300213 100644 --- a/pkg/vm_service/test/private_rpcs/dev_fs_http_put_test.dart +++ b/pkg/vm_service/test/private_rpcs/dev_fs_http_put_test.dart @@ -15,9 +15,12 @@ import 'private_rpc_common.dart'; Future readResponse(HttpClientResponse response) { final completer = Completer(); final contents = StringBuffer(); - response.cast>().transform(utf8.decoder).listen((String data) { - contents.write(data); - }, onDone: () => completer.complete(contents.toString())); + response.cast>().transform(utf8.decoder).listen( + (String data) { + contents.write(data); + }, + onDone: () => completer.complete(contents.toString()), + ); return completer.future; } @@ -62,7 +65,7 @@ final tests = [ // Write the file by issuing an HTTP PUT. result = await postToDevFS(content: [9]); - if (result case {'result': Map innerResult}) { + if (result case {'result': final Map innerResult}) { expectSuccess(innerResult); } else { invalidResponse(result); @@ -74,7 +77,7 @@ final tests = [ case { 'error': { 'data': { - 'details': String details, + 'details': final String details, } } }) { @@ -85,27 +88,35 @@ final tests = [ // Write the file again but this time with the true file contents. result = await postToDevFS(content: fileContents); - if (result case {'result': Map innerResult}) { + if (result case {'result': final Map innerResult}) { expectSuccess(innerResult); } else { invalidResponse(result); } // Read the file back. - result = await callMethod(service, '_readDevFSFile', args: { - 'fsName': fsId, - 'path': filePath, - }); - if (result case {'type': 'FSFile', 'fileContents': String contents}) { + result = await callMethod( + service, + '_readDevFSFile', + args: { + 'fsName': fsId, + 'path': filePath, + }, + ); + if (result case {'type': 'FSFile', 'fileContents': final String contents}) { expect(contents, fileContentsBase64); } else { invalidResponse(result); } // List all the files in the file system. - result = await callMethod(service, '_listDevFSFiles', args: { - 'fsName': fsId, - }); + result = await callMethod( + service, + '_listDevFSFiles', + args: { + 'fsName': fsId, + }, + ); if (result case {'type': 'FSFileList', 'files': [{'name': filePath}]}) { // Expected } else { @@ -113,9 +124,13 @@ final tests = [ } // Delete DevFS. - result = await callMethod(service, '_deleteDevFS', args: { - 'fsName': fsId, - }); + result = await callMethod( + service, + '_deleteDevFS', + args: { + 'fsName': fsId, + }, + ); expectSuccess(result); }, ]; diff --git a/pkg/vm_service/test/private_rpcs/dev_fs_http_put_weird_char_test.dart b/pkg/vm_service/test/private_rpcs/dev_fs_http_put_weird_char_test.dart index 418262e7fc1..2d4927097e8 100644 --- a/pkg/vm_service/test/private_rpcs/dev_fs_http_put_weird_char_test.dart +++ b/pkg/vm_service/test/private_rpcs/dev_fs_http_put_weird_char_test.dart @@ -15,9 +15,12 @@ import 'private_rpc_common.dart'; Future readResponse(HttpClientResponse response) { final completer = Completer(); final contents = StringBuffer(); - response.cast>().transform(utf8.decoder).listen((String data) { - contents.write(data); - }, onDone: () => completer.complete(contents.toString())); + response.cast>().transform(utf8.decoder).listen( + (String data) { + contents.write(data); + }, + onDone: () => completer.complete(contents.toString()), + ); return completer.future; } @@ -62,7 +65,7 @@ final tests = [ // Write the file by issuing an HTTP PUT. result = await postToDevFS(content: [9]); - if (result case {'result': Map innerResult}) { + if (result case {'result': final Map innerResult}) { expectSuccess(innerResult); } else { invalidResponse(result); @@ -74,7 +77,7 @@ final tests = [ case { 'error': { 'data': { - 'details': String details, + 'details': final String details, } } }) { @@ -85,27 +88,35 @@ final tests = [ // Write the file again but this time with the true file contents. result = await postToDevFS(content: fileContents); - if (result case {'result': Map innerResult}) { + if (result case {'result': final Map innerResult}) { expectSuccess(innerResult); } else { invalidResponse(result); } // Read the file back. - result = await callMethod(service, '_readDevFSFile', args: { - 'fsName': fsId, - 'path': filePath, - }); - if (result case {'type': 'FSFile', 'fileContents': String contents}) { + result = await callMethod( + service, + '_readDevFSFile', + args: { + 'fsName': fsId, + 'path': filePath, + }, + ); + if (result case {'type': 'FSFile', 'fileContents': final String contents}) { expect(contents, fileContentsBase64); } else { invalidResponse(result); } // List all the files in the file system. - result = await callMethod(service, '_listDevFSFiles', args: { - 'fsName': fsId, - }); + result = await callMethod( + service, + '_listDevFSFiles', + args: { + 'fsName': fsId, + }, + ); if (result case {'type': 'FSFileList', 'files': [{'name': filePath}]}) { // Expected } else { @@ -113,9 +124,13 @@ final tests = [ } // Delete DevFS. - result = await callMethod(service, '_deleteDevFS', args: { - 'fsName': fsId, - }); + result = await callMethod( + service, + '_deleteDevFS', + args: { + 'fsName': fsId, + }, + ); expectSuccess(result); }, ]; diff --git a/pkg/vm_service/test/private_rpcs/dev_fs_test.dart b/pkg/vm_service/test/private_rpcs/dev_fs_test.dart index 335032fbc7c..bf18056f52d 100644 --- a/pkg/vm_service/test/private_rpcs/dev_fs_test.dart +++ b/pkg/vm_service/test/private_rpcs/dev_fs_test.dart @@ -88,10 +88,14 @@ final tests = [ } try { - await callMethod(service, '_readDevFSFile', args: { - 'fsName': fsId, - 'path': filePath, - }); + await callMethod( + service, + '_readDevFSFile', + args: { + 'fsName': fsId, + 'path': filePath, + }, + ); fail('Unreachable'); } on RPCError catch (e) { expect(e.code, PrivateRpcErrorCodes.kFileDoesNotExist.code); @@ -99,39 +103,55 @@ final tests = [ } // Write a file. - result = await callMethod(service, '_writeDevFSFile', args: { - 'fsName': fsId, - 'path': filePath, - 'fileContents': fileContents, - }); + result = await callMethod( + service, + '_writeDevFSFile', + args: { + 'fsName': fsId, + 'path': filePath, + 'fileContents': fileContents, + }, + ); expectSuccess(result); // Read the file back. - result = await callMethod(service, '_readDevFSFile', args: { - 'fsName': fsId, - 'path': filePath, - }); - if (result case {'type': 'FSFile', 'fileContents': String contents}) { + result = await callMethod( + service, + '_readDevFSFile', + args: { + 'fsName': fsId, + 'path': filePath, + }, + ); + if (result case {'type': 'FSFile', 'fileContents': final String contents}) { expect(contents, fileContents); } else { invalidResponse(result); } // The leading '/' is optional. - result = await callMethod(service, '_readDevFSFile', args: { - 'fsName': fsId, - 'path': filePath.substring(1), - }); - if (result case {'type': 'FSFile', 'fileContents': String contents}) { + result = await callMethod( + service, + '_readDevFSFile', + args: { + 'fsName': fsId, + 'path': filePath.substring(1), + }, + ); + if (result case {'type': 'FSFile', 'fileContents': final String contents}) { expect(contents, fileContents); } // Read a file outside of the fs. try { - await callMethod(service, '_readDevFSFile', args: { - 'fsName': fsId, - 'path': '../foo', - }); + await callMethod( + service, + '_readDevFSFile', + args: { + 'fsName': fsId, + 'path': '../foo', + }, + ); fail('Unreachable'); } on RPCError catch (e) { expect(e.code, RPCErrorKind.kInvalidParams.code); @@ -139,31 +159,43 @@ final tests = [ } // Write a set of files. - result = await callMethod(service, '_writeDevFSFiles', args: { - 'fsName': fsId, - 'files': [ - ['/a', base64Encode(utf8.encode('a_contents'))], - ['/b', base64Encode(utf8.encode('b_contents'))] - ] - }); + result = await callMethod( + service, + '_writeDevFSFiles', + args: { + 'fsName': fsId, + 'files': [ + ['/a', base64Encode(utf8.encode('a_contents'))], + ['/b', base64Encode(utf8.encode('b_contents'))], + ], + }, + ); expectSuccess(result); // Read one of the files back. - result = await callMethod(service, '_readDevFSFile', args: { - 'fsName': fsId, - 'path': '/b', - }); + result = await callMethod( + service, + '_readDevFSFile', + args: { + 'fsName': fsId, + 'path': '/b', + }, + ); - if (result case {'type': 'FSFile', 'fileContents': String contents}) { + if (result case {'type': 'FSFile', 'fileContents': final String contents}) { expect(contents, base64Encode(utf8.encode('b_contents'))); } else { invalidResponse(result); } // List all the files in the file system. - result = await callMethod(service, '_listDevFSFiles', args: { - 'fsName': fsId, - }); + result = await callMethod( + service, + '_listDevFSFiles', + args: { + 'fsName': fsId, + }, + ); if (result case {'type': 'FSFileList', 'files': [_, _, _]}) { // Expected } else { @@ -171,9 +203,13 @@ final tests = [ } // Delete DevFS. - result = await callMethod(service, '_deleteDevFS', args: { - 'fsName': fsId, - }); + result = await callMethod( + service, + '_deleteDevFS', + args: { + 'fsName': fsId, + }, + ); expectSuccess(result); }, ]; diff --git a/pkg/vm_service/test/private_rpcs/dev_fs_uri_test.dart b/pkg/vm_service/test/private_rpcs/dev_fs_uri_test.dart index b644b228b52..5b20ae43347 100644 --- a/pkg/vm_service/test/private_rpcs/dev_fs_uri_test.dart +++ b/pkg/vm_service/test/private_rpcs/dev_fs_uri_test.dart @@ -15,9 +15,12 @@ import 'private_rpc_common.dart'; Future readResponse(HttpClientResponse response) { final completer = Completer(); final contents = StringBuffer(); - response.cast>().transform(utf8.decoder).listen((String data) { - contents.write(data); - }, onDone: () => completer.complete(contents.toString())); + response.cast>().transform(utf8.decoder).listen( + (String data) { + contents.write(data); + }, + onDone: () => completer.complete(contents.toString()), + ); return completer.future; } @@ -62,7 +65,7 @@ final tests = [ // Write the file by issuing an HTTP PUT. result = await postToDevFS(content: [9]); - if (result case {'result': Map innerResult}) { + if (result case {'result': final Map innerResult}) { expectSuccess(innerResult); } else { invalidResponse(result); @@ -70,7 +73,7 @@ final tests = [ // Trigger an error by issuing an HTTP PUT. result = await postToDevFS(content: fileContents, omitDevFsUri: true); - if (result case {'error': {'data': {'details': String details}}}) { + if (result case {'error': {'data': {'details': final String details}}}) { expect(details.contains("expects the 'path' parameter"), true); } else { invalidResponse(result); @@ -78,45 +81,61 @@ final tests = [ // Write the file again but this time with the true file contents. result = await postToDevFS(content: fileContents); - if (result case {'result': Map innerResult}) { + if (result case {'result': final Map innerResult}) { expectSuccess(innerResult); } else { invalidResponse(result); } // Read the file back. - result = await callMethod(service, '_readDevFSFile', args: { - 'fsName': fsId, - 'uri': fileUri.toString(), - }); - if (result case {'type': 'FSFile', 'fileContents': String contents}) { + result = await callMethod( + service, + '_readDevFSFile', + args: { + 'fsName': fsId, + 'uri': fileUri.toString(), + }, + ); + if (result case {'type': 'FSFile', 'fileContents': final String contents}) { expect(contents, fileContentsBase64); } else { invalidResponse(result); } // Write a second file via URI. - result = await callMethod(service, '_writeDevFSFile', args: { - 'fsName': fsId, - 'uri': fileUri2.toString(), - 'fileContents': fileContentsBase64 - }); + result = await callMethod( + service, + '_writeDevFSFile', + args: { + 'fsName': fsId, + 'uri': fileUri2.toString(), + 'fileContents': fileContentsBase64, + }, + ); // Read the second file back. - result = await callMethod(service, '_readDevFSFile', args: { - 'fsName': fsId, - 'uri': fileUri2.toString(), - }); - if (result case {'type': 'FSFile', 'fileContents': String contents}) { + result = await callMethod( + service, + '_readDevFSFile', + args: { + 'fsName': fsId, + 'uri': fileUri2.toString(), + }, + ); + if (result case {'type': 'FSFile', 'fileContents': final String contents}) { expect(contents, fileContentsBase64); } else { invalidResponse(result); } // Delete DevFS. - result = await callMethod(service, '_deleteDevFS', args: { - 'fsName': fsId, - }); + result = await callMethod( + service, + '_deleteDevFS', + args: { + 'fsName': fsId, + }, + ); expectSuccess(result); }, ]; diff --git a/pkg/vm_service/test/private_rpcs/dev_fs_weird_char_test.dart b/pkg/vm_service/test/private_rpcs/dev_fs_weird_char_test.dart index e205dd41190..17171a2ee89 100644 --- a/pkg/vm_service/test/private_rpcs/dev_fs_weird_char_test.dart +++ b/pkg/vm_service/test/private_rpcs/dev_fs_weird_char_test.dart @@ -30,28 +30,40 @@ final tests = [ } // Write the file. - result = await callMethod(service, '_writeDevFSFile', args: { - 'fsName': fsId, - 'path': filePath, - 'fileContents': fileContents, - }); + result = await callMethod( + service, + '_writeDevFSFile', + args: { + 'fsName': fsId, + 'path': filePath, + 'fileContents': fileContents, + }, + ); expectSuccess(result); // Read the file back. - result = await callMethod(service, '_readDevFSFile', args: { - 'fsName': fsId, - 'path': filePath, - }); - if (result case {'type': 'FSFile', 'fileContents': String contents}) { + result = await callMethod( + service, + '_readDevFSFile', + args: { + 'fsName': fsId, + 'path': filePath, + }, + ); + if (result case {'type': 'FSFile', 'fileContents': final String contents}) { expect(contents, fileContents); } else { invalidResponse(result); } // List all the files in the file system. - result = await callMethod(service, '_listDevFSFiles', args: { - 'fsName': fsId, - }); + result = await callMethod( + service, + '_listDevFSFiles', + args: { + 'fsName': fsId, + }, + ); if (result case { 'type': 'FSFileList', @@ -63,9 +75,13 @@ final tests = [ } // Delete DevFS. - result = await callMethod(service, '_deleteDevFS', args: { - 'fsName': fsId, - }); + result = await callMethod( + service, + '_deleteDevFS', + args: { + 'fsName': fsId, + }, + ); expectSuccess(result); }, ]; diff --git a/pkg/vm_service/test/private_rpcs/echo_test.dart b/pkg/vm_service/test/private_rpcs/echo_test.dart index eee7e4e92b1..4f701846523 100644 --- a/pkg/vm_service/test/private_rpcs/echo_test.dart +++ b/pkg/vm_service/test/private_rpcs/echo_test.dart @@ -24,18 +24,24 @@ var tests = [ }, (VmService service, IsolateRef isolateRef) async { // Echo from VM target. - final result = await service.callMethod('_echo', args: { - 'text': 'hello', - }); + final result = await service.callMethod( + '_echo', + args: { + 'text': 'hello', + }, + ); expect(result, isA()); expect((result as EchoResponse).text, 'hello'); }, (VmService service, IsolateRef isolateRef) async { // Echo from Isolate target. - final result = - await service.callMethod('_echo', isolateId: isolateRef.id!, args: { - 'text': 'hello', - }); + final result = await service.callMethod( + '_echo', + isolateId: isolateRef.id!, + args: { + 'text': 'hello', + }, + ); expect(result, isA()); expect((result as EchoResponse).text, 'hello'); }, @@ -65,7 +71,7 @@ var tests = [ }, ]; -main(args) => runIsolateTests( +Future main(args) => runIsolateTests( args, tests, 'echo_test.dart', diff --git a/pkg/vm_service/test/private_rpcs/get_heap_map_rpc_test.dart b/pkg/vm_service/test/private_rpcs/get_heap_map_rpc_test.dart index ff8dcbe58ec..a674f990398 100644 --- a/pkg/vm_service/test/private_rpcs/get_heap_map_rpc_test.dart +++ b/pkg/vm_service/test/private_rpcs/get_heap_map_rpc_test.dart @@ -59,11 +59,17 @@ enum GCType { } extension on VmService { - Future getHeapMap(String isolateId, - {GCType gc = GCType.none}) async => - await callMethod('_getHeapMap', isolateId: isolateId, args: { - if (gc != GCType.none) 'gc': gc.toString(), - }) as HeapMap; + Future getHeapMap( + String isolateId, { + GCType gc = GCType.none, + }) async => + await callMethod( + '_getHeapMap', + isolateId: isolateId, + args: { + if (gc != GCType.none) 'gc': gc.toString(), + }, + ) as HeapMap; } final tests = [ diff --git a/pkg/vm_service/test/private_rpcs/get_implementation_fields_rpc_test.dart b/pkg/vm_service/test/private_rpcs/get_implementation_fields_rpc_test.dart index 948bade8770..d1b167c00e5 100644 --- a/pkg/vm_service/test/private_rpcs/get_implementation_fields_rpc_test.dart +++ b/pkg/vm_service/test/private_rpcs/get_implementation_fields_rpc_test.dart @@ -8,12 +8,18 @@ import 'package:vm_service/vm_service.dart'; import '../common/test_helper.dart'; Future getImplementationFields( - VmService service, String isolateId, String objectId) async { - return await service.callMethod('_getImplementationFields', - isolateId: isolateId, args: {'objectId': objectId}); + VmService service, + String isolateId, + String objectId, +) async { + return await service.callMethod( + '_getImplementationFields', + isolateId: isolateId, + args: {'objectId': objectId}, + ); } -var tests = [ +final tests = [ // A null object. (VmService service, IsolateRef isolateRef) async { final isolateId = isolateRef.id!; @@ -24,5 +30,8 @@ var tests = [ }, ]; -main([args = const []]) async => - runIsolateTests(args, tests, 'get_implementation_fields_rpc_test.dart'); +void main([args = const []]) => runIsolateTests( + args, + tests, + 'get_implementation_fields_rpc_test.dart', + ); diff --git a/pkg/vm_service/test/private_rpcs/get_retained_size_rpc_test.dart b/pkg/vm_service/test/private_rpcs/get_retained_size_rpc_test.dart index 5ac61a0b45f..e615d947be5 100644 --- a/pkg/vm_service/test/private_rpcs/get_retained_size_rpc_test.dart +++ b/pkg/vm_service/test/private_rpcs/get_retained_size_rpc_test.dart @@ -39,9 +39,13 @@ extension on VmService { String isolateId, String targetId, ) async { - return await callMethod('_getRetainedSize', isolateId: isolateId, args: { - 'targetId': targetId, - }) as InstanceRef; + return await callMethod( + '_getRetainedSize', + isolateId: isolateId, + args: { + 'targetId': targetId, + }, + ) as InstanceRef; } } diff --git a/pkg/vm_service/test/private_rpcs/native_metrics_test.dart b/pkg/vm_service/test/private_rpcs/native_metrics_test.dart index ee3e7bbe943..bf004f42976 100644 --- a/pkg/vm_service/test/private_rpcs/native_metrics_test.dart +++ b/pkg/vm_service/test/private_rpcs/native_metrics_test.dart @@ -41,12 +41,14 @@ class MetricList { extension on VmService { Future getIsolateMetricList(String isolateId) async { - final response = await callMethod('_getIsolateMetricList', - isolateId: isolateId, - // Only native metrics are supported. - args: { - 'type': 'Native', - }); + final response = await callMethod( + '_getIsolateMetricList', + isolateId: isolateId, + // Only native metrics are supported. + args: { + 'type': 'Native', + }, + ); return MetricList.parse(response.json)!; } diff --git a/pkg/vm_service/test/private_rpcs/reachable_size_test.dart b/pkg/vm_service/test/private_rpcs/reachable_size_test.dart index 6c26bd2dcc6..f7b626ce6c3 100644 --- a/pkg/vm_service/test/private_rpcs/reachable_size_test.dart +++ b/pkg/vm_service/test/private_rpcs/reachable_size_test.dart @@ -22,7 +22,7 @@ dynamic p1; @pragma('vm:entry-point') // Prevent obfuscation dynamic p2; -buildGraph() { +void buildGraph() { p1 = Pair(); p2 = Pair(); diff --git a/pkg/vm_service/test/private_rpcs/type_arguments_test.dart b/pkg/vm_service/test/private_rpcs/type_arguments_test.dart index d2314d008ad..8cf37d753b0 100644 --- a/pkg/vm_service/test/private_rpcs/type_arguments_test.dart +++ b/pkg/vm_service/test/private_rpcs/type_arguments_test.dart @@ -32,12 +32,14 @@ extension on VmService { String isolateId, bool onlyWithInstantiations, ) async { - final response = await callMethod('_getTypeArgumentsList', - isolateId: isolateId, - // Only native metrics are supported. - args: { - 'onlyWithInstantiations': onlyWithInstantiations, - }); + final response = await callMethod( + '_getTypeArgumentsList', + isolateId: isolateId, + // Only native metrics are supported. + args: { + 'onlyWithInstantiations': onlyWithInstantiations, + }, + ); return TypeArgumentsList.parse(response.json)!; } } diff --git a/pkg/vm_service/test/process_service_test.dart b/pkg/vm_service/test/process_service_test.dart index accdfd07e70..55fffaf4946 100644 --- a/pkg/vm_service/test/process_service_test.dart +++ b/pkg/vm_service/test/process_service_test.dart @@ -73,7 +73,7 @@ Future setupProcesses() async { final result = jsonEncode({ 'type': 'foobar', - 'pids': [process1!.pid, process2!.pid, process3!.pid] + 'pids': [process1!.pid, process2!.pid, process3!.pid], }); return Future.value(ServiceExtensionResponse.result(result)); } @@ -151,7 +151,7 @@ final processTests = [ }, ]; -main([args = const []]) async => runIsolateTests( +void main([args = const []]) => runIsolateTests( args, processTests, 'process_service_test.dart', diff --git a/pkg/vm_service/test/regress_34841_test.dart b/pkg/vm_service/test/regress_34841_test.dart index e44ab5bfd5f..83212a3144d 100644 --- a/pkg/vm_service/test/regress_34841_test.dart +++ b/pkg/vm_service/test/regress_34841_test.dart @@ -71,8 +71,8 @@ final tests = [ // Make sure we can translate it all. for (int place in coveragePlaces) { - int? line = script.getLineNumberFromTokenPos(place); - int? column = script.getColumnNumberFromTokenPos(place); + final int? line = script.getLineNumberFromTokenPos(place); + final int? column = script.getColumnNumberFromTokenPos(place); if (line == null || column == null) { throw 'Token $place translated to $line:$column'; } diff --git a/pkg/vm_service/test/regress_43940_test.dart b/pkg/vm_service/test/regress_43940_test.dart index b7ba5ce4b18..c918af364c4 100644 --- a/pkg/vm_service/test/regress_43940_test.dart +++ b/pkg/vm_service/test/regress_43940_test.dart @@ -9,9 +9,11 @@ import 'package:vm_service/vm_service.dart'; void main() { test('Call dispose handler before onDone completion', () async { - final controller = StreamController(onCancel: () async { - await Future.delayed(const Duration(seconds: 1)); - }); + final controller = StreamController( + onCancel: () async { + await Future.delayed(const Duration(seconds: 1)); + }, + ); bool completed = false; final fakeService = VmService( controller.stream, @@ -24,5 +26,6 @@ void main() { unawaited(fakeService.dispose()); await fakeService.onDone; expect(completed, true); + await controller.close(); }); } diff --git a/pkg/vm_service/test/regress_44588_test.dart b/pkg/vm_service/test/regress_44588_test.dart index b9ab0b34f67..6e6f803288f 100644 --- a/pkg/vm_service/test/regress_44588_test.dart +++ b/pkg/vm_service/test/regress_44588_test.dart @@ -24,7 +24,7 @@ var tests = [ } ]; -main([args = const []]) => runIsolateTests( +Future main([args = const []]) => runIsolateTests( args, tests, 'regress_44588_test.dart', diff --git a/pkg/vm_service/test/regress_44842_test.dart b/pkg/vm_service/test/regress_44842_test.dart index f7dc88e4ff2..a4d5a238d6c 100644 --- a/pkg/vm_service/test/regress_44842_test.dart +++ b/pkg/vm_service/test/regress_44842_test.dart @@ -13,7 +13,7 @@ const Map kNullInstance = { 'type': '@Class', 'id': 'object/0', 'name': 'Null', - } + }, }; void main() { diff --git a/pkg/vm_service/test/regress_46419_test.dart b/pkg/vm_service/test/regress_46419_test.dart index 57f81840926..e3e47851a57 100644 --- a/pkg/vm_service/test/regress_46419_test.dart +++ b/pkg/vm_service/test/regress_46419_test.dart @@ -35,13 +35,13 @@ void printSync() { } } -printSyncStar() sync* { +Iterable printSyncStar() sync* { // We'll end up resolving breakpoint 1 to this location instead of at LINE_A // if #46419 regresses. print('sync*'); // LINE_C } -testeeDo() { +void testeeDo() { printSync(); final iterator = printSyncStar(); diff --git a/pkg/vm_service/test/regress_46559_test.dart b/pkg/vm_service/test/regress_46559_test.dart index 84fceaeca1e..3b573917894 100644 --- a/pkg/vm_service/test/regress_46559_test.dart +++ b/pkg/vm_service/test/regress_46559_test.dart @@ -11,19 +11,31 @@ import 'package:vm_service/vm_service.dart'; import 'common/service_test_common.dart'; import 'common/test_helper.dart'; +// AUTOGENERATED START +// +// Update these constants by running: +// +// dart pkg/vm_service/test/update_line_numbers.dart +// +const LINE_A = 33; +// AUTOGENERATED END + Future echo( - String method, Map args) async { + String method, + Map args, +) async { print('In service extension'); return ServiceExtensionResponse.result(json.encode(args)); } -testMain() { +void testMain() { registerExtension('ext.foo', echo); - debugger(); + debugger(); // LINE_A } final tests = [ hasStoppedAtBreakpoint, + stoppedAtLine(LINE_A), resumeIsolate, (VmService vm, IsolateRef isolateRef) async { print('waiting for response'); @@ -37,7 +49,7 @@ final tests = [ }, ]; -main([args = const []]) async => await runIsolateTests( +void main([args = const []]) => runIsolateTests( args, tests, 'regress_46559_test.dart', diff --git a/pkg/vm_service/test/regress_48279_test.dart b/pkg/vm_service/test/regress_48279_test.dart index bb7df1f58d5..f112e701138 100644 --- a/pkg/vm_service/test/regress_48279_test.dart +++ b/pkg/vm_service/test/regress_48279_test.dart @@ -17,17 +17,17 @@ class A { List foo = []; } -testeeMain() { - A object = A(); +void testeeMain() { + final A object = A(); object.foo = []; } -var tests = [ +final tests = [ hasStoppedWithUnhandledException, - (VmService? service, IsolateRef? isolateRef) async { + (VmService service, IsolateRef isolateRef) async { print('We stopped!'); - final isolateId = isolateRef!.id!; - final stack = await service!.getStack(isolateId); + final isolateId = isolateRef.id!; + final stack = await service.getStack(isolateId); final topFrame = stack.frames![0]; expect(topFrame.function!.name, equals('foo=')); final result = await service.evaluateInFrame(isolateId, 0, 'T'); @@ -36,7 +36,7 @@ var tests = [ } ]; -main(args) => runIsolateTests( +Future main(args) => runIsolateTests( args, tests, 'regress_48279_test.dart', diff --git a/pkg/vm_service/test/regress_88104_test.dart b/pkg/vm_service/test/regress_88104_test.dart index ba867b5ae16..b32a857adb7 100644 --- a/pkg/vm_service/test/regress_88104_test.dart +++ b/pkg/vm_service/test/regress_88104_test.dart @@ -15,10 +15,19 @@ import 'package:vm_service/vm_service.dart'; import 'common/service_test_common.dart'; import 'common/test_helper.dart'; +// AUTOGENERATED START +// +// Update these constants by running: +// +// dart pkg/vm_service/test/update_line_numbers.dart +// +const LINE_A = 30; +// AUTOGENERATED END + class Foo {} -testMain() async { - debugger(); +Future testMain() async { + debugger(); // LINE_A for (int i = 0; i < 10; ++i) { Foo(); await Future.delayed(const Duration(milliseconds: 10)); @@ -27,6 +36,7 @@ testMain() async { final tests = [ hasStoppedAtBreakpoint, + stoppedAtLine(LINE_A), (VmService service, IsolateRef isolateRef) async { final isolateId = isolateRef.id!; final isolate = await service.getIsolate(isolateId); @@ -39,7 +49,7 @@ final tests = [ hasStoppedAtExit, ]; -main([args = const []]) => runIsolateTests( +void main([args = const []]) => runIsolateTests( args, tests, 'regress_88104_test.dart', diff --git a/pkg/vm_service/test/reload_sources_rpc_triggers_isolate_reload_event_test.dart b/pkg/vm_service/test/reload_sources_rpc_triggers_isolate_reload_event_test.dart index ac87fe04a10..e73eed49c10 100644 --- a/pkg/vm_service/test/reload_sources_rpc_triggers_isolate_reload_event_test.dart +++ b/pkg/vm_service/test/reload_sources_rpc_triggers_isolate_reload_event_test.dart @@ -39,7 +39,7 @@ final tests = [ }, ]; -main([args = const []]) async => runIsolateTests( +void main([args = const []]) => runIsolateTests( args, tests, 'reload_sources_rpc_triggers_isolate_reload_event_test.dart', diff --git a/pkg/vm_service/test/rewind_optimized_out_test.dart b/pkg/vm_service/test/rewind_optimized_out_test.dart index 109dfaba46e..a2bb946950d 100644 --- a/pkg/vm_service/test/rewind_optimized_out_test.dart +++ b/pkg/vm_service/test/rewind_optimized_out_test.dart @@ -66,7 +66,10 @@ final tests = [ // We are at our breakpoint with global=100. final result = await service.evaluate( - isolateId, isolate.rootLib!.id!, 'global') as InstanceRef; + isolateId, + isolate.rootLib!.id!, + 'global', + ) as InstanceRef; expect(result.valueAsString, '100'); // Rewind the top stack frame. @@ -78,11 +81,12 @@ final tests = [ caughtException = true; expect(e.code, RPCErrorKind.kIsolateCannotBeResumed.code); expect( - e.details, - startsWith('Cannot rewind to frame 1 due to conflicting compiler ' - 'optimizations. Run the vm with --no-prune-dead-locals ' - 'to disallow these optimizations. Next valid rewind ' - 'frame is ')); + e.details, + startsWith('Cannot rewind to frame 1 due to conflicting compiler ' + 'optimizations. Run the vm with --no-prune-dead-locals ' + 'to disallow these optimizations. Next valid rewind ' + 'frame is '), + ); } expect(caughtException, true); }, diff --git a/pkg/vm_service/test/rpc_error_test.dart b/pkg/vm_service/test/rpc_error_test.dart index 2262547198d..783ad0feb16 100644 --- a/pkg/vm_service/test/rpc_error_test.dart +++ b/pkg/vm_service/test/rpc_error_test.dart @@ -19,14 +19,16 @@ var tests = [ expect(stack.where((e) => e.contains('VmService.callMethod')).length, 1); // Call to vm.callMethod('foo'). expect( - stack.where((e) => e.contains('test/rpc_error_test.dart')).length, 1); + stack.where((e) => e.contains('test/rpc_error_test.dart')).length, + 1, + ); } catch (e) { fail('Expected RPCError, got $e'); } }, ]; -main([args = const []]) async => await runVMTests( +Future main([args = const []]) async => await runVMTests( args, tests, 'rpc_error_test.dart', diff --git a/pkg/vm_service/test/set_breakpoint_state_test.dart b/pkg/vm_service/test/set_breakpoint_state_test.dart index 8151dc70bb9..ec52f15a11e 100644 --- a/pkg/vm_service/test/set_breakpoint_state_test.dart +++ b/pkg/vm_service/test/set_breakpoint_state_test.dart @@ -9,10 +9,17 @@ import 'package:vm_service/vm_service.dart'; import 'common/service_test_common.dart'; import 'common/test_helper.dart'; -const int LINE_A = 17; -const int LINE_B = LINE_A + 1; +// AUTOGENERATED START +// +// Update these constants by running: +// +// dart pkg/vm_service/test/update_line_numbers.dart +// +const LINE_A = 24; +const LINE_B = 25; +// AUTOGENERATED END -testMain() { +void testMain() { while (true) { print('a'); // LINE_A print('b'); // LINE_B @@ -21,7 +28,7 @@ testMain() { late Breakpoint bpt; -var tests = [ +final tests = [ hasPausedAtStart, (VmService service, IsolateRef isolateRef) async { bpt = await service.addBreakpointWithScriptUri( @@ -62,7 +69,7 @@ var tests = [ stoppedAtLine(LINE_A), ]; -main([args = const []]) => runIsolateTests( +void main([args = const []]) => runIsolateTests( args, tests, 'set_breakpoint_state_test.dart', diff --git a/pkg/vm_service/test/set_library_debuggable_rpc_test.dart b/pkg/vm_service/test/set_library_debuggable_rpc_test.dart index aee24e4eb14..8c601ef6af8 100644 --- a/pkg/vm_service/test/set_library_debuggable_rpc_test.dart +++ b/pkg/vm_service/test/set_library_debuggable_rpc_test.dart @@ -36,7 +36,10 @@ final tests = [ bool caughtException = false; try { await service.setLibraryDebuggable( - isolateRef.id!, 'libraries/9999999', false); + isolateRef.id!, + 'libraries/9999999', + false, + ); fail('Unreachable'); } on RPCError catch (e) { caughtException = true; diff --git a/pkg/vm_service/test/sigquit_starts_service_test.dart b/pkg/vm_service/test/sigquit_starts_service_test.dart index 6fa5981d5e9..b8f999e8a22 100644 --- a/pkg/vm_service/test/sigquit_starts_service_test.dart +++ b/pkg/vm_service/test/sigquit_starts_service_test.dart @@ -10,31 +10,35 @@ import 'package:test/test.dart'; void runTest(bool withDartDev) { test( - 'Displays service URI on SIGQUIT ${withDartDev ? '' : 'with --disable-dart-dev'}', - () async { - final process = await Process.start(Platform.resolvedExecutable, [ - if (!withDartDev) '--disable-dart-dev', - Platform.script.resolve('sigquit_starts_service_script.dart').toString(), - ]); + 'Displays service URI on SIGQUIT ${withDartDev ? '' : 'with --disable-dart-dev'}', + () async { + final process = await Process.start(Platform.resolvedExecutable, [ + if (!withDartDev) '--disable-dart-dev', + Platform.script + .resolve('sigquit_starts_service_script.dart') + .toString(), + ]); - final readyCompleter = Completer(); - final completer = Completer(); - late StreamSubscription sub; - sub = process.stdout.transform(utf8.decoder).listen((e) async { - if (e.contains('ready') && !readyCompleter.isCompleted) { - readyCompleter.complete(); - } else if (e.contains('The Dart VM service is listening on')) { - await sub.cancel(); - completer.complete(); - } - }); + final readyCompleter = Completer(); + final completer = Completer(); + late StreamSubscription sub; + sub = process.stdout.transform(utf8.decoder).listen((e) async { + if (e.contains('ready') && !readyCompleter.isCompleted) { + readyCompleter.complete(); + } else if (e.contains('The Dart VM service is listening on')) { + await sub.cancel(); + completer.complete(); + } + }); - // Wait for the process to start. - await readyCompleter.future; - process.kill(ProcessSignal.sigquit); - await completer.future; - process.kill(); - }, skip: Platform.isWindows); + // Wait for the process to start. + await readyCompleter.future; + process.kill(ProcessSignal.sigquit); + await completer.future; + process.kill(); + }, + skip: Platform.isWindows, + ); } void main() { diff --git a/pkg/vm_service/test/simple_reload_test.dart b/pkg/vm_service/test/simple_reload_test.dart index 79d9d24d64a..4f07df1e784 100644 --- a/pkg/vm_service/test/simple_reload_test.dart +++ b/pkg/vm_service/test/simple_reload_test.dart @@ -38,7 +38,7 @@ Future testMain() async { print(baseUri); debugger(); // LINE_A // Spawn the child isolate. - I.Isolate isolate = await I.Isolate.spawnUri(spawnUri, [], null); + final I.Isolate isolate = await I.Isolate.spawnUri(spawnUri, [], null); print(isolate); debugger(); // LINE_B } diff --git a/pkg/vm_service/test/source_report_libraries_already_compiled_test.dart b/pkg/vm_service/test/source_report_libraries_already_compiled_test.dart index edae10b0aa4..f9d58c6bf73 100644 --- a/pkg/vm_service/test/source_report_libraries_already_compiled_test.dart +++ b/pkg/vm_service/test/source_report_libraries_already_compiled_test.dart @@ -51,45 +51,46 @@ final tests = [ final target = Platform.script.toString(); -librariesAlreadyCompiledTest( +Future Function(VmService service, IsolateRef isolateRef) + librariesAlreadyCompiledTest( bool forceCompile, List librariesAlreadyCompiled, List expectedHits, List expectedMisses, ) => - (VmService service, IsolateRef isolateRef) async { - final isolateId = isolateRef.id!; + (VmService service, IsolateRef isolateRef) async { + final isolateId = isolateRef.id!; - final report = await service.getSourceReport( - isolateId, - [SourceReportKind.kCoverage], - forceCompile: forceCompile, - reportLines: true, - librariesAlreadyCompiled: librariesAlreadyCompiled, - ); + final report = await service.getSourceReport( + isolateId, + [SourceReportKind.kCoverage], + forceCompile: forceCompile, + reportLines: true, + librariesAlreadyCompiled: librariesAlreadyCompiled, + ); - addLines(List? lines, Set out) { - for (final line in lines ?? []) { - if (line < ignoreHitsBelowThisLine) { - out.add(line); + void addLines(List? lines, Set out) { + for (final line in lines ?? []) { + if (line < ignoreHitsBelowThisLine) { + out.add(line); + } + } } - } - } - final hits = {}; - final misses = {}; - for (final range in report.ranges!) { - if (report.scripts?[range.scriptIndex!].uri == target) { - addLines(range.coverage?.hits, hits); - addLines(range.coverage?.misses, misses); - } - } + final hits = {}; + final misses = {}; + for (final range in report.ranges!) { + if (report.scripts?[range.scriptIndex!].uri == target) { + addLines(range.coverage?.hits, hits); + addLines(range.coverage?.misses, misses); + } + } - expect(hits, unorderedEquals(expectedHits)); - expect(misses, unorderedEquals(expectedMisses)); - }; + expect(hits, unorderedEquals(expectedHits)); + expect(misses, unorderedEquals(expectedMisses)); + }; -main([args = const []]) async => await runIsolateTests( +void main([args = const []]) => runIsolateTests( args, tests, target, diff --git a/pkg/vm_service/test/source_report_package_filters_test.dart b/pkg/vm_service/test/source_report_package_filters_test.dart index 54e9b0eabef..556c559e0d4 100644 --- a/pkg/vm_service/test/source_report_package_filters_test.dart +++ b/pkg/vm_service/test/source_report_package_filters_test.dart @@ -36,13 +36,17 @@ IsolateTest filterTestImpl(List filters, Function(Set) check) { } IsolateTest filterTestExactlyMatches( - List filters, List expectedScripts) => + List filters, + List expectedScripts, +) => filterTestImpl(filters, (Set scripts) { expect(scripts, unorderedEquals(expectedScripts)); }); IsolateTest filterTestContains( - List filters, List expectedScripts) => + List filters, + List expectedScripts, +) => filterTestImpl(filters, (Set scripts) { expect(scripts, containsAll(expectedScripts)); }); @@ -80,7 +84,7 @@ var tests = [ resumeIsolate, ]; -main([args = const []]) => runIsolateTests( +Future main([args = const []]) => runIsolateTests( args, tests, 'source_report_package_filters_test.dart', diff --git a/pkg/vm_service/test/step_through_arithmetic_test.dart b/pkg/vm_service/test/step_through_arithmetic_test.dart index 15bdbc5118f..9a11d06a127 100644 --- a/pkg/vm_service/test/step_through_arithmetic_test.dart +++ b/pkg/vm_service/test/step_through_arithmetic_test.dart @@ -55,7 +55,7 @@ final tests = [ debugPrint: true, debugPrintFile: file, debugPrintLine: LINE_A, - ) + ), ]; void main([args = const []]) => runIsolateTests( diff --git a/pkg/vm_service/test/step_through_constructor_calls_test.dart b/pkg/vm_service/test/step_through_constructor_calls_test.dart index 8eeff63e11c..8a438f048e4 100644 --- a/pkg/vm_service/test/step_through_constructor_calls_test.dart +++ b/pkg/vm_service/test/step_through_constructor_calls_test.dart @@ -17,15 +17,15 @@ const LINE_A = 20; const file = 'step_through_constructor_calls_test.dart'; void code() { - Foo foo1 = Foo(); // LINE_A + final Foo foo1 = Foo(); // LINE_A print(foo1.x); - Foo foo2 = Foo.named(); + final Foo foo2 = Foo.named(); print(foo2.x); - Foo foo3 = const Foo(); + final Foo foo3 = const Foo(); print(foo3.x); - Foo foo4 = const Foo.named(); + final Foo foo4 = const Foo.named(); print(foo4.x); - Foo foo5 = Foo.named2(1, 2, 3); + final Foo foo5 = Foo.named2(1, 2, 3); print(foo5.x); } @@ -42,23 +42,23 @@ class Foo { final stops = []; const expected = [ - '$file:${LINE_A + 0}:14', // on 'Foo' + '$file:${LINE_A + 0}:20', // on 'Foo' '$file:${LINE_A + 15}:12', // on '(' in 'const Foo() : x = 1;' '$file:${LINE_A + 15}:22', // on ';' in same line '$file:${LINE_A + 1}:14', // on 'x' '$file:${LINE_A + 1}:3', // on print - '$file:${LINE_A + 2}:18', // on 'named' + '$file:${LINE_A + 2}:24', // on 'named' '$file:${LINE_A + 17}:18', // on '(' in 'const Foo.named() : x = 2;' '$file:${LINE_A + 17}:28', // on ';' in same line '$file:${LINE_A + 3}:14', // on 'x' '$file:${LINE_A + 3}:3', // on print - '$file:${LINE_A + 4}:12', // on '=' + '$file:${LINE_A + 4}:18', // on '=' '$file:${LINE_A + 5}:14', // on 'x' '$file:${LINE_A + 5}:3', // on print - '$file:${LINE_A + 6}:12', // on '=' + '$file:${LINE_A + 6}:18', // on '=' '$file:${LINE_A + 7}:14', // on 'x' '$file:${LINE_A + 7}:3', // on print - '$file:${LINE_A + 8}:18', // on 'named2' + '$file:${LINE_A + 8}:24', // on 'named2' '$file:${LINE_A + 19}:54', // on 'ccccccccccccc' '$file:${LINE_A + 20}:22', // on first '+' '$file:${LINE_A + 20}:35', // on second '+' diff --git a/pkg/vm_service/test/step_through_extension_type_method_call_test.dart b/pkg/vm_service/test/step_through_extension_type_method_call_test.dart index fced126f544..6bada32d72d 100644 --- a/pkg/vm_service/test/step_through_extension_type_method_call_test.dart +++ b/pkg/vm_service/test/step_through_extension_type_method_call_test.dart @@ -20,18 +20,18 @@ extension type IdNumber(int i) { operator <(IdNumber other) => i < other.i; } -testMain() { - IdNumber id1 = IdNumber(123); - IdNumber id2 = IdNumber(999); +void testMain() { + final IdNumber id1 = IdNumber(123); + final IdNumber id2 = IdNumber(999); id1 < id2; } -List stops = []; +final stops = []; -List expected = [ - '$fileName:${testMainStartLine + 0}:9', // on '()' - '$fileName:${testMainStartLine + 1}:18', // on 'IdNumber' - '$fileName:${testMainStartLine + 2}:18', // on 'IdNumber' +const expected = [ + '$fileName:${testMainStartLine + 0}:14', // on '()' + '$fileName:${testMainStartLine + 1}:24', // on 'IdNumber' + '$fileName:${testMainStartLine + 2}:24', // on 'IdNumber' '$fileName:${testMainStartLine + 3}:7', // on '<' '$fileName:${inlineClassDefinitionStartLine + 1}:23', // on 'other' '$fileName:${inlineClassDefinitionStartLine + 1}:35', // on '<' @@ -56,7 +56,7 @@ final tests = [ checkRecordedStops(stops, expected), ]; -main(args) => runIsolateTestsSynchronous( +void main(args) => runIsolateTests( args, tests, fileName, diff --git a/pkg/vm_service/test/step_through_for_each_sync_star_2_test.dart b/pkg/vm_service/test/step_through_for_each_sync_star_2_test.dart index b9d02a8be56..df8079e0a46 100644 --- a/pkg/vm_service/test/step_through_for_each_sync_star_2_test.dart +++ b/pkg/vm_service/test/step_through_for_each_sync_star_2_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// ignore_for_file: prefer_final_locals + import 'common/service_test_common.dart'; import 'common/test_helper.dart'; @@ -11,7 +13,7 @@ import 'common/test_helper.dart'; // // dart pkg/vm_service/test/update_line_numbers.dart // -const LINE_A = 19; +const LINE_A = 21; // AUTOGENERATED END const String file = 'step_through_for_each_sync_star_2_test.dart'; diff --git a/pkg/vm_service/test/step_through_for_each_sync_star_test.dart b/pkg/vm_service/test/step_through_for_each_sync_star_test.dart index 813890e50ae..bcc752ef4a4 100644 --- a/pkg/vm_service/test/step_through_for_each_sync_star_test.dart +++ b/pkg/vm_service/test/step_through_for_each_sync_star_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// ignore_for_file: prefer_final_locals + import 'common/service_test_common.dart'; import 'common/test_helper.dart'; @@ -11,7 +13,7 @@ import 'common/test_helper.dart'; // // dart pkg/vm_service/test/update_line_numbers.dart // -const LINE_A = 19; +const LINE_A = 21; // AUTOGENERATED END const file = 'step_through_for_each_sync_star_test.dart'; @@ -23,10 +25,10 @@ void code() /* LINE_A */ { } Iterable generator() sync* { - var x = 3; - var y = 4; + int x = 3; + int y = 4; yield y; - var z = x + y; + int z = x + y; yield z; } diff --git a/pkg/vm_service/test/step_through_function_2_test.dart b/pkg/vm_service/test/step_through_function_2_test.dart index 2aba8156f5a..dd023bacad7 100644 --- a/pkg/vm_service/test/step_through_function_2_test.dart +++ b/pkg/vm_service/test/step_through_function_2_test.dart @@ -17,7 +17,7 @@ const LINE_A = 19; const file = 'step_through_function_2_test.dart'; void code() /* LINE_A */ { - Bar bar = Bar(); + final Bar bar = Bar(); bar.barXYZ1(42); bar.barXYZ2(42); fooXYZ1(42); @@ -52,7 +52,7 @@ class Bar { final stops = []; const expected = [ '$file:${LINE_A + 0}:10', // after 'code' - '$file:${LINE_A + 1}:13', // on 'Bar' + '$file:${LINE_A + 1}:19', // on 'Bar' '$file:${LINE_A + 2}:7', // on 'barXYZ1' '$file:${LINE_A + 22}:20', // on 'i' @@ -75,7 +75,7 @@ const expected = [ '$file:${LINE_A + 16}:3', // on '_xyz' '$file:${LINE_A + 17}:1', // on '}' - '$file:${LINE_A + 6}:1' // on ending '}' + '$file:${LINE_A + 6}:1', // on ending '}' ]; final tests = [ diff --git a/pkg/vm_service/test/step_through_getter_test.dart b/pkg/vm_service/test/step_through_getter_test.dart index 9e53d18655a..0e5d1dee4b7 100644 --- a/pkg/vm_service/test/step_through_getter_test.dart +++ b/pkg/vm_service/test/step_through_getter_test.dart @@ -69,7 +69,7 @@ const expected = [ '$file:${LINE_A + 12}:3', // on 'return' '$file:${LINE_A + 5}:3', // on 'print' - '$file:${LINE_A + 6}:1' // on ending '}' + '$file:${LINE_A + 6}:1', // on ending '}' ]; final tests = [ diff --git a/pkg/vm_service/test/step_through_mixin_from_sdk_test.dart b/pkg/vm_service/test/step_through_mixin_from_sdk_test.dart index 5c3fbc031df..5e4476c1939 100644 --- a/pkg/vm_service/test/step_through_mixin_from_sdk_test.dart +++ b/pkg/vm_service/test/step_through_mixin_from_sdk_test.dart @@ -63,7 +63,7 @@ const expected = [ 'list.dart:91:23', // on '<' in 'i < length' 'list.dart:97:5', // on 'return' '$file:${LINE_A + 4}:5', // on 'print' - '$file:${LINE_A + 6}:1' // on ending '}' + '$file:${LINE_A + 6}:1', // on ending '}' ]; final tests = [ diff --git a/pkg/vm_service/test/step_through_patterns_test.dart b/pkg/vm_service/test/step_through_patterns_test.dart index 4ec9a3e7a08..c3c00a557dd 100644 --- a/pkg/vm_service/test/step_through_patterns_test.dart +++ b/pkg/vm_service/test/step_through_patterns_test.dart @@ -8,7 +8,14 @@ import 'dart:math' show pi; import 'common/service_test_common.dart'; import 'common/test_helper.dart'; -const int LINE = 26; +// AUTOGENERATED START +// +// Update these constants by running: +// +// dart pkg/vm_service/test/update_line_numbers.dart +// +const LINE_A = 33; +// AUTOGENERATED END const String FILE = 'step_through_patterns_test.dart'; abstract class Shape {} @@ -23,43 +30,43 @@ class Circle implements Shape { Circle(this.radius); } -double calculateArea(Shape shape) => switch (shape) { - Square(length: var l) when l >= 0 => l * l, - Circle(radius: var r) when r >= 0 => pi * r * r, - Square(length: var l) when l < 0 => -1, - Circle(radius: var r) when r < 0 => -1, +double calculateArea(Shape shape) => switch (shape) /* LINE_A */ { + Square(length: final l) when l >= 0 => l * l, + Circle(radius: final r) when r >= 0 => pi * r * r, + Square(length: final l) when l < 0 => -1, + Circle(radius: final r) when r < 0 => -1, Shape() => 0 }; -testMain() { +void testMain() { calculateArea(Circle(-123)); } -List stops = []; +final stops = []; -List expected = [ - '$FILE:${LINE + 0}:28', // on 'shape' before 'switch' - '$FILE:${LINE + 1}:7', // on 'Square' - '$FILE:${LINE + 2}:7', // on 'Circle' - '$FILE:${LINE + 2}:26', // on 'r' right after 'var' - '$FILE:${LINE + 2}:36', // on '>=' - '$FILE:${LINE + 3}:7', // on 'Square' - '$FILE:${LINE + 4}:7', // on 'Circle' - '$FILE:${LINE + 4}:26', // on 'r' right after 'var' - '$FILE:${LINE + 4}:36', // on '<' - '$FILE:${LINE + 4}:40', // on '=>' - '$FILE:${LINE + 0}:38', // on 'switch' - '$FILE:36:1', // on closing '}' of [testMain] +const expected = [ + '$FILE:${LINE_A + 0}:28', // on 'shape' before 'switch' + '$FILE:${LINE_A + 1}:7', // on 'Square' + '$FILE:${LINE_A + 2}:7', // on 'Circle' + '$FILE:${LINE_A + 2}:28', // on 'r' right after 'var' + '$FILE:${LINE_A + 2}:38', // on '>=' + '$FILE:${LINE_A + 3}:7', // on 'Square' + '$FILE:${LINE_A + 4}:7', // on 'Circle' + '$FILE:${LINE_A + 4}:28', // on 'r' right after 'var' + '$FILE:${LINE_A + 4}:38', // on '<' + '$FILE:${LINE_A + 4}:42', // on '=>' + '$FILE:${LINE_A + 0}:38', // on 'switch' + '$FILE:43:1', // on closing '}' of [testMain] ]; -var tests = [ +final tests = [ hasPausedAtStart, - setBreakpointAtLine(LINE), + setBreakpointAtLine(LINE_A), runStepThroughProgramRecordingStops(stops), - checkRecordedStops(stops, expected) + checkRecordedStops(stops, expected), ]; -main(args) => runIsolateTestsSynchronous( +void main(args) => runIsolateTestsSynchronous( args, tests, FILE, diff --git a/pkg/vm_service/test/step_through_property_set_test.dart b/pkg/vm_service/test/step_through_property_set_test.dart index 9ee6e3a7ec5..253673d1cdb 100644 --- a/pkg/vm_service/test/step_through_property_set_test.dart +++ b/pkg/vm_service/test/step_through_property_set_test.dart @@ -70,7 +70,7 @@ const expected = [ '$file:${LINE_A + 7}:22', // on '[' '$file:${LINE_A + 7}:5', // on 'print' - '$file:${LINE_A + 8}:3' // on ending '}' + '$file:${LINE_A + 8}:3', // on ending '}' ]; final tests = [ diff --git a/pkg/vm_service/test/step_through_switch_with_continue_test.dart b/pkg/vm_service/test/step_through_switch_with_continue_test.dart index e0a0aace90f..64914270c1c 100644 --- a/pkg/vm_service/test/step_through_switch_with_continue_test.dart +++ b/pkg/vm_service/test/step_through_switch_with_continue_test.dart @@ -49,7 +49,7 @@ const expected = [ '$file:${LINE_A + 7}:7', // on print '$file:${LINE_A + 8}:7', // on break - '$file:${LINE_A + 15}:1' // on ending '}' + '$file:${LINE_A + 15}:1', // on ending '}' ]; final tests = [ diff --git a/pkg/vm_service/test/super_constructor_invocation_test.dart b/pkg/vm_service/test/super_constructor_invocation_test.dart index dcd10678477..3c304cd3a5b 100644 --- a/pkg/vm_service/test/super_constructor_invocation_test.dart +++ b/pkg/vm_service/test/super_constructor_invocation_test.dart @@ -65,7 +65,7 @@ Future evaluateGetter( String instanceId, String getter, ) async { - dynamic result = await service.evaluate(isolateId, instanceId, getter); + final dynamic result = await service.evaluate(isolateId, instanceId, getter); return await service.getObject(isolateId, result.id); } @@ -143,7 +143,7 @@ final tests = [ expect(result.json['name'], 'int'); }, (VmService service, _) async { - dynamic instance = await createInstance(service, 'B(1, 2, 3, 4)'); + final dynamic instance = await createInstance(service, 'B(1, 2, 3, 4)'); dynamic result = await evaluateGetter(service, instance.id, 'f1'); expect(result.valueAsString, '1'); result = await evaluateGetter(service, instance.id, 'v1'); @@ -177,7 +177,7 @@ final tests = [ } ]; -main([args = const []]) => runIsolateTests( +Future main([args = const []]) => runIsolateTests( args, tests, 'super_constructor_invocation_test.dart', diff --git a/pkg/vm_service/test/test_package/lib/has_part.dart b/pkg/vm_service/test/test_package/lib/has_part.dart index 32d719ab7a7..554b51fa23a 100644 --- a/pkg/vm_service/test/test_package/lib/has_part.dart +++ b/pkg/vm_service/test/test_package/lib/has_part.dart @@ -17,6 +17,6 @@ void fooz() { } void main() { - Foo10 foo = Foo10('Foo!'); + final Foo10 foo = Foo10('Foo!'); print(foo); } diff --git a/pkg/vm_service/test/throws_sentinel_test.dart b/pkg/vm_service/test/throws_sentinel_test.dart index bf525498092..5b1195bb932 100644 --- a/pkg/vm_service/test/throws_sentinel_test.dart +++ b/pkg/vm_service/test/throws_sentinel_test.dart @@ -27,7 +27,7 @@ var tests = [ }, ]; -main([args = const []]) async => await runVMTests( +Future main([args = const []]) async => await runVMTests( args, tests, 'throws_sentinel_test.dart', diff --git a/pkg/vm_service/test/timeline_default_streams_test.dart b/pkg/vm_service/test/timeline_default_streams_test.dart index cbed7b77e96..44b2e2ba73b 100644 --- a/pkg/vm_service/test/timeline_default_streams_test.dart +++ b/pkg/vm_service/test/timeline_default_streams_test.dart @@ -10,7 +10,7 @@ import 'package:test/test.dart'; import 'package:vm_service/vm_service.dart'; import 'package:vm_service/vm_service_io.dart'; -main() { +void main() { late VmService service; setUp(() async { ServiceProtocolInfo serviceInfo = await Service.getInfo(); diff --git a/pkg/vm_service/test/typed_data_test.dart b/pkg/vm_service/test/typed_data_test.dart index d4eded02c1a..528dadef74c 100644 --- a/pkg/vm_service/test/typed_data_test.dart +++ b/pkg/vm_service/test/typed_data_test.dart @@ -147,10 +147,10 @@ final tests = [ Future expectTypedData(String name, Object expectedValue) async { final variable = variables.singleWhere((v) => v.name == name); final actualValue = toTypedElement( - (await service.getObject( + await service.getObject( isolateId, variable.staticValue.id!, - ) as Instance), + ) as Instance, ); if (expectedValue is Int32x4List) { expect(actualValue.length, equals(expectedValue.length)); diff --git a/pkg/vm_service/test/update_line_numbers.dart b/pkg/vm_service/test/update_line_numbers.dart index 89f395a748c..956bb90c455 100644 --- a/pkg/vm_service/test/update_line_numbers.dart +++ b/pkg/vm_service/test/update_line_numbers.dart @@ -21,14 +21,17 @@ void main(List args) { final lineConstantPattern = RegExp(r'^const( int)? LINE_\w+ = \d+;$'); final prefix = content - .takeWhile((line) => - !lineConstantPattern.hasMatch(line) && autogeneratedStart != line) + .takeWhile( + (line) => + !lineConstantPattern.hasMatch(line) && autogeneratedStart != line, + ) .toList(); final suffix = content .skip(prefix.length) .skipWhile( - (line) => line.startsWith('//') || lineConstantPattern.hasMatch(line)) + (line) => line.startsWith('//') || lineConstantPattern.hasMatch(line), + ) .toList(); final lineCommentPattern = @@ -48,8 +51,7 @@ void main(List args) { '//', '// Update these constants by running:', '//', - '// dart pkg/vm_service/test/update_line_numbers.dart ' - '', + '// dart pkg/vm_service/test/update_line_numbers.dart ', '//', ]; @@ -60,12 +62,14 @@ void main(List args) { mapping .updateAll((_, value) => 1 + header.length + mapping.length + 1 + value); - inputFile.writeAsString([ - ...header, - for (var entry in mapping.entries) 'const ${entry.key} = ${entry.value};', - autogeneratedEnd, - ...suffix, - '', - ].join('\n')); + inputFile.writeAsString( + [ + ...header, + for (var entry in mapping.entries) 'const ${entry.key} = ${entry.value};', + autogeneratedEnd, + ...suffix, + '', + ].join('\n'), + ); print('Updated $inputFile'); } diff --git a/pkg/vm_service/test/user_tag_changed_test.dart b/pkg/vm_service/test/user_tag_changed_test.dart index 422c3910c7d..090be2c4741 100644 --- a/pkg/vm_service/test/user_tag_changed_test.dart +++ b/pkg/vm_service/test/user_tag_changed_test.dart @@ -54,7 +54,7 @@ var tests = [ } ]; -main([args = const []]) async => await runIsolateTests( +Future main([args = const []]) async => await runIsolateTests( args, tests, 'user_tag_changed_test.dart', diff --git a/pkg/vm_service/test/verify_http_timeline_test.dart b/pkg/vm_service/test/verify_http_timeline_test.dart index c61a9731ad7..ddaf9f47573 100644 --- a/pkg/vm_service/test/verify_http_timeline_test.dart +++ b/pkg/vm_service/test/verify_http_timeline_test.dart @@ -58,10 +58,12 @@ Uri randomlyAddRequestParams(Uri uri) { possiblePathSegments.sublist(0, rng.nextInt(possiblePathSegments.length)); uri = uri.replace(pathSegments: segmentSubset); if (rng.nextInt(3) == 0) { - uri = uri.replace(queryParameters: { - 'foo': 'bar', - 'year': '2019', - }); + uri = uri.replace( + queryParameters: { + 'foo': 'bar', + 'year': '2019', + }, + ); } return uri; } @@ -78,7 +80,8 @@ Future startServer() async { } // Randomly delay response. await Future.delayed( - Duration(milliseconds: rng.nextInt(maxResponseDelayMs))); + Duration(milliseconds: rng.nextInt(maxResponseDelayMs)), + ); await response.close(); }); return server; @@ -174,8 +177,8 @@ Future testMain() async { print('done'); } -bool isStartEvent(Map event) => (event['ph'] == 'b'); -bool isFinishEvent(Map event) => (event['ph'] == 'e'); +bool isStartEvent(Map event) => event['ph'] == 'b'; +bool isFinishEvent(Map event) => event['ph'] == 'e'; bool hasCompletedEvents(List traceEvents) { final events = {}; @@ -198,11 +201,16 @@ bool hasCompletedEvents(List traceEvents) { } List filterEventsByName( - List traceEvents, String name) => + List traceEvents, + String name, +) => traceEvents.where((e) => e.json!.containsKey(name)).toList(); List filterEventsByIdAndName( - List traceEvents, String id, String name) => + List traceEvents, + String id, + String name, +) => traceEvents .where((e) => e.json!['id'] == id && e.json!['name'].contains(name)) .toList(); @@ -248,7 +256,10 @@ void validateHttpFinishEvent(Map event) { } void hasValidHttpRequests( - HttpProfile profile, List traceEvents, String method) { + HttpProfile profile, + List traceEvents, + String method, +) { final requests = profile.requests .where( (element) => element.method == method, @@ -301,10 +312,14 @@ void hasValidHttpProfile(HttpProfile profile, String method) { } void hasValidHttpCONNECTs( - HttpProfile profile, List traceEvents) => + HttpProfile profile, + List traceEvents, +) => hasValidHttpRequests(profile, traceEvents, 'CONNECT'); void hasValidHttpDELETEs( - HttpProfile profile, List traceEvents) => + HttpProfile profile, + List traceEvents, +) => hasValidHttpRequests(profile, traceEvents, 'DELETE'); void hasValidHttpGETs(HttpProfile profile, List traceEvents) => hasValidHttpRequests(profile, traceEvents, 'GET'); @@ -339,7 +354,7 @@ var tests = [ }, ]; -main(args) async => runIsolateTests( +void main([args = const []]) => runIsolateTests( args, tests, 'verify_http_timeline_test.dart', diff --git a/pkg/vm_service/test/weak_properties_test.dart b/pkg/vm_service/test/weak_properties_test.dart index 7f80718f895..15b7bfd9c60 100644 --- a/pkg/vm_service/test/weak_properties_test.dart +++ b/pkg/vm_service/test/weak_properties_test.dart @@ -34,8 +34,12 @@ void script() { print(weakProperty); } -Future getFieldValue(VmService service, String isolateId, - List variables, String name) async { +Future getFieldValue( + VmService service, + String isolateId, + List variables, + String name, +) async { final fieldRef = variables.singleWhere((v) => v.name == name); final field = await service.getObject( isolateId, diff --git a/pkg/vm_service/test/wrap_future_test.dart b/pkg/vm_service/test/wrap_future_test.dart index 918cfddba02..367a0f2f14a 100644 --- a/pkg/vm_service/test/wrap_future_test.dart +++ b/pkg/vm_service/test/wrap_future_test.dart @@ -70,7 +70,7 @@ var tests = [ }, ]; -main([args = const []]) async => runVMTests( +void main([args = const []]) => runVMTests( args, tests, 'wrap_future_test.dart', diff --git a/pkg/vm_service/test/yield_positions_with_finally_test.dart b/pkg/vm_service/test/yield_positions_with_finally_test.dart index 14af9e5e102..b43867c21ee 100644 --- a/pkg/vm_service/test/yield_positions_with_finally_test.dart +++ b/pkg/vm_service/test/yield_positions_with_finally_test.dart @@ -65,7 +65,7 @@ Stream testMultipleFunctions() async* { // continue statement Stream testContinueSwitch() async* { - int currentState = 0; + final int currentState = 0; switch (currentState) { case 0: { @@ -86,7 +86,7 @@ Stream testContinueSwitch() async* { } Stream testNestFinally() async* { - int i = 0; + final int i = 0; try { if (i == 1) return; await throwException(); // LINE_E @@ -102,13 +102,13 @@ Stream testNestFinally() async* { } Stream testAsyncClosureInFinally() async* { - int i = 0; + final int i = 0; try { if (i == 1) return; await throwException(); // LINE_F } catch (e) { } finally { - inner() async { + Future inner() async { await Future.delayed(Duration(milliseconds: 10)); } @@ -141,7 +141,7 @@ final tests = [ _expectSecondFrameFromTheTopToBeAt(line), resumeIsolate, ], - hasStoppedAtExit + hasStoppedAtExit, ]; Future Function(VmService, IsolateRef) _expectSecondFrameFromTheTopToBeAt(