Add exception to FakeCommand (#75545)

This commit is contained in:
Jenn Magder
2021-02-09 10:07:46 -08:00
committed by GitHub
parent bbc1614aa9
commit 152d88a3df
8 changed files with 129 additions and 181 deletions

View File

@@ -33,6 +33,7 @@ class FakeCommand {
this.stderr = '',
this.completer,
this.stdin,
this.exception,
}) : assert(command != null),
assert(duration != null),
assert(exitCode != null);
@@ -97,6 +98,9 @@ class FakeCommand {
/// [FakeProcess].
final IOSink stdin;
/// If provided, this exception will be thrown when the fake command is run.
final dynamic exception;
void _matches(
List<String> command,
String workingDirectory,
@@ -229,6 +233,9 @@ abstract class FakeProcessManager implements ProcessManager {
) {
_pid += 1;
final FakeCommand fakeCommand = findCommand(command, workingDirectory, environment, encoding);
if (fakeCommand.exception != null) {
throw fakeCommand.exception;
}
if (fakeCommand.onRun != null) {
fakeCommand.onRun();
}