From 860730a2aa95ec36ed61819f2d4bb9655544eec7 Mon Sep 17 00:00:00 2001 From: Anna Gringauze Date: Thu, 28 Sep 2023 09:52:57 -0700 Subject: [PATCH 1/2] Add test to catch latest type table failure in DDC --- webdev/test/e2e_test.dart | 64 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/webdev/test/e2e_test.dart b/webdev/test/e2e_test.dart index 6c6d09248..31db03e3b 100644 --- a/webdev/test/e2e_test.dart +++ b/webdev/test/e2e_test.dart @@ -368,6 +368,10 @@ void main() { var process = await testRunner.runWebDev(args, workingDirectory: soundNullSafety ? soundExampleDirectory : exampleDirectory); + + process.stdoutStream().listen(Logger.root.fine); + process.stderrStream().listen(Logger.root.warning); + VmService? vmService; try { @@ -412,6 +416,66 @@ void main() { await process.shouldExit(); } }, timeout: const Timeout.factor(2)); + + test('evaluate in a batch', () async { + var openPort = await findUnusedPort(); + // running daemon command that starts dwds without keyboard input + var args = [ + 'daemon', + 'web:$openPort', + '--enable-expression-evaluation', + '--verbose', + ]; + var process = await testRunner.runWebDev(args, + workingDirectory: + soundNullSafety ? soundExampleDirectory : exampleDirectory); + + process.stdoutStream().listen(Logger.root.fine); + process.stderrStream().listen(Logger.root.warning); + + VmService? vmService; + + try { + // Wait for debug service Uri + String? wsUri; + await expectLater(process.stdout, emitsThrough((message) { + wsUri = getDebugServiceUri(message as String); + return wsUri != null; + })); + expect(wsUri, isNotNull); + + vmService = await vmServiceConnectUri(wsUri!); + var vm = await vmService.getVM(); + var isolateId = vm.isolates!.first.id!; + var isolate = await vmService.getIsolate(isolateId); + var libraryId = isolate.rootLib!.id!; + + await vmService.streamListen('Debug'); + + final results = await Future.wait([ + vmService.evaluate(isolateId, libraryId, 'true'), + vmService.evaluate(isolateId, libraryId, 'false'), + ]); + + expect( + results[0], + const TypeMatcher().having( + (instance) => instance.valueAsString, + 'valueAsString', + 'true')); + + expect( + results[1], + const TypeMatcher().having( + (instance) => instance.valueAsString, + 'valueAsString', + 'false')); + } finally { + await vmService?.dispose(); + await exitWebdev(process); + await process.shouldExit(); + } + }, timeout: const Timeout.factor(2)); }); group('and --no-enable-expression-evaluation:', () { From 31f77dd0caca955a450072703e431aba1a53cf1b Mon Sep 17 00:00:00 2001 From: Anna Gringauze Date: Wed, 11 Oct 2023 16:24:47 -0700 Subject: [PATCH 2/2] Add tests that use debugger runtime API --- webdev/test/e2e_test.dart | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/webdev/test/e2e_test.dart b/webdev/test/e2e_test.dart index 31db03e3b..9a574010d 100644 --- a/webdev/test/e2e_test.dart +++ b/webdev/test/e2e_test.dart @@ -417,7 +417,7 @@ void main() { } }, timeout: const Timeout.factor(2)); - test('evaluate in a batch', () async { + test('evaluate and get objects', () async { var openPort = await findUnusedPort(); // running daemon command that starts dwds without keyboard input var args = [ @@ -452,24 +452,32 @@ void main() { await vmService.streamListen('Debug'); - final results = await Future.wait([ - vmService.evaluate(isolateId, libraryId, 'true'), - vmService.evaluate(isolateId, libraryId, 'false'), - ]); - + final result = await vmService.evaluate( + isolateId, libraryId, '[true, false]'); expect( - results[0], + result, const TypeMatcher().having( - (instance) => instance.valueAsString, - 'valueAsString', - 'true')); + (instance) => instance.classRef?.name, + 'class name', + 'List')); + final instanceRef = result as InstanceRef; + final list = + await vmService.getObject(isolateId, instanceRef.id!); expect( - results[1], - const TypeMatcher().having( - (instance) => instance.valueAsString, - 'valueAsString', - 'false')); + list, + const TypeMatcher().having( + (instance) => instance.classRef?.name, + 'class name', + 'List')); + + final elements = (list as Instance).elements; + expect(elements, [ + const TypeMatcher().having( + (instance) => instance.valueAsString, 'value', 'true'), + const TypeMatcher().having( + (instance) => instance.valueAsString, 'value', 'false'), + ]); } finally { await vmService?.dispose(); await exitWebdev(process);