[flutter_tools] warn when doctor takes long (#100805)
* warn when doctor takes long
This commit is contained in:
committed by
GitHub
parent
4ece077249
commit
9c138f9c76
@@ -631,7 +631,11 @@ class StreamLogger extends Logger {
|
||||
}
|
||||
|
||||
@override
|
||||
Status startSpinner({ VoidCallback onFinish }) {
|
||||
Status startSpinner({
|
||||
VoidCallback onFinish,
|
||||
Duration timeout,
|
||||
SlowWarningCallback slowWarningCallback,
|
||||
}) {
|
||||
return SilentStatus(
|
||||
stopwatch: Stopwatch(),
|
||||
onFinish: onFinish,
|
||||
|
||||
@@ -451,7 +451,7 @@ void main() {
|
||||
FakeAsync().run((FakeAsync time) {
|
||||
final AnonymousSpinnerStatus spinner = AnonymousSpinnerStatus(
|
||||
stdio: mockStdio,
|
||||
stopwatch: stopwatchFactory.createStopwatch(),
|
||||
stopwatch: mockStopwatch,
|
||||
terminal: terminal,
|
||||
)..start();
|
||||
doWhileAsync(time, () => spinner.ticks < 10);
|
||||
@@ -479,6 +479,35 @@ void main() {
|
||||
expect(done, isTrue);
|
||||
});
|
||||
|
||||
testWithoutContext('AnonymousSpinnerStatus logs warning after timeout', () async {
|
||||
mockStopwatch = FakeStopwatch();
|
||||
const String warningMessage = 'a warning message.';
|
||||
final bool done = FakeAsync().run<bool>((FakeAsync time) {
|
||||
final AnonymousSpinnerStatus spinner = AnonymousSpinnerStatus(
|
||||
stdio: mockStdio,
|
||||
stopwatch: mockStopwatch,
|
||||
terminal: terminal,
|
||||
slowWarningCallback: () => warningMessage,
|
||||
timeout: const Duration(milliseconds: 100),
|
||||
)..start();
|
||||
// must be greater than the spinner timer duration
|
||||
const Duration timeLapse = Duration(milliseconds: 101);
|
||||
mockStopwatch.elapsed += timeLapse;
|
||||
time.elapse(timeLapse);
|
||||
|
||||
List<String> lines = outputStdout();
|
||||
expect(
|
||||
lines.join(),
|
||||
contains(warningMessage),
|
||||
);
|
||||
|
||||
spinner.stop();
|
||||
lines = outputStdout();
|
||||
return true;
|
||||
});
|
||||
expect(done, isTrue);
|
||||
});
|
||||
|
||||
testWithoutContext('Stdout startProgress on colored terminal', () async {
|
||||
final Logger logger = StdoutLogger(
|
||||
terminal: coloredTerminal,
|
||||
|
||||
Reference in New Issue
Block a user