Catch version and option skew errors from build_daemon (#43403)

This commit is contained in:
Jonah Williams
2019-10-24 09:06:45 -07:00
committed by GitHub
parent 1dc0b94765
commit 9e7b6f9500
2 changed files with 52 additions and 0 deletions

View File

@@ -4,6 +4,7 @@
import 'dart:async';
import 'package:build_daemon/client.dart';
import 'package:meta/meta.dart';
import 'package:vm_service/vm_service.dart' as vmservice;
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart' hide StackTrace;
@@ -212,6 +213,18 @@ class ResidentWebRunner extends ResidentRunner {
);
});
return result;
} on VersionSkew {
// Thrown if an older build daemon is already running.
throwToolExit(
'Another build daemon is already running with an older version.\n'
'Try exiting other Flutter processes in this project and try again.'
);
} on OptionsSkew {
// Thrown if a build daemon is already running with different configuration.
throwToolExit(
'Another build daemon is already running with different configuration.\n'
'Try exiting other Flutter processes in this project and try again.'
);
} on WebSocketException {
throwToolExit('Failed to connect to WebSocket.');
} on BuildException {

View File

@@ -5,6 +5,7 @@
import 'dart:async';
import 'dart:convert';
import 'package:build_daemon/client.dart';
import 'package:dwds/dwds.dart';
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
@@ -583,6 +584,44 @@ void main() {
await expectation;
}));
test('Successfully turns OptionsSkew error into ToolExit', () => testbed.run(() async {
_setupMocks();
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
final Completer<void> unhandledErrorCompleter = Completer<void>();
when(mockWebFs.connect(any)).thenAnswer((Invocation _) async {
unawaited(unhandledErrorCompleter.future.then((void value) {
throw OptionsSkew();
}));
return ConnectionResult(mockAppConnection, mockDebugConnection);
});
final Future<void> expectation = expectLater(() => residentWebRunner.run(
connectionInfoCompleter: connectionInfoCompleter,
), throwsA(isInstanceOf<ToolExit>()));
unhandledErrorCompleter.complete();
await expectation;
}));
test('Successfully turns VersionSkew error into ToolExit', () => testbed.run(() async {
_setupMocks();
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
final Completer<void> unhandledErrorCompleter = Completer<void>();
when(mockWebFs.connect(any)).thenAnswer((Invocation _) async {
unawaited(unhandledErrorCompleter.future.then((void value) {
throw VersionSkew();
}));
return ConnectionResult(mockAppConnection, mockDebugConnection);
});
final Future<void> expectation = expectLater(() => residentWebRunner.run(
connectionInfoCompleter: connectionInfoCompleter,
), throwsA(isInstanceOf<ToolExit>()));
unhandledErrorCompleter.complete();
await expectation;
}));
test('Rethrows Exception type', () => testbed.run(() async {
_setupMocks();
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();