mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Deflake flutter tool logger test (#43800)
This commit is contained in:
parent
e0094eee52
commit
417449e2f3
@ -359,12 +359,12 @@ class BufferLogger extends Logger {
|
||||
|
||||
class VerboseLogger extends Logger {
|
||||
VerboseLogger(this.parent) : assert(terminal != null) {
|
||||
stopwatch.start();
|
||||
_stopwatch.start();
|
||||
}
|
||||
|
||||
final Logger parent;
|
||||
|
||||
Stopwatch stopwatch = Stopwatch();
|
||||
final Stopwatch _stopwatch = context.get<Stopwatch>() ?? Stopwatch();
|
||||
|
||||
@override
|
||||
bool get isVerbose => true;
|
||||
@ -438,8 +438,8 @@ class VerboseLogger extends Logger {
|
||||
return;
|
||||
}
|
||||
|
||||
final int millis = stopwatch.elapsedMilliseconds;
|
||||
stopwatch.reset();
|
||||
final int millis = _stopwatch.elapsedMilliseconds;
|
||||
_stopwatch.reset();
|
||||
|
||||
String prefix;
|
||||
const int prefixWidth = 8;
|
||||
|
@ -24,6 +24,11 @@ void main() {
|
||||
final String resetColor = RegExp.escape(AnsiTerminal.resetColor);
|
||||
|
||||
group('AppContext', () {
|
||||
FakeStopwatch fakeStopWatch;
|
||||
|
||||
setUp(() {
|
||||
fakeStopWatch = FakeStopwatch();
|
||||
});
|
||||
testUsingContext('error', () async {
|
||||
final BufferLogger mockLogger = BufferLogger();
|
||||
final VerboseLogger verboseLogger = VerboseLogger(mockLogger);
|
||||
@ -39,6 +44,7 @@ void main() {
|
||||
}, overrides: <Type, Generator>{
|
||||
OutputPreferences: () => OutputPreferences(showColor: false),
|
||||
Platform: _kNoAnsiPlatform,
|
||||
Stopwatch: () => fakeStopWatch,
|
||||
});
|
||||
|
||||
testUsingContext('ANSI colored errors', () async {
|
||||
@ -60,6 +66,7 @@ void main() {
|
||||
}, overrides: <Type, Generator>{
|
||||
OutputPreferences: () => OutputPreferences(showColor: true),
|
||||
Platform: () => FakePlatform()..stdoutSupportsAnsi = true,
|
||||
Stopwatch: () => fakeStopWatch,
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user