mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-12 18:16:43 +00:00
Introduce DotNETUtil
* Apply in FSharpLanguageServer and CSharpLanguageServer * CSharpLanguageServer: Disabled auto-install of .NET (does not work reliably) and remove corresponding test * Remove TestFSharpLanguageServerSetup
This commit is contained in:
1 parent
9cd33aa503
commit
9800d4e98b
6 files changed
+161
-447
No files matched your search
@@ -1,14 +1,10 @@
|
||||
import os
|
||||
import tempfile
|
||||
import threading
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from solidlsp import SolidLanguageServer
|
||||
from solidlsp.language_servers.fsharp_language_server import FSharpLanguageServer
|
||||
from solidlsp.ls_config import Language
|
||||
from solidlsp.ls_utils import SymbolUtils
|
||||
from test.conftest import is_ci
|
||||
@@ -183,41 +179,3 @@ class TestFSharpLanguageServer:
|
||||
|
||||
# This is a successful test - FsAutoComplete is working with F# files
|
||||
assert True, "F# language server can handle files successfully"
|
||||
|
||||
|
||||
@pytest.mark.fsharp
|
||||
class TestFSharpLanguageServerSetup:
|
||||
"""Test F# language server setup and configuration."""
|
||||
|
||||
def test_runtime_dependency_setup_without_dotnet(self) -> None:
|
||||
"""Test that setup fails gracefully when .NET is not installed."""
|
||||
with patch("shutil.which", return_value=None):
|
||||
with pytest.raises(RuntimeError, match=r"\.NET SDK is not installed"):
|
||||
FSharpLanguageServer._setup_runtime_dependencies(Mock(), Mock())
|
||||
|
||||
def test_runtime_dependency_setup_with_dotnet(self) -> None:
|
||||
"""Test that setup works when .NET is available."""
|
||||
mock_config = Mock()
|
||||
mock_settings = Mock()
|
||||
|
||||
# Mock the ls_resources_dir to return a temp directory
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
with patch("shutil.which", return_value="/usr/bin/dotnet"):
|
||||
with patch.object(FSharpLanguageServer, "ls_resources_dir", return_value=temp_dir):
|
||||
with patch("subprocess.run") as mock_run:
|
||||
# Mock successful dotnet version check
|
||||
mock_run.return_value.stdout = "8.0.100"
|
||||
mock_run.return_value.returncode = 0
|
||||
|
||||
# Create a fake fsautocomplete executable
|
||||
fsharp_dir = os.path.join(temp_dir, "fsharp-lsp")
|
||||
os.makedirs(fsharp_dir, exist_ok=True)
|
||||
# Use .exe extension on Windows, matching production code
|
||||
exe_name = "fsautocomplete.exe" if os.name == "nt" else "fsautocomplete"
|
||||
fsautocomplete_path = os.path.join(fsharp_dir, exe_name)
|
||||
Path(fsautocomplete_path).touch()
|
||||
|
||||
result = FSharpLanguageServer._setup_runtime_dependencies(mock_config, mock_settings)
|
||||
|
||||
assert fsautocomplete_path in result
|
||||
assert "--adaptive-lsp-server-enabled --project-graph-enabled --use-fcs-transparent-compiler" in result
|
||||
Reference in new issue
Block a user