Added more extensive ANSI color printing support on terminals. (#20958)
This adds support to AnsiTerminal for colored output, and makes all tool output written to stderr (with the printError function) colored red. No color codes are sent if the terminal doesn't support color (or isn't a terminal). Also makes "progress" output print the elapsed time when not connected to a terminal, so that redirected output and terminal output match (redirected output doesn't print the spinner, however). Addresses #17307
This commit is contained in:
@@ -76,7 +76,7 @@ void testUsingContext(String description, dynamic testMethod(), {
|
||||
when(mock.getAttachedDevices()).thenReturn(<IOSSimulator>[]);
|
||||
return mock;
|
||||
},
|
||||
Logger: () => BufferLogger(),
|
||||
Logger: () => BufferLogger()..supportsColor = false,
|
||||
OperatingSystemUtils: () => MockOperatingSystemUtils(),
|
||||
SimControl: () => MockSimControl(),
|
||||
Usage: () => MockUsage(),
|
||||
|
||||
@@ -287,11 +287,15 @@ class MemoryIOSink implements IOSink {
|
||||
/// A Stdio that collects stdout and supports simulated stdin.
|
||||
class MockStdio extends Stdio {
|
||||
final MemoryIOSink _stdout = MemoryIOSink();
|
||||
final MemoryIOSink _stderr = MemoryIOSink();
|
||||
final StreamController<List<int>> _stdin = StreamController<List<int>>();
|
||||
|
||||
@override
|
||||
IOSink get stdout => _stdout;
|
||||
|
||||
@override
|
||||
IOSink get stderr => _stderr;
|
||||
|
||||
@override
|
||||
Stream<List<int>> get stdin => _stdin.stream;
|
||||
|
||||
@@ -300,6 +304,7 @@ class MockStdio extends Stdio {
|
||||
}
|
||||
|
||||
List<String> get writtenToStdout => _stdout.writes.map(_stdout.encoding.decode).toList();
|
||||
List<String> get writtenToStderr => _stderr.writes.map(_stderr.encoding.decode).toList();
|
||||
}
|
||||
|
||||
class MockPollingDeviceDiscovery extends PollingDeviceDiscovery {
|
||||
|
||||
Reference in New Issue
Block a user