diff options
| author | bors <bors@rust-lang.org> | 2013-12-17 10:21:44 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-12-17 10:21:44 -0800 |
| commit | fe85856dc945c7e5eb83e05bdbd72fe1acd6d1c0 (patch) | |
| tree | e9a65bddef89b630cf39cb6adc21208238172971 /src | |
| parent | b870ce7a9fe1368462c3ba8b62a1f85c9e5444ce (diff) | |
| parent | 33ca3e35bebdb3f1b718feb374df1fa24a1ad73a (diff) | |
| download | rust-fe85856dc945c7e5eb83e05bdbd72fe1acd6d1c0.tar.gz rust-fe85856dc945c7e5eb83e05bdbd72fe1acd6d1c0.zip | |
auto merge of #10863 : cadencemarseille/rust/patch-handle-ENOENT, r=alexcrichton
Translate ENOENT to IoErrorKind::FileNotFound.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustuv/lib.rs | 1 | ||||
| -rw-r--r-- | src/librustuv/uvll.rs | 3 | ||||
| -rw-r--r-- | src/libstd/io/net/unix.rs | 2 | ||||
| -rw-r--r-- | src/libstd/run.rs | 9 |
4 files changed, 12 insertions, 3 deletions
diff --git a/src/librustuv/lib.rs b/src/librustuv/lib.rs index 34d36b486b3..9f2b19ac5fd 100644 --- a/src/librustuv/lib.rs +++ b/src/librustuv/lib.rs @@ -337,6 +337,7 @@ pub fn uv_error_to_io_error(uverr: UvError) -> IoError { EACCES => PermissionDenied, ECONNREFUSED => ConnectionRefused, ECONNRESET => ConnectionReset, + ENOENT => FileNotFound, ENOTCONN => NotConnected, EPIPE => BrokenPipe, ECONNABORTED => ConnectionAborted, diff --git a/src/librustuv/uvll.rs b/src/librustuv/uvll.rs index 91be6563343..0e5b50fd310 100644 --- a/src/librustuv/uvll.rs +++ b/src/librustuv/uvll.rs @@ -44,6 +44,7 @@ pub static EOF: c_int = -4095; pub static UNKNOWN: c_int = -4094; // uv-errno.h redefines error codes for windows, but not for unix... +// https://github.com/joyent/libuv/blob/master/include/uv-errno.h #[cfg(windows)] pub mod errors { @@ -52,6 +53,7 @@ pub mod errors { pub static EACCES: c_int = -4092; pub static ECONNREFUSED: c_int = -4078; pub static ECONNRESET: c_int = -4077; + pub static ENOENT: c_int = -4058; pub static ENOTCONN: c_int = -4053; pub static EPIPE: c_int = -4047; pub static ECONNABORTED: c_int = -4079; @@ -66,6 +68,7 @@ pub mod errors { pub static EACCES: c_int = -libc::EACCES; pub static ECONNREFUSED: c_int = -libc::ECONNREFUSED; pub static ECONNRESET: c_int = -libc::ECONNRESET; + pub static ENOENT: c_int = -libc::ENOENT; pub static ENOTCONN: c_int = -libc::ENOTCONN; pub static EPIPE: c_int = -libc::EPIPE; pub static ECONNABORTED: c_int = -libc::ECONNABORTED; diff --git a/src/libstd/io/net/unix.rs b/src/libstd/io/net/unix.rs index 49770b80060..2766aa9ad27 100644 --- a/src/libstd/io/net/unix.rs +++ b/src/libstd/io/net/unix.rs @@ -191,7 +191,7 @@ mod tests { do run_in_mt_newsched_task { let mut called = false; io_error::cond.trap(|e| { - assert_eq!(e.kind, OtherIoError); + assert_eq!(e.kind, FileNotFound); called = true; }).inside(|| { let stream = UnixStream::connect(&("path/to/nowhere")); diff --git a/src/libstd/run.rs b/src/libstd/run.rs index 70ad752ea93..3c4d06bc71f 100644 --- a/src/libstd/run.rs +++ b/src/libstd/run.rs @@ -339,7 +339,7 @@ mod tests { use task::spawn; use unstable::running_on_valgrind; use io::native::file; - use io::{Writer, Reader, io_error}; + use io::{FileNotFound, OtherIoError, Reader, Writer, io_error}; #[test] #[cfg(not(target_os="android"))] // FIXME(#10380) @@ -353,9 +353,14 @@ mod tests { #[test] fn test_process_output_fail_to_start() { + // If the executable does not exist, then the io_error condition should be raised with + // IoErrorKind FileNotFound. + let mut trapped_io_error = false; - let opt_outp = io_error::cond.trap(|_| { + let opt_outp = io_error::cond.trap(|e| { trapped_io_error = true; + // FIXME(#11023) + assert_eq!(e.kind, if cfg!(windows) { OtherIoError } else { FileNotFound }); }).inside(|| -> Option<run::ProcessOutput> { run::process_output("no-binary-by-this-name-should-exist", []) }); |
