Auto merge of #2008 - RalfJung:notempty, r=RalfJung
fs: add and test for DirectoryNotEmpty error variant
This commit is contained in:
commit
acb58ffaaf
@ -490,6 +490,7 @@ fn set_last_error_from_io_error(&mut self, err_kind: std::io::ErrorKind) -> Inte
|
|||||||
TimedOut => "ETIMEDOUT",
|
TimedOut => "ETIMEDOUT",
|
||||||
AlreadyExists => "EEXIST",
|
AlreadyExists => "EEXIST",
|
||||||
WouldBlock => "EWOULDBLOCK",
|
WouldBlock => "EWOULDBLOCK",
|
||||||
|
DirectoryNotEmpty => "ENOTEMPTY",
|
||||||
_ => {
|
_ => {
|
||||||
throw_unsup_format!(
|
throw_unsup_format!(
|
||||||
"io error {:?} cannot be translated into a raw os error",
|
"io error {:?} cannot be translated into a raw os error",
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#![feature(try_blocks)]
|
#![feature(try_blocks)]
|
||||||
#![feature(let_else)]
|
#![feature(let_else)]
|
||||||
#![feature(bool_to_option)]
|
#![feature(bool_to_option)]
|
||||||
|
#![feature(io_error_more)]
|
||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
#![allow(clippy::cast_lossless)]
|
#![allow(clippy::cast_lossless)]
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// compile-flags: -Zmiri-disable-isolation
|
// compile-flags: -Zmiri-disable-isolation
|
||||||
|
|
||||||
#![feature(rustc_private)]
|
#![feature(rustc_private)]
|
||||||
|
#![feature(io_error_more)]
|
||||||
|
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
|
||||||
@ -380,6 +381,8 @@ fn test_directory() {
|
|||||||
let mut file_names = dir_iter.map(|e| e.unwrap().file_name()).collect::<Vec<_>>();
|
let mut file_names = dir_iter.map(|e| e.unwrap().file_name()).collect::<Vec<_>>();
|
||||||
file_names.sort_unstable();
|
file_names.sort_unstable();
|
||||||
assert_eq!(file_names, vec!["test_file_1", "test_file_2"]);
|
assert_eq!(file_names, vec!["test_file_1", "test_file_2"]);
|
||||||
|
// Deleting the directory should fail, since it is not empty.
|
||||||
|
assert_eq!(ErrorKind::DirectoryNotEmpty, remove_dir(&dir_path).unwrap_err().kind());
|
||||||
// Clean up the files in the directory
|
// Clean up the files in the directory
|
||||||
remove_file(&path_1).unwrap();
|
remove_file(&path_1).unwrap();
|
||||||
remove_file(&path_2).unwrap();
|
remove_file(&path_2).unwrap();
|
||||||
|
Loading…
Reference in New Issue
Block a user