diff --git a/dwds/test/build_daemon_circular_evaluate_test.dart b/dwds/test/build_daemon_circular_evaluate_test.dart index 9111f14e7..90c2d1794 100644 --- a/dwds/test/build_daemon_circular_evaluate_test.dart +++ b/dwds/test/build_daemon_circular_evaluate_test.dart @@ -10,7 +10,6 @@ import 'package:test_common/test_sdk_configuration.dart'; import 'evaluate_circular_common.dart'; import 'fixtures/context.dart'; -import 'fixtures/project.dart'; void main() async { // Enable verbose logging for debugging. @@ -19,14 +18,9 @@ void main() async { final provider = TestSdkConfigurationProvider(verbose: debug); tearDownAll(provider.dispose); - for (var nullSafety in NullSafety.values) { - group('${nullSafety.name} null safety |', () { - testAll( - provider: provider, - compilationMode: CompilationMode.buildDaemon, - nullSafety: nullSafety, - debug: debug, - ); - }); - } + testAll( + provider: provider, + compilationMode: CompilationMode.buildDaemon, + debug: debug, + ); } diff --git a/dwds/test/build_daemon_evaluate_test.dart b/dwds/test/build_daemon_evaluate_test.dart index 0de8a12f9..45145c93c 100644 --- a/dwds/test/build_daemon_evaluate_test.dart +++ b/dwds/test/build_daemon_evaluate_test.dart @@ -11,7 +11,6 @@ import 'package:test_common/test_sdk_configuration.dart'; import 'evaluate_common.dart'; import 'fixtures/context.dart'; -import 'fixtures/project.dart'; void main() async { // Enable verbose logging for debugging. @@ -20,14 +19,9 @@ void main() async { final provider = TestSdkConfigurationProvider(verbose: debug); tearDownAll(provider.dispose); - for (var nullSafety in NullSafety.values) { - group('${nullSafety.name} null safety |', () { - testAll( - provider: provider, - compilationMode: CompilationMode.buildDaemon, - nullSafety: nullSafety, - debug: debug, - ); - }); - } + testAll( + provider: provider, + compilationMode: CompilationMode.buildDaemon, + debug: debug, + ); } diff --git a/dwds/test/evaluate_circular_common.dart b/dwds/test/evaluate_circular_common.dart index 16ca45470..0a777d298 100644 --- a/dwds/test/evaluate_circular_common.dart +++ b/dwds/test/evaluate_circular_common.dart @@ -19,7 +19,6 @@ void testAll({ required TestSdkConfigurationProvider provider, CompilationMode compilationMode = CompilationMode.buildDaemon, IndexBaseMode indexBaseMode = IndexBaseMode.noBase, - NullSafety nullSafety = NullSafety.sound, bool useDebuggerModuleNames = false, bool debug = false, }) { @@ -30,9 +29,8 @@ void testAll({ ); } - final testCircular1 = TestProject.testCircular1(nullSafety: nullSafety); + final testCircular1 = TestProject.testCircular1(); final testCircular2 = TestProject.testCircular2( - nullSafety: nullSafety, baseMode: indexBaseMode, ); diff --git a/dwds/test/evaluate_common.dart b/dwds/test/evaluate_common.dart index 2b48fe5fc..e10fbd31e 100644 --- a/dwds/test/evaluate_common.dart +++ b/dwds/test/evaluate_common.dart @@ -21,7 +21,6 @@ void testAll({ required TestSdkConfigurationProvider provider, CompilationMode compilationMode = CompilationMode.buildDaemon, IndexBaseMode indexBaseMode = IndexBaseMode.noBase, - NullSafety nullSafety = NullSafety.sound, bool useDebuggerModuleNames = false, bool debug = false, }) { @@ -32,9 +31,8 @@ void testAll({ ); } - final testProject = TestProject.test(nullSafety: nullSafety); - final testPackageProject = - TestProject.testPackage(nullSafety: nullSafety, baseMode: indexBaseMode); + final testProject = TestProject.test(); + final testPackageProject = TestProject.testPackage(baseMode: indexBaseMode); final context = TestContext(testPackageProject, provider); @@ -302,19 +300,6 @@ void testAll({ skip: 'https://github.com/dart-lang/webdev/issues/1371', ); - test('uses correct null safety mode', () async { - await onBreakPoint(mainScript, 'printLocal', (event) async { - final isNullSafetyEnabledExpression = - '() { const sound = !([] is List); return sound; } ()'; - final result = await getInstanceRef( - event.topFrame!.index!, - isNullSafetyEnabledExpression, - ); - final expectedResult = '${nullSafety == NullSafety.sound}'; - expect(result, matchInstanceRef(expectedResult)); - }); - }); - test('does not crash if class metadata cannot be found', () async { await onBreakPoint(mainScript, 'printStream', (event) async { final instanceRef = diff --git a/dwds/test/frontend_server_callstack_test.dart b/dwds/test/frontend_server_callstack_test.dart index d4d89796f..ff78fc066 100644 --- a/dwds/test/frontend_server_callstack_test.dart +++ b/dwds/test/frontend_server_callstack_test.dart @@ -23,294 +23,290 @@ void main() { tearDownAll(provider.dispose); group('shared context |', () { - for (var nullSafety in NullSafety.values) { - group('${nullSafety.name} null safety |', () { - final project = TestProject.testPackage(nullSafety: nullSafety); - final context = TestContext(project, provider); - - setUpAll(() async { - setCurrentLogWriter(debug: debug); - await context.setUp( - testSettings: TestSettings( - compilationMode: CompilationMode.frontendServer, - enableExpressionEvaluation: true, - verboseCompiler: debug, + final project = TestProject.testPackage(); + final context = TestContext(project, provider); + + setUpAll(() async { + setCurrentLogWriter(debug: debug); + await context.setUp( + testSettings: TestSettings( + compilationMode: CompilationMode.frontendServer, + enableExpressionEvaluation: true, + verboseCompiler: debug, + ), + ); + }); + + tearDownAll(() async { + await context.tearDown(); + }); + + group('callStack |', () { + late VmServiceInterface service; + VM vm; + late Isolate isolate; + late String isolateId; + ScriptList scripts; + late ScriptRef mainScript; + late ScriptRef testLibraryScript; + late Stream stream; + + setUp(() async { + setCurrentLogWriter(debug: debug); + service = context.service; + vm = await service.getVM(); + isolate = await service.getIsolate(vm.isolates!.first.id!); + isolateId = isolate.id!; + scripts = await service.getScripts(isolateId); + + await service.streamListen('Debug'); + stream = service.onEvent('Debug'); + + final testPackage = project.packageName; + mainScript = scripts.scripts! + .firstWhere((each) => each.uri!.contains('main.dart')); + testLibraryScript = scripts.scripts!.firstWhere( + (each) => + each.uri!.contains('package:$testPackage/test_library.dart'), + ); + }); + + tearDown(() async { + await service.resume(isolateId); + }); + + Future onBreakPoint( + BreakpointTestData breakpoint, + Future Function() body, + ) async { + Breakpoint? bp; + try { + final bpId = breakpoint.bpId; + final script = breakpoint.script; + final line = + await context.findBreakpointLine(bpId, isolateId, script); + bp = await context.service + .addBreakpointWithScriptUri(isolateId, script.uri!, line); + + expect(bp, isNotNull); + expect(bp.location, _matchBpLocation(script, line, 0)); + + await stream.firstWhere( + (Event event) => event.kind == EventKind.kPauseBreakpoint, + ); + + await body(); + } finally { + // Remove breakpoint so it doesn't impact other tests or retries. + if (bp != null) { + await context.service.removeBreakpoint(isolateId, bp.id!); + } + } + } + + Future testCallStack( + List breakpoints, { + int frameIndex = 1, + }) async { + // Find lines the breakpoints are located on. + final lines = await Future.wait( + breakpoints.map( + (frame) => context.findBreakpointLine( + frame.bpId, + isolateId, + frame.script, + ), + ), + ); + + // Get current stack. + final stack = await service.getStack(isolateId); + + // Verify the stack is correct. + expect(stack.frames!.length, greaterThanOrEqualTo(lines.length)); + final expected = [ + for (var i = 0; i < lines.length; i++) + _matchFrame( + breakpoints[i].script, + breakpoints[i].function, + lines[i], ), + ]; + expect(stack.frames, containsAll(expected)); + + // Verify that expression evaluation is not failing. + final instance = + await service.evaluateInFrame(isolateId, frameIndex, 'true'); + expect(instance, isA()); + } + + test('breakpoint succeeds with correct callstack', () async { + // Expected breakpoints on the stack + final breakpoints = [ + BreakpointTestData( + 'printEnclosingObject', + 'printEnclosingObject', + mainScript, + ), + BreakpointTestData( + 'printEnclosingFunctionMultiLine', + 'printNestedObjectsMultiLine', + mainScript, + ), + BreakpointTestData( + 'callPrintEnclosingFunctionMultiLine', + '', + mainScript, + ), + ]; + await onBreakPoint( + breakpoints[0], + () => testCallStack(breakpoints), + ); + }); + + test('expression evaluation succeeds on parent frame', () async { + // Expected breakpoints on the stack + final breakpoints = [ + BreakpointTestData( + 'testLibraryClassConstructor', + 'new', + testLibraryScript, + ), + BreakpointTestData( + 'createLibraryObject', + 'printFieldFromLibraryClass', + mainScript, + ), + BreakpointTestData( + 'callPrintFieldFromLibraryClass', + '', + mainScript, + ), + ]; + await onBreakPoint( + breakpoints[0], + () => testCallStack(breakpoints, frameIndex: 2), + ); + }); + + test('breakpoint inside a line gives correct callstack', () async { + // Expected breakpoints on the stack + final breakpoints = [ + BreakpointTestData( + 'newEnclosedClass', + 'new', + mainScript, + ), + BreakpointTestData( + 'printNestedObjectMultiLine', + 'printNestedObjectsMultiLine', + mainScript, + ), + BreakpointTestData( + 'callPrintEnclosingFunctionMultiLine', + '', + mainScript, + ), + ]; + await onBreakPoint( + breakpoints[0], + () => testCallStack(breakpoints), + ); + }); + + test('breakpoint gives correct callstack after step out', () async { + // Expected breakpoints on the stack + final breakpoints = [ + BreakpointTestData( + 'newEnclosedClass', + 'new', + mainScript, + ), + BreakpointTestData( + 'printEnclosingObjectMultiLine', + 'printNestedObjectsMultiLine', + mainScript, + ), + BreakpointTestData( + 'callPrintEnclosingFunctionMultiLine', + '', + mainScript, + ), + ]; + await onBreakPoint(breakpoints[0], () async { + await service.resume(isolateId, step: 'Out'); + await stream.firstWhere( + (Event event) => event.kind == EventKind.kPauseInterrupted, ); + return testCallStack([breakpoints[1], breakpoints[2]]); }); + }); - tearDownAll(() async { - await context.tearDown(); + test('breakpoint gives correct callstack after step in', () async { + // Expected breakpoints on the stack + final breakpoints = [ + BreakpointTestData( + 'newEnclosedClass', + 'new', + mainScript, + ), + BreakpointTestData( + 'printNestedObjectMultiLine', + 'printNestedObjectsMultiLine', + mainScript, + ), + BreakpointTestData( + 'callPrintEnclosingFunctionMultiLine', + '', + mainScript, + ), + ]; + await onBreakPoint(breakpoints[1], () async { + await service.resume(isolateId, step: 'Into'); + await stream.firstWhere( + (Event event) => event.kind == EventKind.kPauseInterrupted, + ); + return testCallStack(breakpoints); }); + }); - group('callStack |', () { - late VmServiceInterface service; - VM vm; - late Isolate isolate; - late String isolateId; - ScriptList scripts; - late ScriptRef mainScript; - late ScriptRef testLibraryScript; - late Stream stream; - - setUp(() async { - setCurrentLogWriter(debug: debug); - service = context.service; - vm = await service.getVM(); - isolate = await service.getIsolate(vm.isolates!.first.id!); - isolateId = isolate.id!; - scripts = await service.getScripts(isolateId); - - await service.streamListen('Debug'); - stream = service.onEvent('Debug'); - - final testPackage = project.packageName; - mainScript = scripts.scripts! - .firstWhere((each) => each.uri!.contains('main.dart')); - testLibraryScript = scripts.scripts!.firstWhere( - (each) => - each.uri!.contains('package:$testPackage/test_library.dart'), - ); - }); - - tearDown(() async { - await service.resume(isolateId); - }); - - Future onBreakPoint( - BreakpointTestData breakpoint, - Future Function() body, - ) async { - Breakpoint? bp; - try { - final bpId = breakpoint.bpId; - final script = breakpoint.script; - final line = - await context.findBreakpointLine(bpId, isolateId, script); - bp = await context.service - .addBreakpointWithScriptUri(isolateId, script.uri!, line); - - expect(bp, isNotNull); - expect(bp.location, _matchBpLocation(script, line, 0)); - - await stream.firstWhere( - (Event event) => event.kind == EventKind.kPauseBreakpoint, - ); - - await body(); - } finally { - // Remove breakpoint so it doesn't impact other tests or retries. - if (bp != null) { - await context.service.removeBreakpoint(isolateId, bp.id!); - } - } - } - - Future testCallStack( - List breakpoints, { - int frameIndex = 1, - }) async { - // Find lines the breakpoints are located on. - final lines = await Future.wait( - breakpoints.map( - (frame) => context.findBreakpointLine( - frame.bpId, - isolateId, - frame.script, - ), - ), - ); - - // Get current stack. - final stack = await service.getStack(isolateId); - - // Verify the stack is correct. - expect(stack.frames!.length, greaterThanOrEqualTo(lines.length)); - final expected = [ - for (var i = 0; i < lines.length; i++) - _matchFrame( - breakpoints[i].script, - breakpoints[i].function, - lines[i], - ), - ]; - expect(stack.frames, containsAll(expected)); - - // Verify that expression evaluation is not failing. - final instance = - await service.evaluateInFrame(isolateId, frameIndex, 'true'); - expect(instance, isA()); - } - - test('breakpoint succeeds with correct callstack', () async { - // Expected breakpoints on the stack - final breakpoints = [ - BreakpointTestData( - 'printEnclosingObject', - 'printEnclosingObject', - mainScript, - ), - BreakpointTestData( - 'printEnclosingFunctionMultiLine', - 'printNestedObjectsMultiLine', - mainScript, - ), - BreakpointTestData( - 'callPrintEnclosingFunctionMultiLine', - '', - mainScript, - ), - ]; - await onBreakPoint( - breakpoints[0], - () => testCallStack(breakpoints), - ); - }); - - test('expression evaluation succeeds on parent frame', () async { - // Expected breakpoints on the stack - final breakpoints = [ - BreakpointTestData( - 'testLibraryClassConstructor', - 'new', - testLibraryScript, - ), - BreakpointTestData( - 'createLibraryObject', - 'printFieldFromLibraryClass', - mainScript, - ), - BreakpointTestData( - 'callPrintFieldFromLibraryClass', - '', - mainScript, - ), - ]; - await onBreakPoint( - breakpoints[0], - () => testCallStack(breakpoints, frameIndex: 2), - ); - }); - - test('breakpoint inside a line gives correct callstack', () async { - // Expected breakpoints on the stack - final breakpoints = [ - BreakpointTestData( - 'newEnclosedClass', - 'new', - mainScript, - ), - BreakpointTestData( - 'printNestedObjectMultiLine', - 'printNestedObjectsMultiLine', - mainScript, - ), - BreakpointTestData( - 'callPrintEnclosingFunctionMultiLine', - '', - mainScript, - ), - ]; - await onBreakPoint( - breakpoints[0], - () => testCallStack(breakpoints), - ); - }); - - test('breakpoint gives correct callstack after step out', () async { - // Expected breakpoints on the stack - final breakpoints = [ - BreakpointTestData( - 'newEnclosedClass', - 'new', - mainScript, - ), - BreakpointTestData( - 'printEnclosingObjectMultiLine', - 'printNestedObjectsMultiLine', - mainScript, - ), - BreakpointTestData( - 'callPrintEnclosingFunctionMultiLine', - '', - mainScript, - ), - ]; - await onBreakPoint(breakpoints[0], () async { - await service.resume(isolateId, step: 'Out'); - await stream.firstWhere( - (Event event) => event.kind == EventKind.kPauseInterrupted, - ); - return testCallStack([breakpoints[1], breakpoints[2]]); - }); - }); - - test('breakpoint gives correct callstack after step in', () async { - // Expected breakpoints on the stack - final breakpoints = [ - BreakpointTestData( - 'newEnclosedClass', - 'new', - mainScript, - ), - BreakpointTestData( - 'printNestedObjectMultiLine', - 'printNestedObjectsMultiLine', - mainScript, - ), - BreakpointTestData( - 'callPrintEnclosingFunctionMultiLine', - '', - mainScript, - ), - ]; - await onBreakPoint(breakpoints[1], () async { - await service.resume(isolateId, step: 'Into'); - await stream.firstWhere( - (Event event) => event.kind == EventKind.kPauseInterrupted, - ); - return testCallStack(breakpoints); - }); - }); - - test('breakpoint gives correct callstack after step into chain calls', - () async { - // Expected breakpoints on the stack - final breakpoints = [ - BreakpointTestData( - 'createObjectWithMethod', - 'createObject', - mainScript, - ), - BreakpointTestData( - // This is currently incorrect, should be printObjectMultiLine. - // See issue: https://github.com/dart-lang/sdk/issues/48874 - 'printMultiLine', - 'printObjectMultiLine', - mainScript, - ), - BreakpointTestData( - 'callPrintObjectMultiLine', - '', - mainScript, - ), - ]; - final bp = BreakpointTestData( - 'printMultiLine', - 'printObjectMultiLine', - mainScript, - ); - await onBreakPoint(bp, () async { - await service.resume(isolateId, step: 'Into'); - await stream.firstWhere( - (Event event) => event.kind == EventKind.kPauseInterrupted, - ); - return testCallStack(breakpoints); - }); - }); + test('breakpoint gives correct callstack after step into chain calls', + () async { + // Expected breakpoints on the stack + final breakpoints = [ + BreakpointTestData( + 'createObjectWithMethod', + 'createObject', + mainScript, + ), + BreakpointTestData( + // This is currently incorrect, should be printObjectMultiLine. + // See issue: https://github.com/dart-lang/sdk/issues/48874 + 'printMultiLine', + 'printObjectMultiLine', + mainScript, + ), + BreakpointTestData( + 'callPrintObjectMultiLine', + '', + mainScript, + ), + ]; + final bp = BreakpointTestData( + 'printMultiLine', + 'printObjectMultiLine', + mainScript, + ); + await onBreakPoint(bp, () async { + await service.resume(isolateId, step: 'Into'); + await stream.firstWhere( + (Event event) => event.kind == EventKind.kPauseInterrupted, + ); + return testCallStack(breakpoints); }); }); - } + }); }); } diff --git a/dwds/test/frontend_server_circular_evaluate_test.dart b/dwds/test/frontend_server_circular_evaluate_test.dart index 71eb67c6b..2795a627c 100644 --- a/dwds/test/frontend_server_circular_evaluate_test.dart +++ b/dwds/test/frontend_server_circular_evaluate_test.dart @@ -22,27 +22,22 @@ void main() async { tearDownAll(provider.dispose); group('Context with circular dependencies |', () { - for (var nullSafety in NullSafety.values) { - group('${nullSafety.name} null safety |', () { - for (var indexBaseMode in IndexBaseMode.values) { - group( - 'with ${indexBaseMode.name} |', - () { - testAll( - provider: provider, - compilationMode: CompilationMode.frontendServer, - indexBaseMode: indexBaseMode, - nullSafety: nullSafety, - useDebuggerModuleNames: true, - debug: debug, - ); - }, - skip: - // https://github.com/dart-lang/sdk/issues/49277 - indexBaseMode == IndexBaseMode.base && Platform.isWindows, + for (var indexBaseMode in IndexBaseMode.values) { + group( + 'with ${indexBaseMode.name} |', + () { + testAll( + provider: provider, + compilationMode: CompilationMode.frontendServer, + indexBaseMode: indexBaseMode, + useDebuggerModuleNames: true, + debug: debug, ); - } - }); + }, + skip: + // https://github.com/dart-lang/sdk/issues/49277 + indexBaseMode == IndexBaseMode.base && Platform.isWindows, + ); } }); } diff --git a/dwds/test/frontend_server_ddc_evaluate_sound_test.dart b/dwds/test/frontend_server_ddc_evaluate_test.dart similarity index 90% rename from dwds/test/frontend_server_ddc_evaluate_sound_test.dart rename to dwds/test/frontend_server_ddc_evaluate_test.dart index 8506896e4..04077d0f5 100644 --- a/dwds/test/frontend_server_ddc_evaluate_sound_test.dart +++ b/dwds/test/frontend_server_ddc_evaluate_test.dart @@ -28,8 +28,7 @@ void main() async { for (var useDebuggerModuleNames in [false, true]) { group('Debugger module names: $useDebuggerModuleNames |', () { - final nullSafety = NullSafety.sound; - group('${nullSafety.name} null safety | DDC module system |', () { + group('DDC module system |', () { for (var indexBaseMode in IndexBaseMode.values) { group( 'with ${indexBaseMode.name} |', @@ -38,7 +37,6 @@ void main() async { provider: provider, compilationMode: CompilationMode.frontendServer, indexBaseMode: indexBaseMode, - nullSafety: nullSafety, useDebuggerModuleNames: useDebuggerModuleNames, debug: debug, ); diff --git a/dwds/test/frontend_server_evaluate_sound_test.dart b/dwds/test/frontend_server_evaluate_sound_test.dart deleted file mode 100644 index 753438833..000000000 --- a/dwds/test/frontend_server_evaluate_sound_test.dart +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file -// 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. - -@Tags(['daily']) -@TestOn('vm') -@Timeout(Duration(minutes: 5)) - -import 'dart:io'; - -import 'package:test/test.dart'; -import 'package:test_common/test_sdk_configuration.dart'; - -import 'evaluate_common.dart'; -import 'fixtures/context.dart'; -import 'fixtures/project.dart'; - -void main() async { - // Enable verbose logging for debugging. - final debug = false; - - final provider = TestSdkConfigurationProvider(verbose: debug); - tearDownAll(provider.dispose); - - for (var useDebuggerModuleNames in [false, true]) { - group('Debugger module names: $useDebuggerModuleNames |', () { - final nullSafety = NullSafety.sound; - group('${nullSafety.name} null safety |', () { - for (var indexBaseMode in IndexBaseMode.values) { - group( - 'with ${indexBaseMode.name} |', - () { - testAll( - provider: provider, - compilationMode: CompilationMode.frontendServer, - indexBaseMode: indexBaseMode, - nullSafety: nullSafety, - useDebuggerModuleNames: useDebuggerModuleNames, - debug: debug, - ); - }, - // https://github.com/dart-lang/sdk/issues/49277 - skip: indexBaseMode == IndexBaseMode.base && Platform.isWindows, - ); - } - }); - }); - } -} diff --git a/dwds/test/frontend_server_evaluate_weak_test.dart b/dwds/test/frontend_server_evaluate_test.dart similarity index 52% rename from dwds/test/frontend_server_evaluate_weak_test.dart rename to dwds/test/frontend_server_evaluate_test.dart index 43b7b2904..ed46b0a5f 100644 --- a/dwds/test/frontend_server_evaluate_weak_test.dart +++ b/dwds/test/frontend_server_evaluate_test.dart @@ -24,26 +24,22 @@ void main() async { for (var useDebuggerModuleNames in [false, true]) { group('Debugger module names: $useDebuggerModuleNames |', () { - final nullSafety = NullSafety.weak; - group('${nullSafety.name} null safety |', () { - for (var indexBaseMode in IndexBaseMode.values) { - group( - 'with ${indexBaseMode.name} |', - () { - testAll( - provider: provider, - compilationMode: CompilationMode.frontendServer, - indexBaseMode: indexBaseMode, - nullSafety: nullSafety, - useDebuggerModuleNames: useDebuggerModuleNames, - debug: debug, - ); - }, - // https://github.com/dart-lang/sdk/issues/49277 - skip: indexBaseMode == IndexBaseMode.base && Platform.isWindows, - ); - } - }); + for (var indexBaseMode in IndexBaseMode.values) { + group( + 'with ${indexBaseMode.name} |', + () { + testAll( + provider: provider, + compilationMode: CompilationMode.frontendServer, + indexBaseMode: indexBaseMode, + useDebuggerModuleNames: useDebuggerModuleNames, + debug: debug, + ); + }, + // https://github.com/dart-lang/sdk/issues/49277 + skip: indexBaseMode == IndexBaseMode.base && Platform.isWindows, + ); + } }); } } diff --git a/dwds/test/instances/common/instance_inspection_common.dart b/dwds/test/instances/common/instance_inspection_common.dart index 312c6a5b6..9de2072f5 100644 --- a/dwds/test/instances/common/instance_inspection_common.dart +++ b/dwds/test/instances/common/instance_inspection_common.dart @@ -16,12 +16,9 @@ void runTests({ required TestSdkConfigurationProvider provider, required CompilationMode compilationMode, required bool canaryFeatures, - required NullSafety nullSafetyMode, required bool debug, }) { - final project = nullSafetyMode == NullSafety.sound - ? TestProject.testPackageWithSoundNullSafety() - : TestProject.testPackageWithWeakNullSafety(); + final project = TestProject.testPackageWithSoundNullSafety(); final context = TestContext(project, provider); late VmService service; @@ -50,295 +47,293 @@ void runTests({ getFields(instanceRef, {offset, count}) => testInspector .getFields(isolateId, instanceRef, offset: offset, count: count); - group('$nullSafetyMode |', () { - group('$compilationMode |', () { - setUpAll(() async { - setCurrentLogWriter(debug: debug); - await context.setUp( - testSettings: TestSettings( - compilationMode: compilationMode, - enableExpressionEvaluation: true, - verboseCompiler: debug, - canaryFeatures: canaryFeatures, - experiments: ['records'], - ), - ); - service = context.debugConnection.vmService; + group('$compilationMode |', () { + setUpAll(() async { + setCurrentLogWriter(debug: debug); + await context.setUp( + testSettings: TestSettings( + compilationMode: compilationMode, + enableExpressionEvaluation: true, + verboseCompiler: debug, + canaryFeatures: canaryFeatures, + experiments: ['records'], + ), + ); + service = context.debugConnection.vmService; + + final vm = await service.getVM(); + isolateId = vm.isolates!.first.id!; + final scripts = await service.getScripts(isolateId); + + await service.streamListen('Debug'); + stream = service.onEvent('Debug'); + + mainScript = scripts.scripts! + .firstWhere((each) => each.uri!.contains('main.dart')); + }); - final vm = await service.getVM(); - isolateId = vm.isolates!.first.id!; - final scripts = await service.getScripts(isolateId); + tearDownAll(context.tearDown); - await service.streamListen('Debug'); - stream = service.onEvent('Debug'); + setUp(() => setCurrentLogWriter(debug: debug)); + tearDown(() async { + try { + await service.resume(isolateId); + } catch (_) {} + }); - mainScript = scripts.scripts! - .firstWhere((each) => each.uri!.contains('main.dart')); + group('Library |', () { + test('classes', () async { + const libraryId = 'org-dartlang-app:///web/main.dart'; + final library = await getObject(libraryId); + + expect( + library, + isA().having( + (l) => l.classes, + 'classes', + [ + matchClassRef(name: 'MainClass', libraryId: libraryId), + matchClassRef(name: 'EnclosedClass', libraryId: libraryId), + matchClassRef(name: 'ClassWithMethod', libraryId: libraryId), + matchClassRef(name: 'EnclosingClass', libraryId: libraryId), + ], + ), + ); }); + }); - tearDownAll(context.tearDown); + group('Class |', () { + test('name and library', () async { + const libraryId = 'org-dartlang-app:///web/main.dart'; + const className = 'MainClass'; + final cls = await getObject('classes|$libraryId|$className'); - setUp(() => setCurrentLogWriter(debug: debug)); - tearDown(() async { - try { - await service.resume(isolateId); - } catch (_) {} + expect(cls, matchClass(name: className, libraryId: libraryId)); }); + }); - group('Library |', () { - test('classes', () async { - const libraryId = 'org-dartlang-app:///web/main.dart'; - final library = await getObject(libraryId); - - expect( - library, - isA().having( - (l) => l.classes, - 'classes', - [ - matchClassRef(name: 'MainClass', libraryId: libraryId), - matchClassRef(name: 'EnclosedClass', libraryId: libraryId), - matchClassRef(name: 'ClassWithMethod', libraryId: libraryId), - matchClassRef(name: 'EnclosingClass', libraryId: libraryId), - ], + group('Object |', () { + test('type and fields', () async { + await onBreakPoint('printFieldMain', (event) async { + final frame = event.topFrame!.index!; + final instanceRef = await getInstanceRef(frame, 'instance'); + + final instanceId = instanceRef.id!; + expect( + await getObject(instanceId), + matchPlainInstance( + libraryId: 'org-dartlang-app:///web/main.dart', + type: 'MainClass', ), ); + + expect(await getFields(instanceRef), {'_field': 1, 'field': 2}); + + // Offsets and counts are ignored for plain object fields. + + // DevTools calls [VmServiceInterface.getObject] with offset=0 + // and count=0 and expects all fields to be returned. + expect( + await getFields(instanceRef, offset: 0, count: 0), + {'_field': 1, 'field': 2}, + ); + expect( + await getFields(instanceRef, offset: 0), + {'_field': 1, 'field': 2}, + ); + expect( + await getFields(instanceRef, offset: 0, count: 1), + {'_field': 1, 'field': 2}, + ); + expect( + await getFields(instanceRef, offset: 1), + {'_field': 1, 'field': 2}, + ); + expect( + await getFields(instanceRef, offset: 1, count: 0), + {'_field': 1, 'field': 2}, + ); + expect( + await getFields(instanceRef, offset: 1, count: 3), + {'_field': 1, 'field': 2}, + ); }); }); - group('Class |', () { - test('name and library', () async { - const libraryId = 'org-dartlang-app:///web/main.dart'; - const className = 'MainClass'; - final cls = await getObject('classes|$libraryId|$className'); + test('field access', () async { + await onBreakPoint('printFieldMain', (event) async { + final frame = event.topFrame!.index!; + expect( + await getInstance(frame, r'instance.field'), + matchPrimitiveInstance(kind: InstanceKind.kDouble, value: 2), + ); - expect(cls, matchClass(name: className, libraryId: libraryId)); + expect( + await getInstance(frame, r'instance._field'), + matchPrimitiveInstance(kind: InstanceKind.kDouble, value: 1), + ); }); }); + }); - group('Object |', () { - test('type and fields', () async { - await onBreakPoint('printFieldMain', (event) async { - final frame = event.topFrame!.index!; - final instanceRef = await getInstanceRef(frame, 'instance'); - - final instanceId = instanceRef.id!; - expect( - await getObject(instanceId), - matchPlainInstance( - libraryId: 'org-dartlang-app:///web/main.dart', - type: 'MainClass', - ), - ); - - expect(await getFields(instanceRef), {'_field': 1, 'field': 2}); - - // Offsets and counts are ignored for plain object fields. - - // DevTools calls [VmServiceInterface.getObject] with offset=0 - // and count=0 and expects all fields to be returned. - expect( - await getFields(instanceRef, offset: 0, count: 0), - {'_field': 1, 'field': 2}, - ); - expect( - await getFields(instanceRef, offset: 0), - {'_field': 1, 'field': 2}, - ); - expect( - await getFields(instanceRef, offset: 0, count: 1), - {'_field': 1, 'field': 2}, - ); - expect( - await getFields(instanceRef, offset: 1), - {'_field': 1, 'field': 2}, - ); - expect( - await getFields(instanceRef, offset: 1, count: 0), - {'_field': 1, 'field': 2}, - ); - expect( - await getFields(instanceRef, offset: 1, count: 3), - {'_field': 1, 'field': 2}, - ); - }); - }); + group('List |', () { + test('type and fields', () async { + await onBreakPoint('printList', (event) async { + final frame = event.topFrame!.index!; + final instanceRef = await getInstanceRef(frame, 'list'); + + final instanceId = instanceRef.id!; + expect(await getObject(instanceId), matchListInstance(type: 'int')); - test('field access', () async { - await onBreakPoint('printFieldMain', (event) async { - final frame = event.topFrame!.index!; - expect( - await getInstance(frame, r'instance.field'), - matchPrimitiveInstance(kind: InstanceKind.kDouble, value: 2), - ); - - expect( - await getInstance(frame, r'instance._field'), - matchPrimitiveInstance(kind: InstanceKind.kDouble, value: 1), - ); - }); + expect( + await getFields(instanceRef), + {0: 0.0, 1: 1.0, 2: 2.0}, + ); + expect(await getFields(instanceRef, offset: 1, count: 0), {}); + expect( + await getFields(instanceRef, offset: 0), + {0: 0.0, 1: 1.0, 2: 2.0}, + ); + expect( + await getFields(instanceRef, offset: 0, count: 1), + {0: 0.0}, + ); + expect( + await getFields(instanceRef, offset: 1), + {0: 1.0, 1: 2.0}, + ); + expect( + await getFields(instanceRef, offset: 1, count: 1), + {0: 1.0}, + ); + expect( + await getFields(instanceRef, offset: 1, count: 3), + {0: 1.0, 1: 2.0}, + ); + expect(await getFields(instanceRef, offset: 3, count: 3), {}); }); }); - group('List |', () { - test('type and fields', () async { - await onBreakPoint('printList', (event) async { - final frame = event.topFrame!.index!; - final instanceRef = await getInstanceRef(frame, 'list'); - - final instanceId = instanceRef.id!; - expect(await getObject(instanceId), matchListInstance(type: 'int')); - - expect( - await getFields(instanceRef), - {0: 0.0, 1: 1.0, 2: 2.0}, - ); - expect(await getFields(instanceRef, offset: 1, count: 0), {}); - expect( - await getFields(instanceRef, offset: 0), - {0: 0.0, 1: 1.0, 2: 2.0}, - ); - expect( - await getFields(instanceRef, offset: 0, count: 1), - {0: 0.0}, - ); - expect( - await getFields(instanceRef, offset: 1), - {0: 1.0, 1: 2.0}, - ); - expect( - await getFields(instanceRef, offset: 1, count: 1), - {0: 1.0}, - ); - expect( - await getFields(instanceRef, offset: 1, count: 3), - {0: 1.0, 1: 2.0}, - ); - expect(await getFields(instanceRef, offset: 3, count: 3), {}); - }); - }); + test('Element access', () async { + await onBreakPoint('printList', (event) async { + final frame = event.topFrame!.index!; + expect( + await getInstance(frame, r'list[0]'), + matchPrimitiveInstance(kind: InstanceKind.kDouble, value: 0), + ); + + expect( + await getInstance(frame, r"list[1]"), + matchPrimitiveInstance(kind: InstanceKind.kDouble, value: 1), + ); - test('Element access', () async { - await onBreakPoint('printList', (event) async { - final frame = event.topFrame!.index!; - expect( - await getInstance(frame, r'list[0]'), - matchPrimitiveInstance(kind: InstanceKind.kDouble, value: 0), - ); - - expect( - await getInstance(frame, r"list[1]"), - matchPrimitiveInstance(kind: InstanceKind.kDouble, value: 1), - ); - - expect( - await getInstance(frame, r"list[2]"), - matchPrimitiveInstance(kind: InstanceKind.kDouble, value: 2), - ); - }); + expect( + await getInstance(frame, r"list[2]"), + matchPrimitiveInstance(kind: InstanceKind.kDouble, value: 2), + ); }); }); + }); + + group('Map |', () { + test('type and fields', () async { + await onBreakPoint('printMap', (event) async { + final frame = event.topFrame!.index!; + final instanceRef = await getInstanceRef(frame, 'map'); + + final instanceId = instanceRef.id!; + expect( + await getObject(instanceId), + matchMapInstance(type: 'IdentityMap'), + ); + + expect(await getFields(instanceRef), {'a': 1, 'b': 2, 'c': 3}); - group('Map |', () { - test('type and fields', () async { - await onBreakPoint('printMap', (event) async { - final frame = event.topFrame!.index!; - final instanceRef = await getInstanceRef(frame, 'map'); - - final instanceId = instanceRef.id!; - expect( - await getObject(instanceId), - matchMapInstance(type: 'IdentityMap'), - ); - - expect(await getFields(instanceRef), {'a': 1, 'b': 2, 'c': 3}); - - expect(await getFields(instanceRef, offset: 1, count: 0), {}); - expect( - await getFields(instanceRef, offset: 0), - {'a': 1, 'b': 2, 'c': 3}, - ); - expect(await getFields(instanceRef, offset: 0, count: 1), {'a': 1}); - expect(await getFields(instanceRef, offset: 1), {'b': 2, 'c': 3}); - expect(await getFields(instanceRef, offset: 1, count: 1), {'b': 2}); - expect( - await getFields(instanceRef, offset: 1, count: 3), - {'b': 2, 'c': 3}, - ); - expect(await getFields(instanceRef, offset: 3, count: 3), {}); - }); + expect(await getFields(instanceRef, offset: 1, count: 0), {}); + expect( + await getFields(instanceRef, offset: 0), + {'a': 1, 'b': 2, 'c': 3}, + ); + expect(await getFields(instanceRef, offset: 0, count: 1), {'a': 1}); + expect(await getFields(instanceRef, offset: 1), {'b': 2, 'c': 3}); + expect(await getFields(instanceRef, offset: 1, count: 1), {'b': 2}); + expect( + await getFields(instanceRef, offset: 1, count: 3), + {'b': 2, 'c': 3}, + ); + expect(await getFields(instanceRef, offset: 3, count: 3), {}); }); + }); + + test('Element access', () async { + await onBreakPoint('printMap', (event) async { + final frame = event.topFrame!.index!; + expect( + await getInstance(frame, r"map['a']"), + matchPrimitiveInstance(kind: InstanceKind.kDouble, value: 1), + ); - test('Element access', () async { - await onBreakPoint('printMap', (event) async { - final frame = event.topFrame!.index!; - expect( - await getInstance(frame, r"map['a']"), - matchPrimitiveInstance(kind: InstanceKind.kDouble, value: 1), - ); - - expect( - await getInstance(frame, r"map['b']"), - matchPrimitiveInstance(kind: InstanceKind.kDouble, value: 2), - ); - - expect( - await getInstance(frame, r"map['c']"), - matchPrimitiveInstance(kind: InstanceKind.kDouble, value: 3), - ); - }); + expect( + await getInstance(frame, r"map['b']"), + matchPrimitiveInstance(kind: InstanceKind.kDouble, value: 2), + ); + + expect( + await getInstance(frame, r"map['c']"), + matchPrimitiveInstance(kind: InstanceKind.kDouble, value: 3), + ); }); }); + }); + + group('Set |', () { + test('type and fields', () async { + await onBreakPoint('printSet', (event) async { + final frame = event.topFrame!.index!; + final instanceRef = await getInstanceRef(frame, 'mySet'); + + final instanceId = instanceRef.id!; + expect( + await getObject(instanceId), + matchSetInstance(type: '_HashSet'), + ); - group('Set |', () { - test('type and fields', () async { - await onBreakPoint('printSet', (event) async { - final frame = event.topFrame!.index!; - final instanceRef = await getInstanceRef(frame, 'mySet'); - - final instanceId = instanceRef.id!; - expect( - await getObject(instanceId), - matchSetInstance(type: '_HashSet'), - ); - - expect( - await getFields(instanceRef), - {0: 1.0, 1: 4.0, 2: 5.0, 3: 7.0}, - ); - expect( - await getFields(instanceRef, offset: 0), - {0: 1.0, 1: 4.0, 2: 5.0, 3: 7.0}, - ); - expect( - await getFields(instanceRef, offset: 1, count: 2), - {0: 4.0, 1: 5.0}, - ); - expect( - await getFields(instanceRef, offset: 2), - {0: 5.0, 1: 7.0}, - ); - expect( - await getFields(instanceRef, offset: 2, count: 10), - {0: 5.0, 1: 7.0}, - ); - expect(await getFields(instanceRef, offset: 1, count: 0), {}); - expect(await getFields(instanceRef, offset: 10, count: 2), {}); - }); + expect( + await getFields(instanceRef), + {0: 1.0, 1: 4.0, 2: 5.0, 3: 7.0}, + ); + expect( + await getFields(instanceRef, offset: 0), + {0: 1.0, 1: 4.0, 2: 5.0, 3: 7.0}, + ); + expect( + await getFields(instanceRef, offset: 1, count: 2), + {0: 4.0, 1: 5.0}, + ); + expect( + await getFields(instanceRef, offset: 2), + {0: 5.0, 1: 7.0}, + ); + expect( + await getFields(instanceRef, offset: 2, count: 10), + {0: 5.0, 1: 7.0}, + ); + expect(await getFields(instanceRef, offset: 1, count: 0), {}); + expect(await getFields(instanceRef, offset: 10, count: 2), {}); }); + }); - test('Element access', () async { - await onBreakPoint('printSet', (event) async { - final frame = event.topFrame!.index!; - expect( - await getInstance(frame, r"mySet.first"), - matchPrimitiveInstance(kind: InstanceKind.kDouble, value: 1), - ); - expect( - await getInstance(frame, r"mySet.last"), - matchPrimitiveInstance(kind: InstanceKind.kDouble, value: 7), - ); - }); + test('Element access', () async { + await onBreakPoint('printSet', (event) async { + final frame = event.topFrame!.index!; + expect( + await getInstance(frame, r"mySet.first"), + matchPrimitiveInstance(kind: InstanceKind.kDouble, value: 1), + ); + expect( + await getInstance(frame, r"mySet.last"), + matchPrimitiveInstance(kind: InstanceKind.kDouble, value: 7), + ); }); }); }); diff --git a/dwds/test/instances/instance_inspection_canary_test.dart b/dwds/test/instances/instance_inspection_canary_test.dart index 704e19b28..68e4028be 100644 --- a/dwds/test/instances/instance_inspection_canary_test.dart +++ b/dwds/test/instances/instance_inspection_canary_test.dart @@ -10,7 +10,6 @@ import 'package:test/test.dart'; import 'package:test_common/test_sdk_configuration.dart'; import '../fixtures/context.dart'; -import '../fixtures/project.dart'; import 'common/instance_inspection_common.dart'; void main() { @@ -29,10 +28,6 @@ void main() { runTests( provider: provider, compilationMode: compilationMode, - // Note: not running with weak null safety because it - // requires a special branch of build_web_compilers - // that does not support --canary flag. - nullSafetyMode: NullSafety.sound, canaryFeatures: canaryFeatures, debug: debug, ); diff --git a/dwds/test/instances/instance_inspection_test.dart b/dwds/test/instances/instance_inspection_test.dart index 53c5b4022..3c879b9bf 100644 --- a/dwds/test/instances/instance_inspection_test.dart +++ b/dwds/test/instances/instance_inspection_test.dart @@ -10,7 +10,6 @@ import 'package:test/test.dart'; import 'package:test_common/test_sdk_configuration.dart'; import '../fixtures/context.dart'; -import '../fixtures/project.dart'; import 'common/instance_inspection_common.dart'; void main() { @@ -26,15 +25,12 @@ void main() { tearDownAll(provider.dispose); for (var compilationMode in CompilationMode.values) { - for (var nullSafetyMode in NullSafety.values) { - runTests( - provider: provider, - compilationMode: compilationMode, - nullSafetyMode: nullSafetyMode, - canaryFeatures: canaryFeatures, - debug: debug, - ); - } + runTests( + provider: provider, + compilationMode: compilationMode, + canaryFeatures: canaryFeatures, + debug: debug, + ); } }); }