Auto merge of #2008 - RalfJung:notempty, r=RalfJung

fs: add and test for DirectoryNotEmpty error variant
This commit is contained in:
bors 2022-03-07 23:31:10 +00:00
commit acb58ffaaf
3 changed files with 5 additions and 0 deletions

View File

@ -490,6 +490,7 @@ fn set_last_error_from_io_error(&mut self, err_kind: std::io::ErrorKind) -> Inte
TimedOut => "ETIMEDOUT",
AlreadyExists => "EEXIST",
WouldBlock => "EWOULDBLOCK",
DirectoryNotEmpty => "ENOTEMPTY",
_ => {
throw_unsup_format!(
"io error {:?} cannot be translated into a raw os error",

View File

@ -5,6 +5,7 @@
#![feature(try_blocks)]
#![feature(let_else)]
#![feature(bool_to_option)]
#![feature(io_error_more)]
#![warn(rust_2018_idioms)]
#![allow(clippy::cast_lossless)]

View File

@ -2,6 +2,7 @@
// compile-flags: -Zmiri-disable-isolation
#![feature(rustc_private)]
#![feature(io_error_more)]
extern crate libc;
@ -380,6 +381,8 @@ fn test_directory() {
let mut file_names = dir_iter.map(|e| e.unwrap().file_name()).collect::<Vec<_>>();
file_names.sort_unstable();
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
remove_file(&path_1).unwrap();
remove_file(&path_2).unwrap();