1 Commits

Author SHA1 Message Date
renovate[bot] 647db30e2b Add renovate.json 2023-03-24 09:30:13 +00:00
14 changed files with 86 additions and 130 deletions
-17
View File
@@ -1,17 +0,0 @@
repos:
- repo: local
hooks:
- id: rust-linting
name: Rust linting
description: Run cargo fmt on files included in the commit.
entry: cargo +nightly fmt --
pass_filenames: true
types: [file, rust]
language: system
- id: rust-clippy
name: Rust clippy
description: Run cargo clippy on files included in the commit.
entry: cargo +nightly clippy --workspace --all-targets --all-features --
pass_filenames: false
types: [file, rust]
language: system
Generated
+3 -21
View File
@@ -29,12 +29,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "anstyle"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23ea9e81bd02e310c216d080f6223c179012256e5151c41db88d12c88a1684d2"
[[package]]
name = "assert_cmd"
version = "2.0.8"
@@ -43,7 +37,7 @@ checksum = "9834fcc22e0874394a010230586367d4a3e9f11b560f469262678547e1d2575e"
dependencies = [
"bstr",
"doc-comment",
"predicates 2.1.5",
"predicates",
"predicates-core",
"predicates-tree",
"wait-timeout",
@@ -270,7 +264,7 @@ dependencies = [
[[package]]
name = "findutils"
version = "0.4.0"
version = "0.3.0"
dependencies = [
"assert_cmd",
"chrono",
@@ -280,7 +274,7 @@ dependencies = [
"nix 0.26.2",
"once_cell",
"onig",
"predicates 3.0.2",
"predicates",
"regex",
"serial_test",
"tempfile",
@@ -678,18 +672,6 @@ version = "2.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59230a63c37f3e18569bdb90e4a89cbf5bf8b06fea0b84e65ea10cc4df47addd"
dependencies = [
"difflib",
"itertools",
"predicates-core",
]
[[package]]
name = "predicates"
version = "3.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c575290b64d24745b6c57a12a31465f0a66f3a4799686a6921526a33b0797965"
dependencies = [
"anstyle",
"difflib",
"float-cmp",
"itertools",
+2 -2
View File
@@ -1,6 +1,6 @@
[package]
name = "findutils"
version = "0.4.0"
version = "0.3.0"
homepage = "https://github.com/uutils/findutils"
repository = "https://github.com/uutils/findutils"
edition = "2018"
@@ -23,7 +23,7 @@ uucore = { version = "0.0.12", features = ["entries", "fs", "fsext", "mode"] }
assert_cmd = "2"
filetime = "0.2"
nix = "0.26"
predicates = "3"
predicates = "2"
serial_test = "1.0"
tempfile = "3"
+6
View File
@@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
]
}
+1 -1
View File
@@ -6,7 +6,7 @@
fn main() {
let args = std::env::args().collect::<Vec<String>>();
let strs: Vec<&str> = args.iter().map(std::convert::AsRef::as_ref).collect();
let strs: Vec<&str> = args.iter().map(|s| s.as_ref()).collect();
let deps = findutils::find::StandardDependencies::new();
std::process::exit(findutils::find::find_main(&strs, &deps));
}
+6 -6
View File
@@ -87,7 +87,7 @@ mod tests {
let dir = get_dir_entry_for("test_data", "simple");
let deps = FakeDependencies::new();
let matcher = TypeMatcher::new("f").unwrap();
let matcher = TypeMatcher::new(&"f".to_string()).unwrap();
assert!(!matcher.matches(&dir, &mut deps.new_matcher_io()));
assert!(matcher.matches(&file, &mut deps.new_matcher_io()));
}
@@ -98,7 +98,7 @@ mod tests {
let dir = get_dir_entry_for("test_data", "simple");
let deps = FakeDependencies::new();
let matcher = TypeMatcher::new("d").unwrap();
let matcher = TypeMatcher::new(&"d".to_string()).unwrap();
assert!(matcher.matches(&dir, &mut deps.new_matcher_io()));
assert!(!matcher.matches(&file, &mut deps.new_matcher_io()));
}
@@ -108,7 +108,7 @@ mod tests {
#[test]
fn link_type_matcher() {
#[cfg(unix)]
{
let _ = {
if let Err(e) = symlink("abbbc", "test_data/links/link-f") {
if e.kind() != ErrorKind::AlreadyExists {
panic!("Failed to create sym link: {:?}", e);
@@ -140,7 +140,7 @@ mod tests {
let dir = get_dir_entry_for("test_data", "links");
let deps = FakeDependencies::new();
let matcher = TypeMatcher::new("l").unwrap();
let matcher = TypeMatcher::new(&"l".to_string()).unwrap();
assert!(!matcher.matches(&dir, &mut deps.new_matcher_io()));
assert!(!matcher.matches(&file, &mut deps.new_matcher_io()));
assert!(matcher.matches(&link_f, &mut deps.new_matcher_io()));
@@ -155,7 +155,7 @@ mod tests {
let deps = FakeDependencies::new();
for typ in &["b", "c", "p", "s"] {
let matcher = TypeMatcher::new(typ.as_ref()).unwrap();
let matcher = TypeMatcher::new(&typ.to_string()).unwrap();
assert!(!matcher.matches(&dir, &mut deps.new_matcher_io()));
assert!(!matcher.matches(&file, &mut deps.new_matcher_io()));
}
@@ -163,7 +163,7 @@ mod tests {
#[test]
fn cant_create_with_invalid_pattern() {
let result = TypeMatcher::new("xxx");
let result = TypeMatcher::new(&"xxx".to_string());
assert!(result.is_err());
}
}
+1 -1
View File
@@ -638,7 +638,7 @@ mod tests {
assert_eq!(rc, 0);
assert_eq!(
deps.get_output_as_string(),
new_dir.path().to_string_lossy().to_string() + "\n"
(&new_dir).path().to_string_lossy().to_string() + "\n"
);
// now do it the other way around, and nothing should be output
+2 -2
View File
@@ -37,7 +37,7 @@ fn open_file(destination_dir: &str) -> File {
loop {
file_number += 1;
let mut file_path: PathBuf = PathBuf::from(destination_dir);
file_path.push(format!("{file_number}.txt"));
file_path.push(format!("{}.txt", file_number));
if let Ok(f) = OpenOptions::new()
.write(true)
.create_new(true)
@@ -68,7 +68,7 @@ fn write_content(mut f: impl Write, config: &Config, args: &[String]) {
// the destination_dir we want to write to. Don't write either of those
// as they'll be non-deterministic.
for arg in &args[2..] {
writeln!(f, "{arg}").expect("failed to write to file");
writeln!(f, "{}", arg).expect("failed to write to file");
}
}
+1 -4
View File
@@ -7,9 +7,6 @@
fn main() {
let args = std::env::args().collect::<Vec<String>>();
std::process::exit(findutils::xargs::xargs_main(
&args
.iter()
.map(std::convert::AsRef::as_ref)
.collect::<Vec<&str>>(),
&args.iter().map(|s| s.as_ref()).collect::<Vec<&str>>(),
))
}
+2 -2
View File
@@ -14,7 +14,7 @@ use walkdir::{DirEntry, WalkDir};
use findutils::find::matchers::MatcherIO;
use findutils::find::Dependencies;
/// A copy of `find::tests::FakeDependencies`.
/// A copy of find::tests::FakeDependencies.
/// TODO: find out how to share #[cfg(test)] functions/structs between unit
/// and integration tests.
pub struct FakeDependencies {
@@ -81,7 +81,7 @@ pub fn fix_up_slashes(path: &str) -> String {
path.to_string()
}
/// A copy of `find::tests::FakeDependencies`.
/// A copy of find::tests::FakeDependencies.
/// TODO: find out how to share #[cfg(test)] functions/structs between unit
/// and integration tests.
pub fn get_dir_entry_for(directory: &str, filename: &str) -> DirEntry {
+3 -5
View File
@@ -4,7 +4,7 @@
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
/// ! This file contains what would be normally be unit tests for `find::matchers::exec`.
/// ! This file contains what would be normally be unit tests for find::matchers::exec.
/// ! But as the tests require running an external executable, they need to be run
/// ! as integration tests so we can ensure that our testing-commandline binary
/// ! has been built.
@@ -17,10 +17,8 @@ use std::io::Read;
use tempfile::Builder;
use walkdir::WalkDir;
use common::test_helpers::{
fix_up_slashes, get_dir_entry_for, path_to_testing_commandline, FakeDependencies,
};
use findutils::find::matchers::exec::SingleExecMatcher;
use common::test_helpers::*;
use findutils::find::matchers::exec::*;
use findutils::find::matchers::Matcher;
mod common;
+46 -56
View File
@@ -22,7 +22,7 @@ use std::os::unix::fs::symlink;
#[cfg(windows)]
use std::os::windows::fs::{symlink_dir, symlink_file};
use common::test_helpers::fix_up_slashes;
use common::test_helpers::*;
mod common;
@@ -54,7 +54,7 @@ fn no_args() {
fn two_matchers_both_match() {
Command::cargo_bin("find")
.expect("found binary")
.args(["-type", "d", "-name", "test_data"])
.args(&["-type", "d", "-name", "test_data"])
.assert()
.success()
.stderr(predicate::str::is_empty())
@@ -66,7 +66,7 @@ fn two_matchers_both_match() {
fn two_matchers_one_matches() {
Command::cargo_bin("find")
.expect("found binary")
.args(["-type", "f", "-name", "test_data"])
.args(&["-type", "f", "-name", "test_data"])
.assert()
.success()
.stderr(predicate::str::is_empty())
@@ -83,7 +83,7 @@ fn matcher_with_side_effects_at_end() {
Command::cargo_bin("find")
.expect("found binary")
.args([&temp_dir_path, "-name", "test", "-delete"])
.args(&[&temp_dir_path, "-name", "test", "-delete"])
.assert()
.success()
.stderr(predicate::str::is_empty())
@@ -103,7 +103,7 @@ fn matcher_with_side_effects_in_front() {
Command::cargo_bin("find")
.expect("found binary")
.args([&temp_dir_path, "-delete", "-name", "test"])
.args(&[&temp_dir_path, "-delete", "-name", "test"])
.assert()
.success()
.stderr(predicate::str::is_empty())
@@ -123,12 +123,12 @@ fn matcher_with_side_effects_in_front() {
fn delete_on_dot_dir() {
let temp_dir = Builder::new().prefix("example").tempdir().unwrap();
let original_dir = env::current_dir().unwrap();
env::set_current_dir(temp_dir.path()).expect("working dir changed");
env::set_current_dir(&temp_dir.path()).expect("working dir changed");
// "." should be matched (confirmed by the print), but not deleted.
Command::cargo_bin("find")
.expect("found binary")
.args([".", "-delete", "-print"])
.args(&[".", "-delete", "-print"])
.assert()
.success()
.stderr(predicate::str::is_empty())
@@ -145,11 +145,11 @@ fn regex_types() {
let temp_dir_path = temp_dir.path().to_string_lossy();
let test_file = temp_dir.path().join("teeest");
File::create(test_file).expect("created test file");
File::create(&test_file).expect("created test file");
Command::cargo_bin("find")
.expect("found binary")
.args([&temp_dir_path, "-regex", &fix_up_regex_slashes(".*/tE+st")])
.args(&[&temp_dir_path, "-regex", &fix_up_regex_slashes(".*/tE+st")])
.assert()
.success()
.stderr(predicate::str::is_empty())
@@ -157,7 +157,7 @@ fn regex_types() {
Command::cargo_bin("find")
.expect("found binary")
.args([&temp_dir_path, "-iregex", &fix_up_regex_slashes(".*/tE+st")])
.args(&[&temp_dir_path, "-iregex", &fix_up_regex_slashes(".*/tE+st")])
.assert()
.success()
.stderr(predicate::str::is_empty())
@@ -165,7 +165,7 @@ fn regex_types() {
Command::cargo_bin("find")
.expect("found binary")
.args([
.args(&[
&temp_dir_path,
"-regextype",
"posix-basic",
@@ -179,7 +179,7 @@ fn regex_types() {
Command::cargo_bin("find")
.expect("found binary")
.args([
.args(&[
&temp_dir_path,
"-regextype",
"posix-extended",
@@ -193,7 +193,7 @@ fn regex_types() {
Command::cargo_bin("find")
.expect("found binary")
.args([
.args(&[
&temp_dir_path,
"-regextype",
"ed",
@@ -207,7 +207,7 @@ fn regex_types() {
Command::cargo_bin("find")
.expect("found binary")
.args([
.args(&[
&temp_dir_path,
"-regextype",
"sed",
@@ -227,18 +227,18 @@ fn empty_files() {
Command::cargo_bin("find")
.expect("found binary")
.args([&temp_dir_path, "-empty"])
.args(&[&temp_dir_path, "-empty"])
.assert()
.success()
.stderr(predicate::str::is_empty())
.stdout(fix_up_slashes(&format!("{temp_dir_path}\n")));
.stdout(fix_up_slashes(&format!("{}\n", temp_dir_path)));
let test_file_path = temp_dir.path().join("test");
let mut test_file = File::create(&test_file_path).unwrap();
Command::cargo_bin("find")
.expect("found binary")
.args([&temp_dir_path, "-empty"])
.args(&[&temp_dir_path, "-empty"])
.assert()
.success()
.stderr(predicate::str::is_empty())
@@ -252,7 +252,7 @@ fn empty_files() {
Command::cargo_bin("find")
.expect("found binary")
.args([&temp_dir_path, "-empty", "-sorted"])
.args(&[&temp_dir_path, "-empty", "-sorted"])
.assert()
.success()
.stderr(predicate::str::is_empty())
@@ -267,7 +267,7 @@ fn empty_files() {
Command::cargo_bin("find")
.expect("found binary")
.args([&temp_dir_path, "-empty", "-sorted"])
.args(&[&temp_dir_path, "-empty", "-sorted"])
.assert()
.success()
.stderr(predicate::str::is_empty())
@@ -283,39 +283,29 @@ fn find_printf() {
#[cfg(unix)]
{
if let Err(e) = symlink("abbbc", "test_data/links/link-f") {
assert!(
e.kind() == ErrorKind::AlreadyExists,
"Failed to create sym link: {:?}",
e
);
if e.kind() != ErrorKind::AlreadyExists {
panic!("Failed to create sym link: {:?}", e);
}
}
if let Err(e) = symlink("subdir", "test_data/links/link-d") {
assert!(
e.kind() == ErrorKind::AlreadyExists,
"Failed to create sym link: {:?}",
e
);
if e.kind() != ErrorKind::AlreadyExists {
panic!("Failed to create sym link: {:?}", e);
}
}
if let Err(e) = symlink("missing", "test_data/links/link-missing") {
assert!(
e.kind() == ErrorKind::AlreadyExists,
"Failed to create sym link: {:?}",
e
);
if e.kind() != ErrorKind::AlreadyExists {
panic!("Failed to create sym link: {:?}", e);
}
}
if let Err(e) = symlink("abbbc/x", "test_data/links/link-notdir") {
assert!(
e.kind() == ErrorKind::AlreadyExists,
"Failed to create sym link: {:?}",
e
);
if e.kind() != ErrorKind::AlreadyExists {
panic!("Failed to create sym link: {:?}", e);
}
}
if let Err(e) = symlink("link-loop", "test_data/links/link-loop") {
assert!(
e.kind() == ErrorKind::AlreadyExists,
"Failed to create sym link: {:?}",
e
);
if e.kind() != ErrorKind::AlreadyExists {
panic!("Failed to create sym link: {:?}", e);
}
}
}
#[cfg(windows)]
@@ -344,7 +334,7 @@ fn find_printf() {
Command::cargo_bin("find")
.expect("found binary")
.args([
.args(&[
&fix_up_slashes("./test_data/simple"),
"-sorted",
"-printf",
@@ -366,7 +356,7 @@ fn find_printf() {
Command::cargo_bin("find")
.expect("found binary")
.args([
.args(&[
&fix_up_slashes("./test_data/links"),
"-sorted",
"-type",
@@ -400,19 +390,19 @@ fn find_printf() {
fn find_perm() {
Command::cargo_bin("find")
.expect("found binary")
.args(["-perm", "+rwx"])
.args(&["-perm", "+rwx"])
.assert()
.success();
Command::cargo_bin("find")
.expect("found binary")
.args(["-perm", "u+rwX"])
.args(&["-perm", "u+rwX"])
.assert()
.success();
Command::cargo_bin("find")
.expect("found binary")
.args(["-perm", "u=g"])
.args(&["-perm", "u=g"])
.assert()
.success();
}
@@ -431,7 +421,7 @@ fn find_inum() {
Command::cargo_bin("find")
.expect("found binary")
.args(["test_data", "-inum", &inum])
.args(&["test_data", "-inum", &inum])
.assert()
.success()
.stderr(predicate::str::is_empty())
@@ -444,7 +434,7 @@ fn find_inum() {
fn find_links() {
Command::cargo_bin("find")
.expect("found binary")
.args(["test_data", "-links", "1"])
.args(&["test_data", "-links", "1"])
.assert()
.success()
.stderr(predicate::str::is_empty())
@@ -459,7 +449,7 @@ fn find_mount_xdev() {
Command::cargo_bin("find")
.expect("found binary")
.args(["test_data", "-mount"])
.args(&["test_data", "-mount"])
.assert()
.success()
.stderr(predicate::str::is_empty())
@@ -467,7 +457,7 @@ fn find_mount_xdev() {
Command::cargo_bin("find")
.expect("found binary")
.args(["test_data", "-xdev"])
.args(&["test_data", "-xdev"])
.assert()
.success()
.stderr(predicate::str::is_empty())
@@ -479,7 +469,7 @@ fn find_mount_xdev() {
fn find_accessable() {
Command::cargo_bin("find")
.expect("found binary")
.args(["test_data", "-readable"])
.args(&["test_data", "-readable"])
.assert()
.success()
.stderr(predicate::str::is_empty())
@@ -487,7 +477,7 @@ fn find_accessable() {
Command::cargo_bin("find")
.expect("found binary")
.args(["test_data", "-writable"])
.args(&["test_data", "-writable"])
.assert()
.success()
.stderr(predicate::str::is_empty())
@@ -496,7 +486,7 @@ fn find_accessable() {
#[cfg(unix)]
Command::cargo_bin("find")
.expect("found binary")
.args(["test_data", "-executable"])
.args(&["test_data", "-executable"])
.assert()
.success()
.stderr(predicate::str::is_empty())
+2 -2
View File
@@ -4,7 +4,7 @@
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
/// ! This file contains what would be normally be unit tests for `find::find_main`
/// ! This file contains what would be normally be unit tests for find::find_main
/// ! related to -exec[dir] and ok[dir] clauses.
/// ! But as the tests require running an external executable, they need to be run
/// ! as integration tests so we can ensure that our testing-commandline binary
@@ -18,7 +18,7 @@ use std::fs::File;
use std::io::Read;
use tempfile::Builder;
use common::test_helpers::{fix_up_slashes, path_to_testing_commandline, FakeDependencies};
use common::test_helpers::*;
use findutils::find::find_main;
mod common;
+11 -11
View File
@@ -14,7 +14,7 @@ use std::io::{Seek, SeekFrom, Write};
use assert_cmd::Command;
use predicates::prelude::*;
use common::test_helpers::path_to_testing_commandline;
use common::test_helpers::*;
mod common;
@@ -33,7 +33,7 @@ fn xargs_basics() {
fn xargs_null() {
Command::cargo_bin("xargs")
.expect("found binary")
.args(["-0n1"])
.args(&["-0n1"])
.write_stdin("ab c\0d\tef\0")
.assert()
.success()
@@ -45,7 +45,7 @@ fn xargs_null() {
fn xargs_delim() {
Command::cargo_bin("xargs")
.expect("found binary")
.args(["-d1"])
.args(&["-d1"])
.write_stdin("ab1cd1ef")
.assert()
.success()
@@ -54,7 +54,7 @@ fn xargs_delim() {
Command::cargo_bin("xargs")
.expect("found binary")
.args(["-d\\t", "-n1"])
.args(&["-d\\t", "-n1"])
.write_stdin("a\nb\td e\tfg")
.assert()
.success()
@@ -63,7 +63,7 @@ fn xargs_delim() {
Command::cargo_bin("xargs")
.expect("found binary")
.args(["-dabc"])
.args(&["-dabc"])
.assert()
.failure()
.code(1)
@@ -75,7 +75,7 @@ fn xargs_delim() {
fn xargs_null_conflict() {
Command::cargo_bin("xargs")
.expect("found binary")
.args(["-d\t", "-0n1"])
.args(&["-d\t", "-0n1"])
.write_stdin("ab c\0d\tef\0")
.assert()
.success()
@@ -95,7 +95,7 @@ fn xargs_if_empty() {
Command::cargo_bin("xargs")
.expect("found binary")
.args(["--no-run-if-empty"])
.args(&["--no-run-if-empty"])
.assert()
.success()
.stderr(predicate::str::is_empty())
@@ -256,7 +256,7 @@ fn xargs_exec_stdin_open() {
fn xargs_exec_failure() {
Command::cargo_bin("xargs")
.expect("found binary")
.args([
.args(&[
"-n1",
&path_to_testing_commandline(),
"-",
@@ -278,7 +278,7 @@ fn xargs_exec_failure() {
fn xargs_exec_urgent_failure() {
Command::cargo_bin("xargs")
.expect("found binary")
.args([
.args(&[
"-n1",
&path_to_testing_commandline(),
"-",
@@ -298,7 +298,7 @@ fn xargs_exec_urgent_failure() {
fn xargs_exec_with_signal() {
Command::cargo_bin("xargs")
.expect("found binary")
.args([
.args(&[
"-n1",
&path_to_testing_commandline(),
"-",
@@ -317,7 +317,7 @@ fn xargs_exec_with_signal() {
fn xargs_exec_not_found() {
Command::cargo_bin("xargs")
.expect("found binary")
.args(["this-file-does-not-exist"])
.args(&["this-file-does-not-exist"])
.assert()
.failure()
.code(127)