Refactor: Construct IoError from std::io::Error instead of std::io::ErrorKind (#15777)

This commit is contained in:
Piepmatz
2025-05-18 14:52:40 +02:00
committed by GitHub
parent c4dcfdb77b
commit 833471241a
80 changed files with 408 additions and 299 deletions

View File

@ -60,5 +60,5 @@ fn self_path_runtime() {
fn self_path_repl() {
let actual = nu!("const foo = path self; $foo");
assert!(!actual.status.success());
assert!(actual.err.contains("nu::shell::io::not_found"));
assert!(actual.err.contains("nu::shell::io::file_not_found"));
}

View File

@ -6,6 +6,8 @@ use nu_test_support::playground::Playground;
use rstest::rstest;
#[cfg(not(windows))]
use std::fs;
#[cfg(windows)]
use std::{fs::OpenOptions, os::windows::fs::OpenOptionsExt};
#[test]
fn removes_a_file() {
@ -562,3 +564,26 @@ fn rm_with_tilde() {
assert!(!files_exist_at(&["~tilde"], dirs.test()));
})
}
#[test]
#[cfg(windows)]
fn rm_already_in_use() {
Playground::setup("rm_already_in_use", |dirs, sandbox| {
sandbox.with_files(&[EmptyFile("i_will_be_used.txt")]);
let file_path = dirs.root().join("rm_already_in_use/i_will_be_used.txt");
let _file = OpenOptions::new()
.read(true)
.write(false)
.share_mode(0) // deny all sharing
.open(file_path)
.unwrap();
let outcome = nu!(
cwd: dirs.root(),
"rm rm_already_in_use/i_will_be_used.txt"
);
assert!(outcome.err.contains("nu::shell::io::already_in_use"));
})
}