mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-14 00:16:57 +00:00
Improve handling of languages for which tests are disabled
adding Clojure to list of disabled languages (tests appear to fail randomly)
This commit is contained in:
1 parent
72d5f688d4
commit
7de68c09c3
7 files changed
+67
-21
No files matched your search
+1
-1
@@ -121,7 +121,7 @@ PYDEVD_DISABLE_FILE_VALIDATION = "1"
|
||||
# Uses PYTEST_MARKERS env var for default markers
|
||||
# For custom markers, one can either adjust the env var or just use -m option in the command line,
|
||||
# as the second -m option will override the first one.
|
||||
test = "pytest test -vv -m \"${PYTEST_MARKERS:-not rust and not erlang}\""
|
||||
test = "pytest test -vv"
|
||||
_black_check = "black --check src scripts test"
|
||||
_ruff_check = "ruff check src scripts test"
|
||||
_black_format = "black src scripts test"
|
||||
|
||||
+49
-2
@@ -15,6 +15,8 @@ from solidlsp.ls import SolidLanguageServer
|
||||
from solidlsp.ls_config import Language, LanguageServerConfig
|
||||
from solidlsp.settings import SolidLSPSettings
|
||||
|
||||
from .solidlsp.clojure import is_clojure_cli_available
|
||||
|
||||
configure(level=logging.ERROR)
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -171,6 +173,51 @@ def project(request: LanguageParamRequest):
|
||||
|
||||
|
||||
is_ci = os.getenv("CI") == "true" or os.getenv("GITHUB_ACTIONS") == "true"
|
||||
"""
|
||||
Flag indicating whether the tests are running in the GitHub CI environment.
|
||||
"""
|
||||
|
||||
# We skip Java tests in CI if not on Windows (hangs on Ubuntu for unknown reasons; testing on Windows is sufficient)
|
||||
java_tests_enabled = not is_ci or platform.system() == "Windows"
|
||||
|
||||
def _determine_disabled_languages() -> list[Language]:
|
||||
"""
|
||||
Determine which language tests should be disabled (based on the environment)
|
||||
|
||||
:return: the list of disabled languages
|
||||
"""
|
||||
result: list[Language] = []
|
||||
|
||||
# We skip Java tests in CI if not on Windows (hangs on Ubuntu for unknown reasons; testing on Windows is sufficient)
|
||||
java_tests_enabled = not is_ci or platform.system() == "Windows"
|
||||
if not java_tests_enabled:
|
||||
result.append(Language.JAVA)
|
||||
|
||||
clojure_tests_enabled = not is_ci and is_clojure_cli_available()
|
||||
if not clojure_tests_enabled:
|
||||
result.append(Language.CLOJURE)
|
||||
|
||||
al_tests_enabled = not is_ci
|
||||
if not al_tests_enabled:
|
||||
result.append(Language.AL)
|
||||
|
||||
rust_tests_enabled = not is_ci
|
||||
if not rust_tests_enabled:
|
||||
result.append(Language.RUST)
|
||||
|
||||
erlang_tests_enabled = not is_ci
|
||||
if not erlang_tests_enabled:
|
||||
result.append(Language.ERLANG)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
_disabled_languages = _determine_disabled_languages()
|
||||
|
||||
|
||||
def language_tests_enabled(language: Language) -> bool:
|
||||
"""
|
||||
Check if tests for the given language are enabled in the current environment.
|
||||
|
||||
:param language: the language to check
|
||||
:return: True if tests for the language are enabled, False otherwise
|
||||
"""
|
||||
return language not in _disabled_languages
|
||||
@@ -5,13 +5,13 @@ import time
|
||||
|
||||
import pytest
|
||||
|
||||
import test.solidlsp.clojure as clj
|
||||
from serena.agent import SerenaAgent
|
||||
from serena.config.serena_config import ProjectConfig, RegisteredProject, SerenaConfig
|
||||
from serena.project import Project
|
||||
from serena.tools import FindReferencingSymbolsTool, FindSymbolTool
|
||||
from solidlsp.ls_config import Language
|
||||
from test.conftest import get_repo_path, java_tests_enabled
|
||||
from test.conftest import get_repo_path, language_tests_enabled
|
||||
from test.solidlsp import clojure as clj
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -56,8 +56,8 @@ def serena_config():
|
||||
@pytest.fixture
|
||||
def serena_agent(request: pytest.FixtureRequest, serena_config):
|
||||
language = Language(request.param)
|
||||
if language == Language.JAVA and not java_tests_enabled:
|
||||
pytest.skip("Java tests are not enabled")
|
||||
if not language_tests_enabled(language):
|
||||
pytest.skip(f"Tests for language {language} are not enabled.")
|
||||
|
||||
project_name = f"test_repo_{language}"
|
||||
|
||||
@@ -75,13 +75,7 @@ class TestSerenaAgent:
|
||||
pytest.param(Language.RUST, "add", "Function", "lib.rs", marks=pytest.mark.rust),
|
||||
pytest.param(Language.TYPESCRIPT, "DemoClass", "Class", "index.ts", marks=pytest.mark.typescript),
|
||||
pytest.param(Language.PHP, "helperFunction", "Function", "helper.php", marks=pytest.mark.php),
|
||||
pytest.param(
|
||||
Language.CLOJURE,
|
||||
"greet",
|
||||
"Function",
|
||||
clj.CORE_PATH,
|
||||
marks=[pytest.mark.clojure, pytest.mark.skipif(clj.CLI_FAIL, reason=f"Clojure CLI not available: {clj.CLI_FAIL}")],
|
||||
),
|
||||
pytest.param(Language.CLOJURE, "greet", "Function", clj.CORE_PATH, marks=pytest.mark.clojure),
|
||||
pytest.param(Language.CSHARP, "Calculator", "Class", "Program.cs", marks=pytest.mark.csharp),
|
||||
],
|
||||
indirect=["serena_agent"],
|
||||
@@ -130,7 +124,7 @@ class TestSerenaAgent:
|
||||
"multiply",
|
||||
clj.CORE_PATH,
|
||||
clj.UTILS_PATH,
|
||||
marks=[pytest.mark.clojure, pytest.mark.skipif(clj.CLI_FAIL, reason=f"Clojure CLI not available: {clj.CLI_FAIL}")],
|
||||
marks=pytest.mark.clojure,
|
||||
),
|
||||
pytest.param(Language.CSHARP, "Calculator", "Program.cs", "Program.cs", marks=pytest.mark.csharp),
|
||||
],
|
||||
|
||||
@@ -5,9 +5,9 @@ import pytest
|
||||
from solidlsp import SolidLanguageServer
|
||||
from solidlsp.ls_config import Language
|
||||
from solidlsp.ls_utils import SymbolUtils
|
||||
from test.conftest import is_ci
|
||||
from test.conftest import language_tests_enabled
|
||||
|
||||
pytestmark = [pytest.mark.al, pytest.mark.skipif(not is_ci, reason="AL tests are not run in CI, because they are unstable locally")]
|
||||
pytestmark = [pytest.mark.al, pytest.mark.skipif(not language_tests_enabled(Language.AL), reason="AL tests are disabled")]
|
||||
|
||||
|
||||
@pytest.mark.al
|
||||
|
||||
@@ -15,3 +15,7 @@ CLI_FAIL = _test_clojure_cli()
|
||||
TEST_APP_PATH = Path("src") / "test_app"
|
||||
CORE_PATH = str(TEST_APP_PATH / "core.clj")
|
||||
UTILS_PATH = str(TEST_APP_PATH / "utils.clj")
|
||||
|
||||
|
||||
def is_clojure_cli_available() -> bool:
|
||||
return not CLI_FAIL
|
||||
@@ -4,12 +4,13 @@ from serena.project import Project
|
||||
from solidlsp.ls import SolidLanguageServer
|
||||
from solidlsp.ls_config import Language
|
||||
from solidlsp.ls_types import UnifiedSymbolInformation
|
||||
from test.conftest import language_tests_enabled
|
||||
|
||||
from . import CLI_FAIL, CORE_PATH, UTILS_PATH
|
||||
from . import CORE_PATH, UTILS_PATH
|
||||
|
||||
|
||||
@pytest.mark.clojure
|
||||
@pytest.mark.skipif(CLI_FAIL, reason=f"Clojure CLI not available: {CLI_FAIL}")
|
||||
@pytest.mark.skipif(not language_tests_enabled(Language.CLOJURE), reason="Clojure tests are disabled")
|
||||
class TestLanguageServerBasics:
|
||||
@pytest.mark.parametrize("language_server", [Language.CLOJURE], indirect=True)
|
||||
def test_basic_definition(self, language_server: SolidLanguageServer):
|
||||
|
||||
@@ -5,9 +5,9 @@ import pytest
|
||||
from solidlsp import SolidLanguageServer
|
||||
from solidlsp.ls_config import Language
|
||||
from solidlsp.ls_utils import SymbolUtils
|
||||
from test.conftest import java_tests_enabled
|
||||
from test.conftest import language_tests_enabled
|
||||
|
||||
pytestmark = [pytest.mark.java, pytest.mark.skipif(not java_tests_enabled, reason="Java tests are only run on Windows in CI")]
|
||||
pytestmark = [pytest.mark.java, pytest.mark.skipif(not language_tests_enabled(Language.JAVA), reason="Java tests disabled")]
|
||||
|
||||
|
||||
class TestJavaLanguageServer:
|
||||
|
||||
Reference in new issue
Block a user