[flutter_tool] Refactor Logger and Terminal to (mostly) no longer depend directly on context (#47269)

This commit is contained in:
Jonah Williams
2020-01-08 12:35:12 -08:00
committed by GitHub
parent 0384c8c482
commit f7b8d62cbc
32 changed files with 733 additions and 367 deletions

View File

@@ -92,6 +92,7 @@ void testUsingContext(
return context.run<dynamic>(
name: 'mocks',
overrides: <Type, Generator>{
AnsiTerminal: () => AnsiTerminal(platform: globals.platform, stdio: globals.stdio),
Config: () => buildConfig(globals.fs),
DeviceManager: () => FakeDeviceManager(),
Doctor: () => FakeDoctor(),
@@ -103,7 +104,10 @@ void testUsingContext(
return mock;
},
OutputPreferences: () => OutputPreferences.test(),
Logger: () => BufferLogger(),
Logger: () => BufferLogger(
terminal: globals.terminal,
outputPreferences: outputPreferences,
),
OperatingSystemUtils: () => FakeOperatingSystemUtils(),
PersistentToolState: () => buildPersistentToolState(globals.fs),
SimControl: () => MockSimControl(),

View File

@@ -38,7 +38,10 @@ final Map<Type, Generator> _testbedDefaults = <Type, Generator>{
// Keeps tests fast by avoiding the actual file system.
FileSystem: () => MemoryFileSystem(style: globals.platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix),
ProcessManager: () => FakeProcessManager.any(),
Logger: () => BufferLogger(), // Allows reading logs and prevents stdout.
Logger: () => BufferLogger(
terminal: AnsiTerminal(stdio: globals.stdio, platform: globals.platform), // Danger, using real stdio.
outputPreferences: OutputPreferences.test(),
), // Allows reading logs and prevents stdout.
OperatingSystemUtils: () => FakeOperatingSystemUtils(),
OutputPreferences: () => OutputPreferences.test(), // configures BufferLogger to avoid color codes.
Usage: () => NoOpUsage(), // prevent addition of analytics from burdening test mocks