Unverified Commit c78ccb0b authored by Paul Berry's avatar Paul Berry Committed by GitHub

Cause `flutter analyze` to fail if the analysis server experienced an error. (#29126)

Substantially reduces the danger that a bug in the analysis server
might prevent errors from being detected by `flutter analyze`.
parent e1005143
...@@ -67,6 +67,9 @@ class AnalyzeContinuously extends AnalyzeBase { ...@@ -67,6 +67,9 @@ class AnalyzeContinuously extends AnalyzeBase {
if (exitCode != 0) if (exitCode != 0)
throwToolExit(message, exitCode: exitCode); throwToolExit(message, exitCode: exitCode);
printStatus(message); printStatus(message);
if (server.didServerErrorOccur)
throwToolExit('Server error(s) occurred.');
} }
void _handleAnalysisStatus(AnalysisServer server, bool isAnalyzing) { void _handleAnalysisStatus(AnalysisServer server, bool isAnalyzing) {
......
...@@ -155,6 +155,10 @@ class AnalyzeOnce extends AnalyzeBase { ...@@ -155,6 +155,10 @@ class AnalyzeOnce extends AnalyzeBase {
} }
} }
if (server.didServerErrorOccur) {
throwToolExit('Server error(s) occurred. (ran in ${seconds}s)');
}
if (argResults['congratulate']) { if (argResults['congratulate']) {
if (undocumentedMembers > 0) { if (undocumentedMembers > 0) {
printStatus('No issues found! (ran in ${seconds}s; $dartdocMessage)'); printStatus('No issues found! (ran in ${seconds}s; $dartdocMessage)');
......
...@@ -27,6 +27,7 @@ class AnalysisServer { ...@@ -27,6 +27,7 @@ class AnalysisServer {
StreamController<bool>.broadcast(); StreamController<bool>.broadcast();
final StreamController<FileAnalysisErrors> _errorsController = final StreamController<FileAnalysisErrors> _errorsController =
StreamController<FileAnalysisErrors>.broadcast(); StreamController<FileAnalysisErrors>.broadcast();
bool _didServerErrorOccur = false;
int _id = 0; int _id = 0;
...@@ -61,6 +62,7 @@ class AnalysisServer { ...@@ -61,6 +62,7 @@ class AnalysisServer {
<String, dynamic>{'included': directories, 'excluded': <String>[]}); <String, dynamic>{'included': directories, 'excluded': <String>[]});
} }
bool get didServerErrorOccur => _didServerErrorOccur;
Stream<bool> get onAnalyzing => _analyzingController.stream; Stream<bool> get onAnalyzing => _analyzingController.stream;
Stream<FileAnalysisErrors> get onErrors => _errorsController.stream; Stream<FileAnalysisErrors> get onErrors => _errorsController.stream;
...@@ -120,6 +122,7 @@ class AnalysisServer { ...@@ -120,6 +122,7 @@ class AnalysisServer {
if (error['stackTrace'] != null) { if (error['stackTrace'] != null) {
printError(error['stackTrace']); printError(error['stackTrace']);
} }
_didServerErrorOccur = true;
} }
void _handleAnalysisIssues(Map<String, dynamic> issueInfo) { void _handleAnalysisIssues(Map<String, dynamic> issueInfo) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment