From fcdd46e534686c1cfb89e923610a3e9f4e2b9b7e Mon Sep 17 00:00:00 2001 From: Trevor Merrifield Date: Sat, 16 Sep 2017 23:36:11 -0400 Subject: [PATCH] Ensure tcp test case passes when disconnected from network net::tcp::tests::connect_timeout_unroutable fails when the network is unreachable, like on a laptop disconnected from wifi. Check for this error and allow the test to pass. Closes #44645 --- src/libstd/net/tcp.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs index 943a83a95fb23..aff9af66444c4 100644 --- a/src/libstd/net/tcp.rs +++ b/src/libstd/net/tcp.rs @@ -1570,10 +1570,13 @@ mod tests { #[test] fn connect_timeout_unroutable() { - // this IP is unroutable, so connections should always time out. + // this IP is unroutable, so connections should always time out, + // provided the network is reachable to begin with. let addr = "10.255.255.1:80".parse().unwrap(); let e = TcpStream::connect_timeout(&addr, Duration::from_millis(250)).unwrap_err(); - assert_eq!(e.kind(), io::ErrorKind::TimedOut); + assert!(e.kind() == io::ErrorKind::TimedOut || + e.kind() == io::ErrorKind::Other, + "bad error: {} {:?}", e, e.kind()); } #[test]