Report an error if compilation during testing times out. (#15745)

* Report an error if compilation times out instead of waiting forever.

* Remove braces
This commit is contained in:
Vyacheslav Egorov 2018-03-20 19:30:06 +01:00 committed by Alexander Aprelev
parent 821c9b35a1
commit 3352a3fb48

View File

@ -144,10 +144,10 @@ class _Compiler {
printTrace('Compiling ${request.path}');
compiler ??= createCompiler();
suppressOutput = false;
final String outputPath = await compiler.recompile(request.path,
final String outputPath = await handleTimeout(compiler.recompile(request.path,
<String>[request.path],
outputPath: outputDill.path,
);
), request.path);
// Check if the compiler produced the output. If it failed then
// outputPath would be null. In this case pass null upwards to the
@ -180,13 +180,20 @@ class _Compiler {
Future<String> compile(String mainDart) {
final Completer<String> completer = new Completer<String>();
compilerController.add(new _CompilationRequest(mainDart, completer));
return completer.future;
return handleTimeout(completer.future, mainDart);
}
Future<dynamic> shutdown() async {
await compiler.shutdown();
compiler = null;
}
static Future<String> handleTimeout(Future<String> value, String path) {
return value.timeout(const Duration(minutes: 5), onTimeout: () {
printError('Compilation of $path timed out after 5 minutes.');
return null;
});
}
}
class _FlutterPlatform extends PlatformPlugin {