Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
417 changes: 376 additions & 41 deletions Cargo.lock

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ authors = ["uutils developers"]

[dependencies]
chrono = "0.4.40"
clap = "4.5"
clap = { version = "4.5", features = ["env"] }
faccess = "0.2.4"
walkdir = "2.5"
regex = "1.11"
onig = { version = "6.4", default-features = false }
uucore = { version = "0.0.30", features = ["entries", "fs", "fsext", "mode"] }
nix = { version = "0.29", features = ["fs", "user"] }
argmax = "0.3.1"
itertools = "0.14.0"
quick-error = "2.0.1"
Comment thread
Qelxiros marked this conversation as resolved.
Outdated
uutests = "0.0.30"
Comment thread
Qelxiros marked this conversation as resolved.
Outdated

[dev-dependencies]
assert_cmd = "2"
Expand All @@ -33,6 +36,14 @@ pretty_assertions = "1.4.1"
name = "find"
path = "src/find/main.rs"

[[bin]]
name = "locate"
path = "src/locate/main.rs"

[[bin]]
name = "updatedb"
path = "src/updatedb/main.rs"

[[bin]]
name = "xargs"
path = "src/xargs/main.rs"
Expand Down
79 changes: 79 additions & 0 deletions src/db_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Copyright 2017 Google Inc.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Copyright 2017 Google Inc.

//
Comment thread
Qelxiros marked this conversation as resolved.
Outdated
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.

#[cfg(test)]
mod tests {
use std::process::Command;

use assert_cmd::{assert::OutputAssertExt, cargo::CommandCargoExt};

#[test]
fn test_locate_no_matches() {
Command::cargo_bin("locate")
.expect("couldn't find locate binary")
.args(["usr", "--database=test_data_db"])
.assert()
.failure();
}

#[test]
fn test_locate_match() {
Command::cargo_bin("locate")
.expect("couldn't find locate binary")
.args(["test_data", "--database=test_data_db"])
.assert()
.success();
}

#[test]
fn test_locate_no_matches_basename() {
Command::cargo_bin("locate")
.expect("couldn't find locate binary")
.args([
"test_data1234567890",
"--basename",
"--database=test_data_db",
])
.assert()
.failure();
}

#[test]
fn test_locate_match_basename() {
Command::cargo_bin("locate")
.expect("couldn't find locate binary")
.args(["abbbc", "--basename", "--database=test_data_db"])
.assert()
.success();
}

#[test]
fn test_locate_existing() {
Command::cargo_bin("locate")
.expect("couldn't find locate binary")
.args(["abbbc", "--existing", "--database=test_data_db"])
.assert()
.success();
}

#[test]
fn test_locate_non_existing() {
Command::cargo_bin("locate")
.expect("couldn't find locate binary")
.args(["abbbc", "--non-existing", "--database=test_data_db"])
.assert()
.failure();
}

#[test]
fn test_updatedb() {
Command::cargo_bin("updatedb")
.expect("couldn't find updatedb binary")
.args(["--localpaths=./test_data", "--output=/dev/null"])
.assert()
.success();
}
}
1 change: 1 addition & 0 deletions src/find/matchers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ use std::{
use super::{Config, Dependencies};

pub use entry::{FileType, WalkEntry, WalkError};
pub use regex::RegexType;

/// Symlink following mode.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.

mod db_tests;
pub mod find;
pub mod locate;
pub mod updatedb;
pub mod xargs;
11 changes: 11 additions & 0 deletions src/locate/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2017 Google Inc.
Comment thread
Qelxiros marked this conversation as resolved.
Outdated
//
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.

fn main() {
Comment thread
Qelxiros marked this conversation as resolved.
let args = std::env::args().collect::<Vec<String>>();
let strs: Vec<&str> = args.iter().map(std::convert::AsRef::as_ref).collect();
std::process::exit(findutils::locate::locate_main(strs.as_slice()));
}
Loading
Loading