fix: preserve native model switches and bound project searches
This commit is contained in:
1 parent
db5e876f40
commit
e7d3080e0a
14 files changed
+371
-35
No files matched your search
@@ -20,6 +20,7 @@ import subprocess
|
||||
import pytest
|
||||
|
||||
from tools.file_operations import ShellFileOperations
|
||||
from tools.environments.local import LocalEnvironment
|
||||
|
||||
# Big enough to prove containment, small enough to keep the test fast.
|
||||
GIANT = 5 * 1024 * 1024 # 5MB single line
|
||||
@@ -27,22 +28,20 @@ GIANT = 5 * 1024 * 1024 # 5MB single line
|
||||
STDOUT_CEILING = 1 * 1024 * 1024
|
||||
|
||||
|
||||
class RecordingEnv:
|
||||
class RecordingEnv(LocalEnvironment):
|
||||
"""Local bash executor that records the largest stdout it returned."""
|
||||
|
||||
def __init__(self, cwd):
|
||||
self.cwd = cwd
|
||||
super().__init__(cwd=cwd)
|
||||
self.max_stdout = 0
|
||||
|
||||
def execute(self, command, timeout=60, **kwargs):
|
||||
proc = subprocess.run(
|
||||
["bash", "-c", command],
|
||||
capture_output=True, text=True, errors="replace",
|
||||
timeout=timeout + 30,
|
||||
)
|
||||
out = proc.stdout + (proc.stderr or "")
|
||||
# Use the application's shell selection/path handling. On Windows a
|
||||
# bare 'bash' may select WSL, whose filesystem is not the native one.
|
||||
result = super().execute(command, timeout=timeout + 30, **kwargs)
|
||||
out = result.get("output", "")
|
||||
self.max_stdout = max(self.max_stdout, len(out))
|
||||
return {"output": out, "returncode": proc.returncode}
|
||||
return result
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@@ -58,6 +57,8 @@ def _ops(giant_dir, engine):
|
||||
env = RecordingEnv(str(giant_dir))
|
||||
ops = ShellFileOperations(env)
|
||||
ops._has_command = lambda cmd: cmd == engine
|
||||
resolve = ops._resolve_command
|
||||
ops._resolve_command = lambda cmd: None if cmd == "rg" and engine != "rg" else resolve(cmd)
|
||||
return ops, env
|
||||
|
||||
|
||||
@@ -96,5 +97,5 @@ def test_line_cap_skipped_for_path_and_count_modes(giant_dir, engine, output_mod
|
||||
if output_mode == "files_only":
|
||||
assert {os.path.basename(f) for f in result.files} == {"trace.json", "small.py"}
|
||||
else:
|
||||
assert {os.path.basename(k) for k in result.counts} == {"trace.json", "small.py"}
|
||||
assert {os.path.basename(k) for k, count in result.counts.items() if count} == {"trace.json", "small.py"}
|
||||
assert env.max_stdout < STDOUT_CEILING
|
||||
Reference in new issue
Block a user