Skip to content

Commit e7b6250

Browse files
shengyfuCopilot
andcommitted
Qualify local indexed content search before starting server
Check both default and hidden local content/file results against proven filesystem scans and require local-only content diagnostics. Co-authored-by: Copilot App <[email protected]>
1 parent b767b93 commit e7b6250

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

‎scripts/qualification/qualify.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def git(*args):
233233
def cli(where, *args, timeout=30, expected=0):
234234
return run([binary, *args], cwd=where, env=env, timeout=timeout, expected=expected)
235235

236-
def parity(where, backend, *, hidden=False):
236+
def parity(where, backend, *, hidden=False, content_backend=None):
237237
for flags in (["--files"], ["-n", "--with-filename", "-F", "--", PATTERN]):
238238
options = ["--stats", "--sort", "path", "--color", "never"]
239239
if hidden:
@@ -243,7 +243,8 @@ def parity(where, backend, *, hidden=False):
243243
options.extend(["--glob", "!.git"])
244244
indexed = cli(where, *options, *flags, ".")
245245
scanned = cli(where, "--no-index", *options, *flags, ".")
246-
assert_parity(indexed, scanned, backend)
246+
expected_backend = content_backend if content_backend and flags[0] != "--files" else backend
247+
assert_parity(indexed, scanned, expected_backend)
247248
require(bool(indexed.stdout.strip()), "fixture must produce nonempty results")
248249

249250
git("init", "-q")
@@ -257,9 +258,8 @@ def parity(where, backend, *, hidden=False):
257258
(root / "ignored.txt").write_text(f"{PATTERN} ignored\n", encoding="utf-8")
258259

259260
cli(root, "index", ".")
260-
local_files = cli(root, "--files", "--stats", "--sort", "path", ".")
261-
assert_parity(local_files, cli(root, "--files", "--stats", "--no-index", "--sort", "path", "."),
262-
"(via local index)")
261+
parity(root, "(via local index)", content_backend="Search completed in ")
262+
parity(root, "(via local index)", content_backend="Search completed in ", hidden=True)
263263
with server(binary, root, ["--no-watch"], env, scratch / "ordinary.log") as child:
264264
wait_for(child, lambda _: marker_owned(root / ".tgrep/serve.json", child),
265265
"ordinary registration")

‎scripts/qualification/test_qualify.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ def test_command_failure_is_not_suppressed(self):
9696
with self.assertRaisesRegex(RuntimeError, "expected exit 0, got 2"):
9797
qualify.run([sys.executable, "-c", "raise SystemExit(2)"], cwd=Path.cwd())
9898

99+
def test_local_content_diagnostic_rejects_server_and_scan_backends(self):
100+
indexed = subprocess.CompletedProcess([], 0, "hit\n", "Search completed in 1ms: 1 matches")
101+
scanned = subprocess.CompletedProcess([], 0, "hit\n", "Brute-force search completed in 1ms")
102+
qualify.assert_parity(indexed, scanned, "Search completed in ")
103+
for diagnostic in ("1 matches in 1ms (via server)", "(via shared daemon v1)",
104+
"Brute-force search completed in 1ms"):
105+
indexed.stderr = diagnostic
106+
with self.assertRaisesRegex(RuntimeError, "expected backend"):
107+
qualify.assert_parity(indexed, scanned, "Search completed in ")
108+
99109
def test_server_log_is_read_only_after_process_exit_and_log_close(self):
100110
events = []
101111
stream = None

0 commit comments

Comments
 (0)