Skip to content

Commit 33ca3e3

Browse files
Handle ENOENT
Translate ENOENT to IoErrorKind::FileNotFound.
1 parent e7b0e0a commit 33ca3e3

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

src/librustuv/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ pub fn uv_error_to_io_error(uverr: UvError) -> IoError {
337337
EACCES => PermissionDenied,
338338
ECONNREFUSED => ConnectionRefused,
339339
ECONNRESET => ConnectionReset,
340+
ENOENT => FileNotFound,
340341
ENOTCONN => NotConnected,
341342
EPIPE => BrokenPipe,
342343
ECONNABORTED => ConnectionAborted,

src/librustuv/uvll.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub static EOF: c_int = -4095;
4444
pub static UNKNOWN: c_int = -4094;
4545

4646
// uv-errno.h redefines error codes for windows, but not for unix...
47+
// https://github.com/joyent/libuv/blob/master/include/uv-errno.h
4748

4849
#[cfg(windows)]
4950
pub mod errors {
@@ -52,6 +53,7 @@ pub mod errors {
5253
pub static EACCES: c_int = -4092;
5354
pub static ECONNREFUSED: c_int = -4078;
5455
pub static ECONNRESET: c_int = -4077;
56+
pub static ENOENT: c_int = -4058;
5557
pub static ENOTCONN: c_int = -4053;
5658
pub static EPIPE: c_int = -4047;
5759
pub static ECONNABORTED: c_int = -4079;
@@ -66,6 +68,7 @@ pub mod errors {
6668
pub static EACCES: c_int = -libc::EACCES;
6769
pub static ECONNREFUSED: c_int = -libc::ECONNREFUSED;
6870
pub static ECONNRESET: c_int = -libc::ECONNRESET;
71+
pub static ENOENT: c_int = -libc::ENOENT;
6972
pub static ENOTCONN: c_int = -libc::ENOTCONN;
7073
pub static EPIPE: c_int = -libc::EPIPE;
7174
pub static ECONNABORTED: c_int = -libc::ECONNABORTED;

src/libstd/io/net/unix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ mod tests {
194194
do run_in_mt_newsched_task {
195195
let mut called = false;
196196
io_error::cond.trap(|e| {
197-
assert_eq!(e.kind, OtherIoError);
197+
assert_eq!(e.kind, FileNotFound);
198198
called = true;
199199
}).inside(|| {
200200
let stream = UnixStream::connect(&("path/to/nowhere"));

src/libstd/run.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ mod tests {
340340
use task::spawn;
341341
use unstable::running_on_valgrind;
342342
use io::native::file;
343-
use io::{Writer, Reader, io_error};
343+
use io::{FileNotFound, OtherIoError, Reader, Writer, io_error};
344344

345345
#[test]
346346
#[cfg(not(target_os="android"))] // FIXME(#10380)
@@ -354,9 +354,14 @@ mod tests {
354354

355355
#[test]
356356
fn test_process_output_fail_to_start() {
357+
// If the executable does not exist, then the io_error condition should be raised with
358+
// IoErrorKind FileNotFound.
359+
357360
let mut trapped_io_error = false;
358-
let opt_outp = io_error::cond.trap(|_| {
361+
let opt_outp = io_error::cond.trap(|e| {
359362
trapped_io_error = true;
363+
// FIXME(#11023)
364+
assert_eq!(e.kind, if cfg!(windows) { OtherIoError } else { FileNotFound });
360365
}).inside(|| -> Option<run::ProcessOutput> {
361366
run::process_output("no-binary-by-this-name-should-exist", [])
362367
});

0 commit comments

Comments
 (0)