mirror of
https://github.com/uutils/findutils.git
synced 2026-06-10 15:48:30 -07:00
Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 13b4ae4d45 | |||
| 6a034e28e8 | |||
| eb6322df5f | |||
| cd44d01d57 | |||
| bda32f0482 | |||
| eed9b64aaf | |||
| ed3a62e9d7 | |||
| 1488d55ceb | |||
| 61f2ffe803 | |||
| efdf1f17c7 | |||
| 6be2cd4c2c | |||
| a1ae326e72 | |||
| 61002aec2b | |||
| 225f77f7ff | |||
| 0ebefda3a8 | |||
| 91a6e64c9f | |||
| f36f576fd9 | |||
| a5db23c712 | |||
| 04dad0ba5f | |||
| 2011a7adfa | |||
| 1753e032b2 | |||
| 6be211a336 | |||
| dbc2f2729b | |||
| 828a72a1ba | |||
| bcc4e0b099 | |||
| c6e025f19a |
Generated
+167
-88
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "findutils"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
homepage = "https://github.com/uutils/findutils"
|
||||
repository = "https://github.com/uutils/findutils"
|
||||
edition = "2018"
|
||||
@@ -24,7 +24,7 @@ assert_cmd = "2"
|
||||
filetime = "0.2"
|
||||
nix = "0.26"
|
||||
predicates = "3"
|
||||
serial_test = "1.0"
|
||||
serial_test = "2.0"
|
||||
tempfile = "3"
|
||||
|
||||
[[bin]]
|
||||
|
||||
@@ -169,7 +169,7 @@ impl Pattern {
|
||||
Self { regex }
|
||||
}
|
||||
|
||||
/// Test if this patern matches a string.
|
||||
/// Test if this pattern matches a string.
|
||||
pub fn matches(&self, string: &str) -> bool {
|
||||
self.regex.is_match(string)
|
||||
}
|
||||
|
||||
@@ -73,15 +73,19 @@ mod tests {
|
||||
fn create_file_link() {
|
||||
#[cfg(unix)]
|
||||
if let Err(e) = symlink("abbbc", "test_data/links/link-f") {
|
||||
if e.kind() != ErrorKind::AlreadyExists {
|
||||
panic!("Failed to create sym link: {:?}", e);
|
||||
}
|
||||
assert!(
|
||||
e.kind() == ErrorKind::AlreadyExists,
|
||||
"Failed to create sym link: {:?}",
|
||||
e
|
||||
);
|
||||
}
|
||||
#[cfg(windows)]
|
||||
if let Err(e) = symlink_file("abbbc", "test_data/links/link-f") {
|
||||
if e.kind() != ErrorKind::AlreadyExists {
|
||||
panic!("Failed to create sym link: {:?}", e);
|
||||
}
|
||||
assert!(
|
||||
e.kind() == ErrorKind::AlreadyExists,
|
||||
"Failed to create sym link: {:?}",
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -530,9 +530,9 @@ mod tests {
|
||||
#[test]
|
||||
fn not_has_side_effects_works() {
|
||||
let has_fx = NotMatcher::new(HasSideEffects);
|
||||
let hasnt_fx = NotMatcher::new(FalseMatcher);
|
||||
let has_no_fx = NotMatcher::new(FalseMatcher);
|
||||
assert!(has_fx.has_side_effects());
|
||||
assert!(!hasnt_fx.has_side_effects());
|
||||
assert!(!has_no_fx.has_side_effects());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -611,7 +611,7 @@ mod tests {
|
||||
let deps = FakeDependencies::new();
|
||||
|
||||
let matcher =
|
||||
build_top_level_matcher(&[arg, "-name", "doesntexist"], &mut config).unwrap();
|
||||
build_top_level_matcher(&[arg, "-name", "does_not_exist"], &mut config).unwrap();
|
||||
|
||||
assert!(matcher.matches(&abbbc_lower, &mut deps.new_matcher_io()));
|
||||
assert_eq!(
|
||||
@@ -652,7 +652,8 @@ mod tests {
|
||||
|
||||
config = Config::default();
|
||||
let matcher =
|
||||
build_top_level_matcher(&[arg, arg, "-name", "doesntexist"], &mut config).unwrap();
|
||||
build_top_level_matcher(&[arg, arg, "-name", "does_not_exist"], &mut config)
|
||||
.unwrap();
|
||||
|
||||
assert!(!matcher.matches(&abbbc_lower, &mut deps.new_matcher_io()));
|
||||
}
|
||||
|
||||
@@ -47,15 +47,19 @@ mod tests {
|
||||
fn create_file_link() {
|
||||
#[cfg(unix)]
|
||||
if let Err(e) = symlink("abbbc", "test_data/links/link-f") {
|
||||
if e.kind() != ErrorKind::AlreadyExists {
|
||||
panic!("Failed to create sym link: {:?}", e);
|
||||
}
|
||||
assert!(
|
||||
e.kind() == ErrorKind::AlreadyExists,
|
||||
"Failed to create sym link: {:?}",
|
||||
e
|
||||
);
|
||||
}
|
||||
#[cfg(windows)]
|
||||
if let Err(e) = symlink_file("abbbc", "test_data/links/link-f") {
|
||||
if e.kind() != ErrorKind::AlreadyExists {
|
||||
panic!("Failed to create sym link: {:?}", e);
|
||||
}
|
||||
assert!(
|
||||
e.kind() == ErrorKind::AlreadyExists,
|
||||
"Failed to create sym link: {:?}",
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -223,7 +223,7 @@ mod tests {
|
||||
PermMatcher::new("d=rwx,g=rx,o+r").expect_err("invalid category should fail");
|
||||
PermMatcher::new("u=dwx,g=rx,o+r").expect_err("invalid permission bit should fail");
|
||||
PermMatcher::new("u_rwx,g=rx,o+r")
|
||||
.expect_err("invalid category/permissoin separator should fail");
|
||||
.expect_err("invalid category/permission separator should fail");
|
||||
PermMatcher::new("77777777777777").expect_err("overflowing octal value should fail");
|
||||
|
||||
// FIXME: uucore::mode shouldn't accept this
|
||||
|
||||
+47
-29
@@ -396,7 +396,7 @@ fn format_directive<'entry>(
|
||||
// NOTE ON QUOTING:
|
||||
// GNU find's man page claims that several directives that print names (like
|
||||
// %f) are quoted like ls; however, I could not reproduce this at all in
|
||||
// pratice, thus the set of rules is undoubtedly very different (if this is
|
||||
// practice, thus the set of rules is undoubtedly very different (if this is
|
||||
// still done at all).
|
||||
|
||||
let res: Cow<'entry, str> = match directive {
|
||||
@@ -467,7 +467,7 @@ fn format_directive<'entry>(
|
||||
.into_iter()
|
||||
.find(|fs| fs.dev_id == dev_id)
|
||||
.map(|fs| fs.fs_type)
|
||||
.unwrap_or_else(|| "".to_owned())
|
||||
.unwrap_or_else(String::new)
|
||||
.into()
|
||||
}
|
||||
|
||||
@@ -946,52 +946,70 @@ mod tests {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
if let Err(e) = symlink("abbbc", "test_data/links/link-f") {
|
||||
if e.kind() != ErrorKind::AlreadyExists {
|
||||
panic!("Failed to create sym link: {:?}", e);
|
||||
}
|
||||
assert!(
|
||||
e.kind() == ErrorKind::AlreadyExists,
|
||||
"Failed to create sym link: {:?}",
|
||||
e
|
||||
);
|
||||
}
|
||||
if let Err(e) = symlink("subdir", "test_data/links/link-d") {
|
||||
if e.kind() != ErrorKind::AlreadyExists {
|
||||
panic!("Failed to create sym link: {:?}", e);
|
||||
}
|
||||
assert!(
|
||||
e.kind() == ErrorKind::AlreadyExists,
|
||||
"Failed to create sym link: {:?}",
|
||||
e
|
||||
);
|
||||
}
|
||||
if let Err(e) = symlink("missing", "test_data/links/link-missing") {
|
||||
if e.kind() != ErrorKind::AlreadyExists {
|
||||
panic!("Failed to create sym link: {:?}", e);
|
||||
}
|
||||
assert!(
|
||||
e.kind() == ErrorKind::AlreadyExists,
|
||||
"Failed to create sym link: {:?}",
|
||||
e
|
||||
);
|
||||
}
|
||||
if let Err(e) = symlink("abbbc/x", "test_data/links/link-notdir") {
|
||||
if e.kind() != ErrorKind::AlreadyExists {
|
||||
panic!("Failed to create sym link: {:?}", e);
|
||||
}
|
||||
assert!(
|
||||
e.kind() == ErrorKind::AlreadyExists,
|
||||
"Failed to create sym link: {:?}",
|
||||
e
|
||||
);
|
||||
}
|
||||
if let Err(e) = symlink("link-loop", "test_data/links/link-loop") {
|
||||
if e.kind() != ErrorKind::AlreadyExists {
|
||||
panic!("Failed to create sym link: {:?}", e);
|
||||
}
|
||||
assert!(
|
||||
e.kind() == ErrorKind::AlreadyExists,
|
||||
"Failed to create sym link: {:?}",
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
#[cfg(windows)]
|
||||
{
|
||||
if let Err(e) = symlink_file("abbbc", "test_data/links/link-f") {
|
||||
if e.kind() != ErrorKind::AlreadyExists {
|
||||
panic!("Failed to create sym link: {:?}", e);
|
||||
}
|
||||
assert!(
|
||||
e.kind() == ErrorKind::AlreadyExists,
|
||||
"Failed to create sym link: {:?}",
|
||||
e
|
||||
);
|
||||
}
|
||||
if let Err(e) = symlink_dir("subdir", "test_data/links/link-d") {
|
||||
if e.kind() != ErrorKind::AlreadyExists {
|
||||
panic!("Failed to create sym link: {:?}", e);
|
||||
}
|
||||
assert!(
|
||||
e.kind() == ErrorKind::AlreadyExists,
|
||||
"Failed to create sym link: {:?}",
|
||||
e
|
||||
);
|
||||
}
|
||||
if let Err(e) = symlink_file("missing", "test_data/links/link-missing") {
|
||||
if e.kind() != ErrorKind::AlreadyExists {
|
||||
panic!("Failed to create sym link: {:?}", e);
|
||||
}
|
||||
assert!(
|
||||
e.kind() == ErrorKind::AlreadyExists,
|
||||
"Failed to create sym link: {:?}",
|
||||
e
|
||||
);
|
||||
}
|
||||
if let Err(e) = symlink_file("abbbc/x", "test_data/links/link-notdir") {
|
||||
if e.kind() != ErrorKind::AlreadyExists {
|
||||
panic!("Failed to create sym link: {:?}", e);
|
||||
}
|
||||
assert!(
|
||||
e.kind() == ErrorKind::AlreadyExists,
|
||||
"Failed to create sym link: {:?}",
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -261,7 +261,7 @@ mod tests {
|
||||
deps.set_time(files_mtime - Duration::new(1_u64, 0));
|
||||
assert!(
|
||||
!exactly_one_day_matcher.matches(&file, &mut deps.new_matcher_io()),
|
||||
"future-modified file shouldn'1 match exactly 1 day old"
|
||||
"future-modified file shouldn't match exactly 1 day old"
|
||||
);
|
||||
assert!(
|
||||
!more_than_one_day_matcher.matches(&file, &mut deps.new_matcher_io()),
|
||||
@@ -311,14 +311,14 @@ mod tests {
|
||||
}
|
||||
|
||||
thread::sleep(Duration::from_secs(2));
|
||||
// read the file agaion - potentially changing accessed time
|
||||
// read the file again - potentially changing accessed time
|
||||
{
|
||||
let mut f = File::open(&foo_path).expect("open temp file");
|
||||
let _ = f.read(&mut buffer);
|
||||
}
|
||||
|
||||
// OK our modification time and creation time should definitely be different
|
||||
// and depending on our platform and file system, our accessed time migh be
|
||||
// and depending on our platform and file system, our accessed time might be
|
||||
// different too.
|
||||
|
||||
let file_info = get_dir_entry_for(&temp_dir.path().to_string_lossy(), "foo");
|
||||
|
||||
@@ -110,27 +110,35 @@ mod tests {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
if let Err(e) = symlink("abbbc", "test_data/links/link-f") {
|
||||
if e.kind() != ErrorKind::AlreadyExists {
|
||||
panic!("Failed to create sym link: {:?}", e);
|
||||
}
|
||||
assert!(
|
||||
e.kind() == ErrorKind::AlreadyExists,
|
||||
"Failed to create sym link: {:?}",
|
||||
e
|
||||
);
|
||||
}
|
||||
if let Err(e) = symlink("subdir", "test_data/links/link-d") {
|
||||
if e.kind() != ErrorKind::AlreadyExists {
|
||||
panic!("Failed to create sym link: {:?}", e);
|
||||
}
|
||||
assert!(
|
||||
e.kind() == ErrorKind::AlreadyExists,
|
||||
"Failed to create sym link: {:?}",
|
||||
e
|
||||
);
|
||||
}
|
||||
};
|
||||
#[cfg(windows)]
|
||||
let _ = {
|
||||
if let Err(e) = symlink_file("abbbc", "test_data/links/link-f") {
|
||||
if e.kind() != ErrorKind::AlreadyExists {
|
||||
panic!("Failed to create sym link: {:?}", e);
|
||||
}
|
||||
assert!(
|
||||
e.kind() == ErrorKind::AlreadyExists,
|
||||
"Failed to create sym link: {:?}",
|
||||
e
|
||||
);
|
||||
}
|
||||
if let Err(e) = symlink_dir("subdir", "test_data/links/link-d") {
|
||||
if e.kind() != ErrorKind::AlreadyExists {
|
||||
panic!("Failed to create sym link: {:?}", e);
|
||||
}
|
||||
assert!(
|
||||
e.kind() == ErrorKind::AlreadyExists,
|
||||
"Failed to create sym link: {:?}",
|
||||
e
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+10
-6
@@ -338,15 +338,19 @@ mod tests {
|
||||
fn create_file_link() {
|
||||
#[cfg(unix)]
|
||||
if let Err(e) = symlink("abbbc", "test_data/links/link-f") {
|
||||
if e.kind() != ErrorKind::AlreadyExists {
|
||||
panic!("Failed to create sym link: {:?}", e);
|
||||
}
|
||||
assert!(
|
||||
e.kind() == ErrorKind::AlreadyExists,
|
||||
"Failed to create sym link: {:?}",
|
||||
e
|
||||
);
|
||||
}
|
||||
#[cfg(windows)]
|
||||
if let Err(e) = symlink_file("abbbc", "test_data/links/link-f") {
|
||||
if e.kind() != ErrorKind::AlreadyExists {
|
||||
panic!("Failed to create sym link: {:?}", e);
|
||||
}
|
||||
assert!(
|
||||
e.kind() == ErrorKind::AlreadyExists,
|
||||
"Failed to create sym link: {:?}",
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,13 +78,14 @@ fn main() {
|
||||
usage();
|
||||
}
|
||||
let mut config = Config {
|
||||
destination_dir: if args[1] != "-" {
|
||||
Some(args[1].clone())
|
||||
} else {
|
||||
destination_dir: if args[1] == "-" {
|
||||
None
|
||||
} else {
|
||||
Some(args[1].clone())
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
for arg in &args[2..] {
|
||||
if arg.starts_with("--") {
|
||||
match arg.as_ref() {
|
||||
|
||||
+22
-14
@@ -1,6 +1,6 @@
|
||||
// Copyright 2021 Chad Williamson <chad@dahc.us>
|
||||
//
|
||||
// Use of this source code is governed by an MIT-syle license that can be
|
||||
// Use of this source code is governed by an MIT-style license that can be
|
||||
// found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
||||
|
||||
// This file contains integration tests for the find command.
|
||||
@@ -321,24 +321,32 @@ fn find_printf() {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
if let Err(e) = symlink_file("abbbc", "test_data/links/link-f") {
|
||||
if e.kind() != ErrorKind::AlreadyExists {
|
||||
panic!("Failed to create sym link: {:?}", e);
|
||||
}
|
||||
assert!(
|
||||
e.kind() == ErrorKind::AlreadyExists,
|
||||
"Failed to create sym link: {:?}",
|
||||
e
|
||||
);
|
||||
}
|
||||
if let Err(e) = symlink_dir("subdir", "test_data/links/link-d") {
|
||||
if e.kind() != ErrorKind::AlreadyExists {
|
||||
panic!("Failed to create sym link: {:?}", e);
|
||||
}
|
||||
assert!(
|
||||
e.kind() == ErrorKind::AlreadyExists,
|
||||
"Failed to create sym link: {:?}",
|
||||
e
|
||||
);
|
||||
}
|
||||
if let Err(e) = symlink_file("missing", "test_data/links/link-missing") {
|
||||
if e.kind() != ErrorKind::AlreadyExists {
|
||||
panic!("Failed to create sym link: {:?}", e);
|
||||
}
|
||||
assert!(
|
||||
e.kind() == ErrorKind::AlreadyExists,
|
||||
"Failed to create sym link: {:?}",
|
||||
e
|
||||
);
|
||||
}
|
||||
if let Err(e) = symlink_file("abbbc/x", "test_data/links/link-notdir") {
|
||||
if e.kind() != ErrorKind::AlreadyExists {
|
||||
panic!("Failed to create sym link: {:?}", e);
|
||||
}
|
||||
assert!(
|
||||
e.kind() == ErrorKind::AlreadyExists,
|
||||
"Failed to create sym link: {:?}",
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -476,7 +484,7 @@ fn find_mount_xdev() {
|
||||
|
||||
#[serial(working_dir)]
|
||||
#[test]
|
||||
fn find_accessable() {
|
||||
fn find_accessible() {
|
||||
Command::cargo_bin("find")
|
||||
.expect("found binary")
|
||||
.args(["test_data", "-readable"])
|
||||
|
||||
Reference in New Issue
Block a user