blob: 1e71b831e9d7834489f4feda999a2be721b97132 [file] [log] [blame]
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
/// Tests that an exception on a non-socket _NativeSocket, e.g. a pipe to
/// another process, is properly thrown as a SocketException. This test confirms
/// the absence of a regression during the dart:io null safety migration where
/// the late localAddress field wasn't initialized in an error path, raising a
/// late initialization error instead.
import 'dart:io';
Future<void> main() async {
final process = await Process.start("exit", [], runInShell: true);
bool finished = false;
// Ensure any other exception is unhandled and fails the test.
process.stdin.done.catchError((e) {
finished = true;
}, test: (e) => e is SocketException);
while (!finished) {
await Future.delayed(new Duration(microseconds: 1));
await process.exitCode;
// Windows hangs for some reason.