mirror of
https://github.com/uutils/grep.git
synced 2026-06-10 16:15:11 -07:00
test: cover strip_dot_prefix for implicit-cwd recursive search
This commit is contained in:
@@ -903,6 +903,25 @@ fn recursive_no_file_defaults_to_cwd_not_stdin() {
|
||||
.stdout_contains("a.txt");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn recursive_implicit_cwd_strips_dot_prefix() {
|
||||
// `-r` with no path argument searches the implicit ".", so reported paths
|
||||
// come back as "./only.txt" (or ".\\only.txt" on Windows). GNU strips that
|
||||
// leading prefix; `strip_dot_prefix` in src/searcher.rs must do the same.
|
||||
// A single file keeps the output deterministic and lets us assert the exact
|
||||
// line, which `stdout_contains` in `recursive_no_file_defaults_to_cwd_not_stdin`
|
||||
// cannot (it would also pass with a leaked "./" prefix).
|
||||
let (scene, _) = ucmd();
|
||||
scene.fixtures.mkdir_all("flat");
|
||||
scene.fixtures.write("flat/only.txt", "grep me\n");
|
||||
|
||||
let mut c = scene.cmd(env!("CARGO_BIN_EXE_grep"));
|
||||
c.current_dir(scene.fixtures.plus("flat"))
|
||||
.args(&["-r", "grep"])
|
||||
.succeeds()
|
||||
.stdout_is("only.txt:grep me\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn recursive_with_include_exclude() {
|
||||
let (scene, _) = ucmd();
|
||||
|
||||
Reference in New Issue
Block a user