restore compileExpressionService (#24063)
diff --git a/packages/flutter_tools/lib/src/test/flutter_platform.dart b/packages/flutter_tools/lib/src/test/flutter_platform.dart
index 26a4b35..4230329 100644
--- a/packages/flutter_tools/lib/src/test/flutter_platform.dart
+++ b/packages/flutter_tools/lib/src/test/flutter_platform.dart
@@ -28,6 +28,7 @@
import '../compile.dart';
import '../dart/package_map.dart';
import '../globals.dart';
+import '../vmservice.dart';
import 'watcher.dart';
/// The timeout we give the test process to connect to the test harness
@@ -450,6 +451,22 @@
return remoteChannel;
}
+ Future<String> _compileExpressionService(String isolateId, String expression,
+ List<String> definitions, List<String> typeDefinitions,
+ String libraryUri, String klass, bool isStatic,
+ ) async {
+ if (compiler == null || compiler.compiler == null) {
+ throw 'Compiler is not set up properly to compile $expression';
+ }
+ final CompilerOutput compilerOutput =
+ await compiler.compiler.compileExpression(expression, definitions,
+ typeDefinitions, libraryUri, klass, isStatic);
+ if (compilerOutput != null && compilerOutput.outputFilename != null) {
+ return base64.encode(fs.file(compilerOutput.outputFilename).readAsBytesSync());
+ }
+ throw 'Failed to compile $expression';
+ }
+
Future<_AsyncError> _startTest(
String testPath,
StreamChannel<dynamic> controller,
@@ -573,6 +590,14 @@
printTrace('test $ourTestCount: using observatory uri $detectedUri from pid ${process.pid}');
}
processObservatoryUri = detectedUri;
+ {
+ printTrace('Connecting to service protocol: $processObservatoryUri');
+ final Future<VMService> localVmService = VMService.connect(processObservatoryUri,
+ compileExpression: _compileExpressionService);
+ localVmService.then((VMService vmservice) {
+ printTrace('Successfully connected to service protocol: $processObservatoryUri');
+ });
+ }
gotProcessObservatoryUri.complete();
watcher?.handleStartedProcess(
ProcessEvent(ourTestCount, process, processObservatoryUri));