From 5548e538b149a07e7125e18632b48e616b1a2b1f Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Fri, 11 Jul 2025 12:59:47 -0400 Subject: [PATCH] tests: add test for filtering hidden files Note that this isn't a regression test. In particular, this didn't fail with ripgrep 14.1.1. I couldn't figure out how to turn what the OP gave me into a failing test. With #829 fixed, if the OP can provide a better regression test, it might make sense to re-investigate this. Closes #2711 --- tests/regression.rs | 58 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/tests/regression.rs b/tests/regression.rs index 95f10d47..46da1287 100644 --- a/tests/regression.rs +++ b/tests/regression.rs @@ -569,6 +569,64 @@ rgtest!(r807, |dir: Dir, mut cmd: TestCommand| { eqnice!(".a/c/file:test\n", cmd.arg("--hidden").arg("test").stdout()); }); +// See: https://github.com/BurntSushi/ripgrep/pull/2711 +// +// Note that this isn't a regression test. In particular, this didn't fail +// with ripgrep 14.1.1. I couldn't figure out how to turn what the OP gave me +// into a failing test. +rgtest!(r2711, |dir: Dir, _cmd: TestCommand| { + dir.create_dir("a/b"); + dir.create("a/.ignore", ".foo"); + dir.create("a/b/.foo", ""); + + { + let mut cmd = dir.command(); + eqnice!("a/.ignore\n", cmd.arg("--hidden").arg("--files").stdout()); + } + { + let mut cmd = dir.command(); + eqnice!( + "./a/.ignore\n", + cmd.arg("--hidden").arg("--files").arg("./").stdout() + ); + } + + { + let mut cmd = dir.command(); + eqnice!( + "a/.ignore\n", + cmd.arg("--hidden").arg("--files").arg("a").stdout() + ); + } + { + let mut cmd = dir.command(); + cmd.arg("--hidden").arg("--files").arg("a/b").assert_err(); + } + { + let mut cmd = dir.command(); + eqnice!( + "./a/.ignore\n", + cmd.arg("--hidden").arg("--files").arg("./a").stdout() + ); + } + + { + let mut cmd = dir.command(); + cmd.current_dir(dir.path().join("a")); + eqnice!(".ignore\n", cmd.arg("--hidden").arg("--files").stdout()); + } + { + let mut cmd = dir.command(); + cmd.current_dir(dir.path().join("a").join("b")); + cmd.arg("--hidden").arg("--files").assert_err(); + } + { + let mut cmd = dir.command(); + cmd.current_dir(dir.path().join("./a")); + eqnice!(".ignore\n", cmd.arg("--hidden").arg("--files").stdout()); + } +}); + // See: https://github.com/BurntSushi/ripgrep/issues/829 rgtest!(r829_original, |dir: Dir, _cmd: TestCommand| { dir.create_dir("a/b");