From 855b180e12f680290f1d92664507c9b6e30ad3b0 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Wed, 5 Apr 2023 12:00:33 -0700 Subject: [PATCH] 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. --- .../src/runners/ssh_command_runner_test.dart | 36 +++++++------------ 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/packages/fuchsia_remote_debug_protocol/test/src/runners/ssh_command_runner_test.dart b/packages/fuchsia_remote_debug_protocol/test/src/runners/ssh_command_runner_test.dart index 01cf993037..7cb70aedd7 100644 --- a/packages/fuchsia_remote_debug_protocol/test/src/runners/ssh_command_runner_test.dart +++ b/packages/fuchsia_remote_debug_protocol/test/src/runners/ssh_command_runner_test.dart @@ -34,12 +34,10 @@ void main() { group('SshCommandRunner.run', () { late FakeProcessManager fakeProcessManager; - late FakeProcessResult fakeProcessResult; SshCommandRunner runner; setUp(() { - fakeProcessResult = FakeProcessResult(); - fakeProcessManager = FakeProcessManager()..fakeResult = fakeProcessResult; + fakeProcessManager = FakeProcessManager(); }); test('verify interface is appended to ipv6 address', () async { @@ -51,7 +49,7 @@ void main() { interface: interface, sshConfigPath: '/whatever', ); - fakeProcessResult.stdout = 'somestuff'; + fakeProcessManager.fakeResult = ProcessResult(23, 0, 'somestuff', null); await runner.run('ls /whatever'); expect(fakeProcessManager.runCommands.single, contains('$ipV6Addr%$interface')); }); @@ -62,7 +60,7 @@ void main() { fakeProcessManager, address: ipV6Addr, ); - fakeProcessResult.stdout = 'somestuff'; + fakeProcessManager.fakeResult = ProcessResult(23, 0, 'somestuff', null); await runner.run('ls /whatever'); expect(fakeProcessManager.runCommands.single, contains(ipV6Addr)); }); @@ -71,11 +69,15 @@ void main() { const String addr = '192.168.1.1'; runner = SshCommandRunner.withProcessManager(fakeProcessManager, address: addr); - fakeProcessResult.stdout = ''' + fakeProcessManager.fakeResult = ProcessResult( + 23, + 0, + ''' this has four - lines'''; + lines''', + null); final List result = await runner.run('oihaw'); expect(result, hasLength(4)); }); @@ -84,8 +86,7 @@ void main() { const String addr = '192.168.1.1'; runner = SshCommandRunner.withProcessManager(fakeProcessManager, address: addr); - fakeProcessResult.stdout = 'whatever'; - fakeProcessResult.exitCode = 1; + fakeProcessManager.fakeResult = ProcessResult(23, 1, 'whatever', null); Future failingFunction() async { await runner.run('oihaw'); } @@ -101,7 +102,7 @@ void main() { address: addr, sshConfigPath: config, ); - fakeProcessResult.stdout = 'somestuff'; + fakeProcessManager.fakeResult = ProcessResult(23, 0, 'somestuff', null); await runner.run('ls /whatever'); final List passedCommand = fakeProcessManager.runCommands.single as List; expect(passedCommand, contains('-F')); @@ -116,7 +117,7 @@ void main() { fakeProcessManager, address: addr, ); - fakeProcessResult.stdout = 'somestuff'; + fakeProcessManager.fakeResult = ProcessResult(23, 0, 'somestuff', null); await runner.run('ls /whatever'); final List passedCommand = fakeProcessManager.runCommands.single as List; final int indexOfFlag = passedCommand.indexOf('-F'); @@ -126,7 +127,7 @@ void main() { } class FakeProcessManager extends Fake implements ProcessManager { - FakeProcessResult? fakeResult; + ProcessResult? fakeResult; List> runCommands = >[]; @@ -143,14 +144,3 @@ class FakeProcessManager extends Fake implements ProcessManager { return fakeResult!; } } - -class FakeProcessResult extends Fake implements ProcessResult { - @override - int exitCode = 0; - - @override - dynamic stdout; - - @override - dynamic stderr; -}