Skip to content

Commit

Permalink
Added tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
hanbings committed Jul 4, 2024
1 parent 0e17be1 commit f4bb537
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/find/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1221,4 +1221,35 @@ mod tests {

assert_eq!(rc, 0);
}

#[test]
#[cfg(unix)]
fn test_ignore_readdir_race() {
use crate::find::tests::FakeDependencies;

let deps = FakeDependencies::new();
let rc = find_main(
&["find", "./test_data/simple/subdir", "-ignore_readdir_race"],
&deps,
);

assert_eq!(rc, 0);
}

#[test]
fn test_noignore_readdir_race() {
use crate::find::tests::FakeDependencies;

let deps = FakeDependencies::new();
let rc = find_main(
&[
"find",
"./test_data/simple/subdir",
"-noignore_readdir_race",
],
&deps,
);

assert_eq!(rc, 0);
}
}
24 changes: 24 additions & 0 deletions tests/find_cmd_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -881,3 +881,27 @@ fn find_samefile() {
.stdout(predicate::str::is_empty())
.stderr(predicate::str::contains("not-exist-file"));
}

#[test]
#[serial(working_dir)]
fn find_ignore_readdir_race() {
Command::cargo_bin("find")
.expect("found binary")
.args(["./test_data/simple/subdir", "-ignore_readdir_race"])
.assert()
.success()
.stdout(predicate::str::contains("./test_data/simple/subdir"))
.stderr(predicate::str::is_empty());
}

#[test]
#[serial(working_dir)]
fn find_noignore_readdir_race() {
Command::cargo_bin("find")
.expect("found binary")
.args(["./test_data/simple/subdir", "-noignore_readdir_race"])
.assert()
.success()
.stdout(predicate::str::contains("./test_data/simple/subdir"))
.stderr(predicate::str::is_empty());
}

0 comments on commit f4bb537

Please sign in to comment.