[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tool] when writing to openssl as a part of macOS/iOS code-signing, flush the stdin stream before closing it #150120

Prev Previous commit
simplify new test of writeToStdinGuarded
  • Loading branch information
andrewkolos committed Jun 28, 2024
commit f01f1c17f1b0c6dcce6ac037a105c6219bae7bf6
48 changes: 13 additions & 35 deletions packages/flutter_tools/test/general.shard/base/process_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -450,45 +450,23 @@ void main() {
group('writeToStdinGuarded', () {
testWithoutContext('handles any error thrown by stdin.flush', () async {
final _ThrowsOnFlushIOSink stdin = _ThrowsOnFlushIOSink();
final Completer<bool> fooCommandCompleter = Completer<bool>();
final Future<bool> >

void fooOnRun(List<String> command) {
ProcessUtils.writeToStdinGuarded(
stdin: stdin,
content: 'message to stdin',
onError: (Object error, StackTrace stackTrace) {
fooCommandCompleter.complete(true);
},
).then((_) {
if (!fooCommandCompleter.isCompleted) {
fooCommandCompleter.complete(false);
}
}).onError((Exception error, StackTrace stackTrace) {
// onError should have handled any error, so either the onError callback
// or the .then callback threw. Fail the test.
throw error;
});
}

final FakeProcessManager processManager = FakeProcessManager.list(
<FakeCommand>[
FakeCommand(
command: const <String>['foo'],
stdin: stdin,
onRun: fooOnRun,
completer: fooCommandCompleter,
),
],
Object? errorPassedToCallback;

await ProcessUtils.writeToStdinGuarded(
stdin: stdin,
content: 'message to stdin',
onError: (Object error, StackTrace stackTrace) {
errorPassedToCallback = error;
},
);

await processManager.run(<String>['foo']);

expect(
await onErrorCalled,
isTrue,
reason: 'onError argument to writeToStdinGuarded should have been called',
errorPassedToCallback,
isNotNull,
reason: 'onError callback should have been invoked.',
);

expect(errorPassedToCallback, const TypeMatcher<SocketException>());
});
});
}
Expand Down