mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 11:07:44 +00:00
chore: run cargo +nightly clippy --fix
This commit is contained in:
parent
c3218740dc
commit
fdd6a05259
9 changed files with 31 additions and 31 deletions
|
@ -511,7 +511,7 @@ fn test_write_to_self() {
|
||||||
.create_new(true)
|
.create_new(true)
|
||||||
.write(true)
|
.write(true)
|
||||||
.append(true)
|
.append(true)
|
||||||
.open(&file_path)
|
.open(file_path)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
s.fixtures.append("first_file", "first_file_content.");
|
s.fixtures.append("first_file", "first_file_content.");
|
||||||
|
|
|
@ -1085,7 +1085,7 @@ fn test_cp_no_deref_folder_to_folder() {
|
||||||
fn test_cp_archive() {
|
fn test_cp_archive() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
let ts = time::OffsetDateTime::now_local().unwrap();
|
let ts = time::OffsetDateTime::now_local().unwrap();
|
||||||
let previous = FileTime::from_unix_time(ts.unix_timestamp() - 3600, ts.nanosecond() as u32);
|
let previous = FileTime::from_unix_time(ts.unix_timestamp() - 3600, ts.nanosecond());
|
||||||
// set the file creation/modification an hour ago
|
// set the file creation/modification an hour ago
|
||||||
filetime::set_file_times(
|
filetime::set_file_times(
|
||||||
at.plus_as_string(TEST_HELLO_WORLD_SOURCE),
|
at.plus_as_string(TEST_HELLO_WORLD_SOURCE),
|
||||||
|
|
|
@ -2057,7 +2057,7 @@ fn test_ls_indicator_style() {
|
||||||
.tempdir()
|
.tempdir()
|
||||||
.expect("failed to create dir");
|
.expect("failed to create dir");
|
||||||
let socket_path = dir.path().join("sock");
|
let socket_path = dir.path().join("sock");
|
||||||
let _listener = UnixListener::bind(&socket_path).expect("failed to create socket");
|
let _listener = UnixListener::bind(socket_path).expect("failed to create socket");
|
||||||
|
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&[
|
.args(&[
|
||||||
|
|
|
@ -621,7 +621,7 @@ fn test_mv_update_option() {
|
||||||
at.touch(file_b);
|
at.touch(file_b);
|
||||||
let ts = time::OffsetDateTime::now_local().unwrap();
|
let ts = time::OffsetDateTime::now_local().unwrap();
|
||||||
let now = FileTime::from_unix_time(ts.unix_timestamp(), ts.nanosecond());
|
let now = FileTime::from_unix_time(ts.unix_timestamp(), ts.nanosecond());
|
||||||
let later = FileTime::from_unix_time(ts.unix_timestamp() as i64 + 3600, ts.nanosecond() as u32);
|
let later = FileTime::from_unix_time(ts.unix_timestamp() + 3600, ts.nanosecond());
|
||||||
filetime::set_file_times(at.plus_as_string(file_a), now, now).unwrap();
|
filetime::set_file_times(at.plus_as_string(file_a), now, now).unwrap();
|
||||||
filetime::set_file_times(at.plus_as_string(file_b), now, later).unwrap();
|
filetime::set_file_times(at.plus_as_string(file_b), now, later).unwrap();
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ impl RandomFile {
|
||||||
/// `create()` file handle located at `at` / `name`
|
/// `create()` file handle located at `at` / `name`
|
||||||
fn new(at: &AtPath, name: &str) -> Self {
|
fn new(at: &AtPath, name: &str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
inner: File::create(&at.plus(name)).unwrap(),
|
inner: File::create(at.plus(name)).unwrap(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ fn get_symlink_times(at: &AtPath, path: &str) -> (FileTime, FileTime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_file_times(at: &AtPath, path: &str, atime: FileTime, mtime: FileTime) {
|
fn set_file_times(at: &AtPath, path: &str, atime: FileTime, mtime: FileTime) {
|
||||||
filetime::set_file_times(&at.plus_as_string(path), atime, mtime).unwrap();
|
filetime::set_file_times(at.plus_as_string(path), atime, mtime).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjusts for local timezone
|
// Adjusts for local timezone
|
||||||
|
|
|
@ -8,7 +8,7 @@ use crate::common::util::*;
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fn check_termination(result: &ExitStatus) {
|
fn check_termination(result: &ExitStatus) {
|
||||||
assert_eq!(result.signal(), Some(libc::SIGPIPE as i32));
|
assert_eq!(result.signal(), Some(libc::SIGPIPE));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(unix))]
|
#[cfg(not(unix))]
|
||||||
|
|
|
@ -470,7 +470,7 @@ pub fn recursive_copy(src: &Path, dest: &Path) -> Result<()> {
|
||||||
fs::create_dir(&new_dest)?;
|
fs::create_dir(&new_dest)?;
|
||||||
recursive_copy(&entry.path(), &new_dest)?;
|
recursive_copy(&entry.path(), &new_dest)?;
|
||||||
} else {
|
} else {
|
||||||
fs::copy(&entry.path(), new_dest)?;
|
fs::copy(entry.path(), new_dest)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -631,12 +631,12 @@ impl AtPath {
|
||||||
|
|
||||||
pub fn rmdir(&self, dir: &str) {
|
pub fn rmdir(&self, dir: &str) {
|
||||||
log_info("rmdir", self.plus_as_string(dir));
|
log_info("rmdir", self.plus_as_string(dir));
|
||||||
fs::remove_dir(&self.plus(dir)).unwrap();
|
fs::remove_dir(self.plus(dir)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mkdir(&self, dir: &str) {
|
pub fn mkdir(&self, dir: &str) {
|
||||||
log_info("mkdir", self.plus_as_string(dir));
|
log_info("mkdir", self.plus_as_string(dir));
|
||||||
fs::create_dir(&self.plus(dir)).unwrap();
|
fs::create_dir(self.plus(dir)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mkdir_all(&self, dir: &str) {
|
pub fn mkdir_all(&self, dir: &str) {
|
||||||
|
@ -645,7 +645,7 @@ impl AtPath {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn make_file(&self, name: &str) -> File {
|
pub fn make_file(&self, name: &str) -> File {
|
||||||
match File::create(&self.plus(name)) {
|
match File::create(self.plus(name)) {
|
||||||
Ok(f) => f,
|
Ok(f) => f,
|
||||||
Err(e) => panic!("{}", e),
|
Err(e) => panic!("{}", e),
|
||||||
}
|
}
|
||||||
|
@ -653,7 +653,7 @@ impl AtPath {
|
||||||
|
|
||||||
pub fn touch(&self, file: &str) {
|
pub fn touch(&self, file: &str) {
|
||||||
log_info("touch", self.plus_as_string(file));
|
log_info("touch", self.plus_as_string(file));
|
||||||
File::create(&self.plus(file)).unwrap();
|
File::create(self.plus(file)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
|
@ -682,25 +682,25 @@ impl AtPath {
|
||||||
pub fn hard_link(&self, original: &str, link: &str) {
|
pub fn hard_link(&self, original: &str, link: &str) {
|
||||||
log_info(
|
log_info(
|
||||||
"hard_link",
|
"hard_link",
|
||||||
&format!(
|
format!(
|
||||||
"{},{}",
|
"{},{}",
|
||||||
self.plus_as_string(original),
|
self.plus_as_string(original),
|
||||||
self.plus_as_string(link)
|
self.plus_as_string(link)
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
hard_link(&self.plus(original), &self.plus(link)).unwrap();
|
hard_link(self.plus(original), self.plus(link)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn symlink_file(&self, original: &str, link: &str) {
|
pub fn symlink_file(&self, original: &str, link: &str) {
|
||||||
log_info(
|
log_info(
|
||||||
"symlink",
|
"symlink",
|
||||||
&format!(
|
format!(
|
||||||
"{},{}",
|
"{},{}",
|
||||||
self.plus_as_string(original),
|
self.plus_as_string(original),
|
||||||
self.plus_as_string(link)
|
self.plus_as_string(link)
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
symlink_file(&self.plus(original), &self.plus(link)).unwrap();
|
symlink_file(self.plus(original), self.plus(link)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn relative_symlink_file(&self, original: &str, link: &str) {
|
pub fn relative_symlink_file(&self, original: &str, link: &str) {
|
||||||
|
@ -708,21 +708,21 @@ impl AtPath {
|
||||||
let original = original.replace('/', &MAIN_SEPARATOR.to_string());
|
let original = original.replace('/', &MAIN_SEPARATOR.to_string());
|
||||||
log_info(
|
log_info(
|
||||||
"symlink",
|
"symlink",
|
||||||
&format!("{},{}", &original, &self.plus_as_string(link)),
|
format!("{},{}", &original, &self.plus_as_string(link)),
|
||||||
);
|
);
|
||||||
symlink_file(original, &self.plus(link)).unwrap();
|
symlink_file(original, self.plus(link)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn symlink_dir(&self, original: &str, link: &str) {
|
pub fn symlink_dir(&self, original: &str, link: &str) {
|
||||||
log_info(
|
log_info(
|
||||||
"symlink",
|
"symlink",
|
||||||
&format!(
|
format!(
|
||||||
"{},{}",
|
"{},{}",
|
||||||
self.plus_as_string(original),
|
self.plus_as_string(original),
|
||||||
self.plus_as_string(link)
|
self.plus_as_string(link)
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
symlink_dir(&self.plus(original), &self.plus(link)).unwrap();
|
symlink_dir(self.plus(original), self.plus(link)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn relative_symlink_dir(&self, original: &str, link: &str) {
|
pub fn relative_symlink_dir(&self, original: &str, link: &str) {
|
||||||
|
@ -730,14 +730,14 @@ impl AtPath {
|
||||||
let original = original.replace('/', &MAIN_SEPARATOR.to_string());
|
let original = original.replace('/', &MAIN_SEPARATOR.to_string());
|
||||||
log_info(
|
log_info(
|
||||||
"symlink",
|
"symlink",
|
||||||
&format!("{},{}", &original, &self.plus_as_string(link)),
|
format!("{},{}", &original, &self.plus_as_string(link)),
|
||||||
);
|
);
|
||||||
symlink_dir(original, &self.plus(link)).unwrap();
|
symlink_dir(original, self.plus(link)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_symlink(&self, path: &str) -> bool {
|
pub fn is_symlink(&self, path: &str) -> bool {
|
||||||
log_info("is_symlink", self.plus_as_string(path));
|
log_info("is_symlink", self.plus_as_string(path));
|
||||||
match fs::symlink_metadata(&self.plus(path)) {
|
match fs::symlink_metadata(self.plus(path)) {
|
||||||
Ok(m) => m.file_type().is_symlink(),
|
Ok(m) => m.file_type().is_symlink(),
|
||||||
Err(_) => false,
|
Err(_) => false,
|
||||||
}
|
}
|
||||||
|
@ -745,7 +745,7 @@ impl AtPath {
|
||||||
|
|
||||||
pub fn resolve_link(&self, path: &str) -> String {
|
pub fn resolve_link(&self, path: &str) -> String {
|
||||||
log_info("resolve_link", self.plus_as_string(path));
|
log_info("resolve_link", self.plus_as_string(path));
|
||||||
match fs::read_link(&self.plus(path)) {
|
match fs::read_link(self.plus(path)) {
|
||||||
Ok(p) => self.minus_as_string(p.to_str().unwrap()),
|
Ok(p) => self.minus_as_string(p.to_str().unwrap()),
|
||||||
Err(_) => "".to_string(),
|
Err(_) => "".to_string(),
|
||||||
}
|
}
|
||||||
|
@ -753,7 +753,7 @@ impl AtPath {
|
||||||
|
|
||||||
pub fn read_symlink(&self, path: &str) -> String {
|
pub fn read_symlink(&self, path: &str) -> String {
|
||||||
log_info("read_symlink", self.plus_as_string(path));
|
log_info("read_symlink", self.plus_as_string(path));
|
||||||
fs::read_link(&self.plus(path))
|
fs::read_link(self.plus(path))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -761,21 +761,21 @@ impl AtPath {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn symlink_metadata(&self, path: &str) -> fs::Metadata {
|
pub fn symlink_metadata(&self, path: &str) -> fs::Metadata {
|
||||||
match fs::symlink_metadata(&self.plus(path)) {
|
match fs::symlink_metadata(self.plus(path)) {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
Err(e) => panic!("{}", e),
|
Err(e) => panic!("{}", e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn metadata(&self, path: &str) -> fs::Metadata {
|
pub fn metadata(&self, path: &str) -> fs::Metadata {
|
||||||
match fs::metadata(&self.plus(path)) {
|
match fs::metadata(self.plus(path)) {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
Err(e) => panic!("{}", e),
|
Err(e) => panic!("{}", e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn file_exists(&self, path: &str) -> bool {
|
pub fn file_exists(&self, path: &str) -> bool {
|
||||||
match fs::metadata(&self.plus(path)) {
|
match fs::metadata(self.plus(path)) {
|
||||||
Ok(m) => m.is_file(),
|
Ok(m) => m.is_file(),
|
||||||
Err(_) => false,
|
Err(_) => false,
|
||||||
}
|
}
|
||||||
|
@ -783,14 +783,14 @@ impl AtPath {
|
||||||
|
|
||||||
/// Decide whether the named symbolic link exists in the test directory.
|
/// Decide whether the named symbolic link exists in the test directory.
|
||||||
pub fn symlink_exists(&self, path: &str) -> bool {
|
pub fn symlink_exists(&self, path: &str) -> bool {
|
||||||
match fs::symlink_metadata(&self.plus(path)) {
|
match fs::symlink_metadata(self.plus(path)) {
|
||||||
Ok(m) => m.file_type().is_symlink(),
|
Ok(m) => m.file_type().is_symlink(),
|
||||||
Err(_) => false,
|
Err(_) => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dir_exists(&self, path: &str) -> bool {
|
pub fn dir_exists(&self, path: &str) -> bool {
|
||||||
match fs::metadata(&self.plus(path)) {
|
match fs::metadata(self.plus(path)) {
|
||||||
Ok(m) => m.is_dir(),
|
Ok(m) => m.is_dir(),
|
||||||
Err(_) => false,
|
Err(_) => false,
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ fn util_name_double() {
|
||||||
};
|
};
|
||||||
|
|
||||||
let scenario = TestScenario::new("sort");
|
let scenario = TestScenario::new("sort");
|
||||||
let mut child = Command::new(&scenario.bin_path)
|
let mut child = Command::new(scenario.bin_path)
|
||||||
.arg("sort")
|
.arg("sort")
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
.stderr(Stdio::piped())
|
.stderr(Stdio::piped())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue