Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ 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"
uutests = { version = "0.0.30" }
ctor = "0.4.1"

[dev-dependencies]
assert_cmd = "2"
Expand Down
10 changes: 10 additions & 0 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,13 @@
// in one test but not another can cause a dead code warning.
#[allow(dead_code)]
pub mod test_helpers;
pub const TESTS_BINARY: &str = env!("CARGO_BIN_EXE_find");

// Use the ctor attribute to run this function before any tests
#[ctor::ctor]
fn init() {
unsafe {
// Necessary for uutests to be able to find the binary
std::env::set_var("UUTESTS_BINARY_PATH", TESTS_BINARY);
}
}
31 changes: 15 additions & 16 deletions tests/find_cmd_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ use std::fs::{self, File};
use std::io::{Read, Write};
use std::{env, io::ErrorKind};
use tempfile::Builder;
use uutests::util::TestScenario;
use uutests::{at_and_ucmd, new_ucmd, util_name};

#[cfg(unix)]
use std::os::unix::fs::symlink;
Expand All @@ -39,15 +41,14 @@ fn fix_up_regex_slashes(re: &str) -> String {
re.to_owned()
}

#[serial(working_dir)]
#[test]
fn no_args() {
Command::cargo_bin("find")
.expect("found binary")
.assert()
.success()
.stderr(predicate::str::is_empty())
.stdout(predicate::str::contains("test_data"));
let ts = TestScenario::new("find");
ts.cmd(env!("CARGO_BIN_EXE_find"))
.current_dir(env!("CARGO_MANIFEST_DIR"))
.succeeds()
.no_stderr()
.stdout_contains("test_data");
}

#[serial(working_dir)]
Expand Down Expand Up @@ -707,15 +708,13 @@ fn find_time() {

#[test]
fn expression_empty_parentheses() {
Command::cargo_bin("find")
.expect("found binary")
.args(["-true", "(", ")"])
.assert()
.failure()
.stderr(predicate::str::contains(
"empty parentheses are not allowed",
))
.stdout(predicate::str::is_empty());
let (_at, mut ucmd) = at_and_ucmd!();
ucmd.arg("-true")
.arg("(")
.arg(")")
.fails()
.stderr_contains("empty parentheses are not allowed")
.no_stdout();
}

#[test]
Expand Down
Loading