Skip to content

Commit 6d3506a

Browse files
committed
fs: add and test for DirectoryNotEmpty error variant
1 parent fc15f96 commit 6d3506a

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

src/helpers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
490490
TimedOut => "ETIMEDOUT",
491491
AlreadyExists => "EEXIST",
492492
WouldBlock => "EWOULDBLOCK",
493+
DirectoryNotEmpty => "ENOTEMPTY",
493494
_ => {
494495
throw_unsup_format!(
495496
"io error {:?} cannot be translated into a raw os error",

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#![feature(try_blocks)]
66
#![feature(let_else)]
77
#![feature(bool_to_option)]
8+
#![feature(io_error_more)]
89
#![warn(rust_2018_idioms)]
910
#![allow(clippy::cast_lossless)]
1011

tests/run-pass/fs.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// compile-flags: -Zmiri-disable-isolation
33

44
#![feature(rustc_private)]
5+
#![feature(io_error_more)]
56

67
extern crate libc;
78

@@ -380,6 +381,8 @@ fn test_directory() {
380381
let mut file_names = dir_iter.map(|e| e.unwrap().file_name()).collect::<Vec<_>>();
381382
file_names.sort_unstable();
382383
assert_eq!(file_names, vec!["test_file_1", "test_file_2"]);
384+
// Deleting the directory should fail, since it is not empty.
385+
assert_eq!(ErrorKind::DirectoryNotEmpty, remove_dir(&dir_path).unwrap_err().kind());
383386
// Clean up the files in the directory
384387
remove_file(&path_1).unwrap();
385388
remove_file(&path_2).unwrap();

0 commit comments

Comments
 (0)