Avoid printing blank lines between "Another exception was thrown:" messages. (#119587)
This commit is contained in:
@@ -169,8 +169,9 @@ Future<void> run(List<String> arguments) async {
|
||||
|
||||
// Try with the --watch analyzer, to make sure it returns success also.
|
||||
// The --benchmark argument exits after one run.
|
||||
// We specify a failureMessage so that the actual output is muted in the case where _runFlutterAnalyze above already failed.
|
||||
printProgress('Dart analysis (with --watch)...');
|
||||
await _runFlutterAnalyze(flutterRoot, options: <String>[
|
||||
await _runFlutterAnalyze(flutterRoot, failureMessage: 'Dart analyzer failed when --watch was used.', options: <String>[
|
||||
'--flutter-repo',
|
||||
'--watch',
|
||||
'--benchmark',
|
||||
@@ -196,7 +197,7 @@ Future<void> run(List<String> arguments) async {
|
||||
],
|
||||
workingDirectory: flutterRoot,
|
||||
);
|
||||
await _runFlutterAnalyze(outDir.path, options: <String>[
|
||||
await _runFlutterAnalyze(outDir.path, failureMessage: 'Dart analyzer failed on mega_gallery benchmark.', options: <String>[
|
||||
'--watch',
|
||||
'--benchmark',
|
||||
...arguments,
|
||||
@@ -1942,11 +1943,13 @@ Diff at character #$indexOfDifference
|
||||
|
||||
Future<CommandResult> _runFlutterAnalyze(String workingDirectory, {
|
||||
List<String> options = const <String>[],
|
||||
String? failureMessage,
|
||||
}) async {
|
||||
return runCommand(
|
||||
flutter,
|
||||
<String>['analyze', ...options],
|
||||
workingDirectory: workingDirectory,
|
||||
failureMessage: failureMessage,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -190,13 +190,24 @@ Future<CommandResult> runCommand(String executable, List<String> arguments, {
|
||||
print(result.flattenedStderr);
|
||||
break;
|
||||
}
|
||||
String allOutput;
|
||||
if (failureMessage == null) {
|
||||
allOutput = '${result.flattenedStdout}\n${result.flattenedStderr}';
|
||||
if (allOutput.split('\n').length > 10) {
|
||||
allOutput = '(stdout/stderr output was more than 10 lines)';
|
||||
}
|
||||
} else {
|
||||
allOutput = '';
|
||||
}
|
||||
foundError(<String>[
|
||||
if (failureMessage != null)
|
||||
failureMessage
|
||||
else
|
||||
'$bold${red}Command exited with exit code ${result.exitCode} but expected: ${expectNonZeroExit ? (expectedExitCode ?? 'non-zero') : 'zero'} exit code.$reset',
|
||||
failureMessage,
|
||||
'${bold}Command: $green$commandDescription$reset',
|
||||
'${bold}Relative working directory: $cyan$relativeWorkingDir$reset',
|
||||
if (failureMessage == null)
|
||||
'$bold${red}Command exited with exit code ${result.exitCode} but expected ${expectNonZeroExit ? (expectedExitCode ?? 'non-zero') : 'zero'} exit code.$reset',
|
||||
'${bold}Working directory: $cyan${path.absolute(relativeWorkingDir)}$reset',
|
||||
if (allOutput.isNotEmpty)
|
||||
'${bold}stdout and stderr output:\n$allOutput',
|
||||
]);
|
||||
} else {
|
||||
print('ELAPSED TIME: ${prettyPrintDuration(result.elapsedTime)} for $green$commandDescription$reset in $cyan$relativeWorkingDir$reset');
|
||||
|
||||
@@ -82,8 +82,7 @@ VoidCallback? onError;
|
||||
bool get hasError => _hasError;
|
||||
bool _hasError = false;
|
||||
|
||||
Iterable<String> get errorMessages => _errorMessages;
|
||||
List<String> _errorMessages = <String>[];
|
||||
List<List<String>> _errorMessages = <List<String>>[];
|
||||
|
||||
final List<String> _pendingLogs = <String>[];
|
||||
Timer? _hideTimer; // When this is null, the output is verbose.
|
||||
@@ -104,7 +103,7 @@ void foundError(List<String> messages) {
|
||||
// another error.
|
||||
_pendingLogs.forEach(_printLoudly);
|
||||
_pendingLogs.clear();
|
||||
_errorMessages.addAll(messages);
|
||||
_errorMessages.add(messages);
|
||||
_hasError = true;
|
||||
if (onError != null) {
|
||||
onError!();
|
||||
@@ -124,8 +123,18 @@ Never reportErrorsAndExit() {
|
||||
_hideTimer?.cancel();
|
||||
_hideTimer = null;
|
||||
print(redLine);
|
||||
print('For your convenience, the error messages reported above are repeated here:');
|
||||
_errorMessages.forEach(print);
|
||||
print('${red}For your convenience, the error messages reported above are repeated here:$reset');
|
||||
final bool printSeparators = _errorMessages.any((List<String> messages) => messages.length > 1);
|
||||
if (printSeparators) {
|
||||
print(' 🙙 🙛 ');
|
||||
}
|
||||
for (int index = 0; index < _errorMessages.length * 2 - 1; index += 1) {
|
||||
if (index.isEven) {
|
||||
_errorMessages[index ~/ 2].forEach(print);
|
||||
} else if (printSeparators) {
|
||||
print(' 🙙 🙛 ');
|
||||
}
|
||||
}
|
||||
print(redLine);
|
||||
system.exit(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user