Skip to content

Commit

Permalink
Check for both TimedOut and WouldBlock in timeout tests
Browse files Browse the repository at this point in the history
Windows returns TimedOut and everything else returns WouldBlock :(
  • Loading branch information
sfackler committed May 28, 2015
1 parent bb620b1 commit 8b758a3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/libstd/net/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -929,8 +929,8 @@ mod tests {

let mut buf = [0; 10];
let wait = Duration::span(|| {
assert_eq!(ErrorKind::WouldBlock,
stream.read(&mut buf).err().expect("expected error").kind());
let kind = stream.read(&mut buf).err().expect("expected error").kind();
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
});
assert!(wait > Duration::from_millis(5));
assert!(wait < Duration::from_millis(15));
Expand All @@ -952,8 +952,8 @@ mod tests {
assert_eq!(b"hello world", &buf[..]);

let wait = Duration::span(|| {
assert_eq!(ErrorKind::WouldBlock,
stream.read(&mut buf).err().expect("expected error").kind());
let kind = stream.read(&mut buf).err().expect("expected error").kind();
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
});
assert!(wait > Duration::from_millis(5));
assert!(wait < Duration::from_millis(15));
Expand Down
8 changes: 4 additions & 4 deletions src/libstd/net/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ mod tests {

let mut buf = [0; 10];
let wait = Duration::span(|| {
assert_eq!(ErrorKind::WouldBlock,
stream.recv_from(&mut buf).err().expect("expected error").kind());
let kind = stream.read(&mut buf).err().expect("expected error").kind();
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
});
assert!(wait > Duration::from_millis(5));
assert!(wait < Duration::from_millis(15));
Expand All @@ -414,8 +414,8 @@ mod tests {
assert_eq!(b"hello world", &buf[..]);

let wait = Duration::span(|| {
assert_eq!(ErrorKind::WouldBlock,
stream.recv_from(&mut buf).err().expect("expected error").kind());
let kind = stream.read(&mut buf).err().expect("expected error").kind();
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
});
assert!(wait > Duration::from_millis(5));
assert!(wait < Duration::from_millis(15));
Expand Down

0 comments on commit 8b758a3

Please sign in to comment.