Unverified Commit 855b180e authored by Brian Quinlan's avatar Brian Quinlan Committed by GitHub

Remove FakeProcessResult for Dart 3 compatibility (#124240)

Removes code that `implements ProcessResult` since it will be `final` in
Dart 3.

Fixes https://github.com/flutter/flutter/issues/124237

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] All existing and new tests are passing.
parent ff6be43b
...@@ -34,12 +34,10 @@ void main() { ...@@ -34,12 +34,10 @@ void main() {
group('SshCommandRunner.run', () { group('SshCommandRunner.run', () {
late FakeProcessManager fakeProcessManager; late FakeProcessManager fakeProcessManager;
late FakeProcessResult fakeProcessResult;
SshCommandRunner runner; SshCommandRunner runner;
setUp(() { setUp(() {
fakeProcessResult = FakeProcessResult(); fakeProcessManager = FakeProcessManager();
fakeProcessManager = FakeProcessManager()..fakeResult = fakeProcessResult;
}); });
test('verify interface is appended to ipv6 address', () async { test('verify interface is appended to ipv6 address', () async {
...@@ -51,7 +49,7 @@ void main() { ...@@ -51,7 +49,7 @@ void main() {
interface: interface, interface: interface,
sshConfigPath: '/whatever', sshConfigPath: '/whatever',
); );
fakeProcessResult.stdout = 'somestuff'; fakeProcessManager.fakeResult = ProcessResult(23, 0, 'somestuff', null);
await runner.run('ls /whatever'); await runner.run('ls /whatever');
expect(fakeProcessManager.runCommands.single, contains('$ipV6Addr%$interface')); expect(fakeProcessManager.runCommands.single, contains('$ipV6Addr%$interface'));
}); });
...@@ -62,7 +60,7 @@ void main() { ...@@ -62,7 +60,7 @@ void main() {
fakeProcessManager, fakeProcessManager,
address: ipV6Addr, address: ipV6Addr,
); );
fakeProcessResult.stdout = 'somestuff'; fakeProcessManager.fakeResult = ProcessResult(23, 0, 'somestuff', null);
await runner.run('ls /whatever'); await runner.run('ls /whatever');
expect(fakeProcessManager.runCommands.single, contains(ipV6Addr)); expect(fakeProcessManager.runCommands.single, contains(ipV6Addr));
}); });
...@@ -71,11 +69,15 @@ void main() { ...@@ -71,11 +69,15 @@ void main() {
const String addr = '192.168.1.1'; const String addr = '192.168.1.1';
runner = SshCommandRunner.withProcessManager(fakeProcessManager, runner = SshCommandRunner.withProcessManager(fakeProcessManager,
address: addr); address: addr);
fakeProcessResult.stdout = ''' fakeProcessManager.fakeResult = ProcessResult(
23,
0,
'''
this this
has has
four four
lines'''; lines''',
null);
final List<String> result = await runner.run('oihaw'); final List<String> result = await runner.run('oihaw');
expect(result, hasLength(4)); expect(result, hasLength(4));
}); });
...@@ -84,8 +86,7 @@ void main() { ...@@ -84,8 +86,7 @@ void main() {
const String addr = '192.168.1.1'; const String addr = '192.168.1.1';
runner = SshCommandRunner.withProcessManager(fakeProcessManager, runner = SshCommandRunner.withProcessManager(fakeProcessManager,
address: addr); address: addr);
fakeProcessResult.stdout = 'whatever'; fakeProcessManager.fakeResult = ProcessResult(23, 1, 'whatever', null);
fakeProcessResult.exitCode = 1;
Future<void> failingFunction() async { Future<void> failingFunction() async {
await runner.run('oihaw'); await runner.run('oihaw');
} }
...@@ -101,7 +102,7 @@ void main() { ...@@ -101,7 +102,7 @@ void main() {
address: addr, address: addr,
sshConfigPath: config, sshConfigPath: config,
); );
fakeProcessResult.stdout = 'somestuff'; fakeProcessManager.fakeResult = ProcessResult(23, 0, 'somestuff', null);
await runner.run('ls /whatever'); await runner.run('ls /whatever');
final List<String?> passedCommand = fakeProcessManager.runCommands.single as List<String?>; final List<String?> passedCommand = fakeProcessManager.runCommands.single as List<String?>;
expect(passedCommand, contains('-F')); expect(passedCommand, contains('-F'));
...@@ -116,7 +117,7 @@ void main() { ...@@ -116,7 +117,7 @@ void main() {
fakeProcessManager, fakeProcessManager,
address: addr, address: addr,
); );
fakeProcessResult.stdout = 'somestuff'; fakeProcessManager.fakeResult = ProcessResult(23, 0, 'somestuff', null);
await runner.run('ls /whatever'); await runner.run('ls /whatever');
final List<String?> passedCommand = fakeProcessManager.runCommands.single as List<String?>; final List<String?> passedCommand = fakeProcessManager.runCommands.single as List<String?>;
final int indexOfFlag = passedCommand.indexOf('-F'); final int indexOfFlag = passedCommand.indexOf('-F');
...@@ -126,7 +127,7 @@ void main() { ...@@ -126,7 +127,7 @@ void main() {
} }
class FakeProcessManager extends Fake implements ProcessManager { class FakeProcessManager extends Fake implements ProcessManager {
FakeProcessResult? fakeResult; ProcessResult? fakeResult;
List<List<dynamic>> runCommands = <List<dynamic>>[]; List<List<dynamic>> runCommands = <List<dynamic>>[];
...@@ -143,14 +144,3 @@ class FakeProcessManager extends Fake implements ProcessManager { ...@@ -143,14 +144,3 @@ class FakeProcessManager extends Fake implements ProcessManager {
return fakeResult!; return fakeResult!;
} }
} }
class FakeProcessResult extends Fake implements ProcessResult {
@override
int exitCode = 0;
@override
dynamic stdout;
@override
dynamic stderr;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment