Co-authored-by: Clément Drouin <clement.drouin@mistral.ai>
Co-authored-by: Clément Sirieix <clement.sirieix@mistral.ai>
Co-authored-by: Guillaume LE GOFF <guillaume.lgf@gmail.com>
Co-authored-by: Mathias Gesbert <mathias.gesbert@mistral.ai>
Co-authored-by: Michel Thomazo <51709227+michelTho@users.noreply.github.com>
Co-authored-by: Pierre Rossinès <pierre.rossines@mistral.ai>
Co-authored-by: Vincent G <10739306+VinceOPS@users.noreply.github.com>
Co-authored-by: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
Quentin 2026-05-25 16:05:26 +02:00 committed by GitHub
parent f71bfd3b8c
commit adb1ca74ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
202 changed files with 5828 additions and 1968 deletions

View file

@ -118,6 +118,61 @@ class TestAcpWriteFileExecution:
assert params["path"] == str(test_file)
assert params["content"] == "New content"
@pytest.mark.asyncio
@pytest.mark.parametrize("input_newline", ["\r\n", "\r", "\n"])
@pytest.mark.parametrize("os_newline", ["\n", "\r\n"])
async def test_run_writes_with_os_linesep(
self,
input_newline: str,
os_newline: str,
mock_client: MockClient,
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
) -> None:
monkeypatch.chdir(tmp_path)
monkeypatch.setattr("vibe.acp.tools.builtins.write_file.os.linesep", os_newline)
tool = WriteFile(
config_getter=lambda: WriteFileConfig(),
state=AcpWriteFileState.model_construct(
client=mock_client, session_id="test_session"
),
)
test_file = tmp_path / "test.txt"
content = input_newline.join(["line 1", "line 2", "line 3"])
args = WriteFileArgs(path=str(test_file), content=content)
await collect_result(tool.run(args))
assert mock_client._last_write_params["content"] == os_newline.join([
"line 1",
"line 2",
"line 3",
])
@pytest.mark.asyncio
async def test_run_normalizes_mixed_newlines(
self, mock_client: MockClient, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
monkeypatch.chdir(tmp_path)
monkeypatch.setattr("vibe.acp.tools.builtins.write_file.os.linesep", "\n")
tool = WriteFile(
config_getter=lambda: WriteFileConfig(),
state=AcpWriteFileState.model_construct(
client=mock_client, session_id="test_session"
),
)
test_file = tmp_path / "test.txt"
args = WriteFileArgs(
path=str(test_file), content="line 1\r\nline 2\nline 3\rline 4"
)
await collect_result(tool.run(args))
assert (
mock_client._last_write_params["content"]
== "line 1\nline 2\nline 3\nline 4"
)
@pytest.mark.asyncio
async def test_run_write_error(
self, mock_client: MockClient, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
@ -209,6 +264,24 @@ class TestAcpWriteFileSessionUpdates:
assert len(update.locations) == 1
assert update.locations[0].path == str(Path("/tmp/test.txt").resolve())
def test_tool_call_session_update_passes_content_through(
self, monkeypatch: pytest.MonkeyPatch
) -> None:
monkeypatch.setattr("vibe.acp.tools.builtins.write_file.os.linesep", "\r\n")
content = "line 1\r\nline 2\nline 3\rline 4"
event = ToolCallEvent(
tool_name="write_file",
tool_call_id="test_call_123",
args=WriteFileArgs(path="/tmp/test.txt", content=content),
tool_class=WriteFile,
)
update = WriteFile.tool_call_session_update(event)
assert update is not None
assert update.content is not None
assert isinstance(update.content, list)
assert update.content[0].new_text == content
def test_tool_call_session_update_invalid_args(self) -> None:
from vibe.core.types import FunctionCall, ToolCall