Test that an operand after double dash alone reaches the file
CI / tests (pull_request) Successful in 2m24s

This commit is contained in:
2026-11-13 22:04:22 +01:00
parent 26f5ccde78
commit 52e1f7f315
+8 -4
View File
@@ -491,10 +491,14 @@ class EnvFileRead(unittest.TestCase):
def test_a_folder_that_starts_with_a_dash_is_searched_after_double_dash(self):
write_config(self.home, self.home / "code" / "other")
config = self.home / ".claude-projects" / "other" / "config.toml"
config.write_text(config.read_text() + 'env-file = "~/-d/x.env"\n')
(self.home / "-d").mkdir()
(self.home / "-d" / "x.env").write_text("TOKEN=z\n")
self.assertEqual(self.breached("Bash", {"command": "rg TOKEN -- -d"}, str(self.home)), ["env-file-read"])
config.write_text(config.read_text() + 'env-file = "~/real/x.env"\n')
(self.home / "real").mkdir()
(self.home / "real" / "x.env").write_text("TOKEN=z\n")
(self.home / "sub").mkdir()
# The link keeps the directory itself clear of the file, so only the operand -d reaches it.
(self.home / "sub" / "-d").symlink_to(self.home / "real")
self.assertEqual(self.breached("Bash", {"command": "rg TOKEN -- -d"}, f"{self.home}/sub"), ["env-file-read"])
self.assertEqual(self.breached("Bash", {"command": "rg TOKEN"}, f"{self.home}/sub"), [])
def test_rg_and_ag_skip_hidden_files_but_grep_does_not(self):
for command, expected in (("rg TOKEN ~/.claude", []), ("ag TOKEN ~/.claude", []), ("grep -r TOKEN ~/.claude", ["env-file-read"]), ("rg --hidden TOKEN ~/.claude", ["env-file-read"]), ("rg -. TOKEN ~/.claude", ["env-file-read"]), ("rg -uu TOKEN ~/.claude", ["env-file-read"]), ("rg -u -u TOKEN ~/.claude", ["env-file-read"]), ("rg --unrestricted TOKEN ~/.claude", []), ("rg --unrestricted --unrestricted TOKEN ~/.claude", ["env-file-read"]), ("ag --hidden TOKEN ~/.claude", ["env-file-read"]), ("ag -u TOKEN ~/.claude", ["env-file-read"])):