From bbf15ffc98f7677894e5754177b1cee5ed02df6a Mon Sep 17 00:00:00 2001 From: David Bernazal Date: Tue, 1 Jul 2025 09:31:04 -0500 Subject: [PATCH] Ensure deps are installed --- .github/workflows/pytest.yml | 8 +---- test/solidlsp/elixir/conftest.py | 53 ++++++++++++++++++++++---------- 2 files changed, 37 insertions(+), 24 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 191f914..7a14aba 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -71,10 +71,4 @@ jobs: run: uv pip install -e ".[dev]" - name: Test with pytest shell: bash - run: | - if [[ "${{ runner.os }}" == "Windows" ]]; then - # Exclude Elixir tests on Windows since Next LS doesn't support Windows - uv run pytest -m "not elixir" - else - uv run poe test - fi + run: uv run poe test diff --git a/test/solidlsp/elixir/conftest.py b/test/solidlsp/elixir/conftest.py index 156fb37..f83d420 100644 --- a/test/solidlsp/elixir/conftest.py +++ b/test/solidlsp/elixir/conftest.py @@ -8,13 +8,14 @@ from pathlib import Path def ensure_elixir_test_repo_compiled(repo_path: str) -> None: - """Ensure the Elixir test repository is compiled for optimal Next LS performance during testing. + """Ensure the Elixir test repository dependencies are installed and project is compiled. Next LS requires the project to be fully compiled and indexed before providing - complete references and symbol resolution. This function ensures the test repository - is compiled before starting the language server for tests. + complete references and symbol resolution. This function: + 1. Installs dependencies via 'mix deps.get' + 2. Compiles the project via 'mix compile' - In production environments, users typically have their code already compiled. + This is essential in CI environments where dependencies aren't pre-installed. Args: repo_path: Path to the Elixir project root directory @@ -25,8 +26,23 @@ def ensure_elixir_test_repo_compiled(repo_path: str) -> None: return try: - print(f"Compiling Elixir test repository for optimal Next LS performance...") - result = subprocess.run( + print(f"Installing dependencies and compiling Elixir test repository for optimal Next LS performance...") + + # First, install dependencies + deps_result = subprocess.run( + ["mix", "deps.get"], + cwd=repo_path, + capture_output=True, + text=True, + timeout=60 # 60 second timeout for dependency installation + ) + + if deps_result.returncode != 0: + print(f"Warning: Failed to install dependencies: {deps_result.stderr}") + # Continue anyway - some projects might not have dependencies + + # Then compile the project + compile_result = subprocess.run( ["mix", "compile"], cwd=repo_path, capture_output=True, @@ -34,26 +50,29 @@ def ensure_elixir_test_repo_compiled(repo_path: str) -> None: timeout=60 # 60 second timeout for compilation ) - if result.returncode == 0: + if compile_result.returncode == 0: print(f"Elixir test repository compiled successfully in {repo_path}") else: - print(f"Elixir test compilation completed with warnings/errors: {result.stderr}") + print(f"Elixir test compilation completed with warnings/errors: {compile_result.stderr}") except subprocess.TimeoutExpired: - print("Warning: Elixir test compilation timed out after 60 seconds") + print("Warning: Elixir dependency installation or compilation timed out after 60 seconds") except FileNotFoundError: print("Warning: 'mix' command not found - Elixir test repository may not be compiled") except Exception as e: - print(f"Warning: Failed to compile Elixir test repository: {e}") + print(f"Warning: Failed to prepare Elixir test repository: {e}") @pytest.fixture(scope="session", autouse=True) def setup_elixir_test_environment(): - """Automatically ensure Elixir test environment is ready for all Elixir tests. + """Automatically prepare Elixir test environment for all Elixir tests. - This fixture runs once per test session and automatically compiles the Elixir - test repository before any Elixir tests run. It uses autouse=True so it runs - automatically without needing to be explicitly requested by tests. + This fixture runs once per test session and automatically: + 1. Installs dependencies via 'mix deps.get' + 2. Compiles the Elixir test repository via 'mix compile' + + It uses autouse=True so it runs automatically without needing to be explicitly + requested by tests. This ensures Next LS has a fully prepared project to work with. """ # Get the test repo path relative to this conftest.py file test_repo_path = Path(__file__).parent.parent.parent / "resources" / "repos" / "elixir" / "test_repo" @@ -63,9 +82,9 @@ def setup_elixir_test_environment(): @pytest.fixture(scope="session") def elixir_test_repo_path(setup_elixir_test_environment): - """Get the path to the compiled Elixir test repository. + """Get the path to the prepared Elixir test repository. - This fixture depends on setup_elixir_test_environment to ensure compilation - has completed before returning the path. + This fixture depends on setup_elixir_test_environment to ensure dependencies + are installed and compilation has completed before returning the path. """ return setup_elixir_test_environment \ No newline at end of file