Skip to content

Commit f8c7256

Browse files
committed
Check case when no global version is set, adjust all version test
1 parent 6f28167 commit f8c7256

File tree

4 files changed

+36
-16
lines changed

4 files changed

+36
-16
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ jobs:
3535
uv sync --extra dev
3636
- name: Run Tests
3737
run: |
38-
uv run python -m pytest tests/ -v --tb=short -n auto
38+
uv run python -m pytest tests/ -v --tb=short -n auto -m "not slow"

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ markers = [
115115
"linux: marks tests to run only on Linux",
116116
"macos: marks tests to run only on macOS",
117117
"windows: marks tests to run only on Windows",
118+
"slow: marks tests as slow running",
118119
]
119120

120121
[tool.mypy]

tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def pytest_configure(config: pytest.Config) -> None:
8282
config.addinivalue_line("markers", "linux: mark test to run only on Linux")
8383
config.addinivalue_line("markers", "macos: mark test to run only on macOS")
8484
config.addinivalue_line("markers", "windows: mark test to run only on Windows")
85+
config.addinivalue_line("markers", "slow: mark test as slow running")
8586

8687

8788
def pytest_runtest_setup(item: pytest.Item) -> None:

tests/test_version_verification.py

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,64 @@
55
work correctly and return expected version information.
66
"""
77

8-
from pathlib import Path
98
from typing import Any
109

11-
from .utils import run_in_venv
10+
import pytest
11+
12+
from .utils import run_command
1213

1314

1415
class TestVersionVerification: # pylint: disable=too-few-public-methods
1516
"""Test solc-select version verification behavior."""
1617

17-
def test_all_versions_work_correctly(self, isolated_python_env: Any) -> None:
18+
@pytest.mark.parametrize("test_mode", [pytest.param("all", marks=pytest.mark.slow), "some"])
19+
def test_all_versions_work_correctly(self, isolated_solc_data: Any, test_mode: str) -> None:
1820
"""
19-
Test that all installed Solidity versions work correctly.
21+
Test that installed Solidity versions work correctly.
2022
21-
This test installs all available Solidity versions using solc-select,
23+
This test installs Solidity versions using solc-select (either all or some specific ones),
2224
then verifies each version by running `solc --version` and checking
2325
that the output contains "solidity compiler" and the correct version number.
2426
"""
25-
venv = isolated_python_env
26-
project_root = Path(__file__).parent.parent
27-
28-
# Install development version of solc-select
29-
run_in_venv(venv, f"pip install -e {project_root}", check=True)
30-
31-
# Install all available versions
32-
run_in_venv(venv, "solc-select install all", check=True)
27+
if test_mode == "all":
28+
# Install all available versions
29+
run_command("solc-select install all", check=True)
30+
else: # test_mode == "some"
31+
# Install specific versions in one call
32+
specific_versions = ["0.4.11", "0.7.3", "0.8.10", "0.8.30"]
33+
run_command(f"solc-select install {' '.join(specific_versions)}", check=True)
3334

3435
# Get list of all installed versions
35-
result = run_in_venv(venv, "solc-select versions", check=True)
36+
result = run_command("solc-select versions", check=True)
3637
versions = [line.strip() for line in result.stdout.strip().split("\n") if line.strip()]
3738

3839
assert versions, "No versions found - installation may have failed"
3940

4041
# Test each version
4142
for version in versions:
4243
# Run solc --version with the specific version set
43-
result = run_in_venv(venv, f"SOLC_VERSION={version} solc --version", check=True)
44+
result = run_command(f"SOLC_VERSION={version} solc --version", check=True)
4445
output = result.stdout.lower()
4546

4647
# Check that output contains "solidity compiler" and the version
4748
assert "solidity compiler" in output, (
4849
f"Version {version}: Missing 'solidity compiler' in output"
4950
)
5051
assert version in output, f"Version {version}: Version number not found in output"
52+
53+
def test_no_global_version_selected_error(self, isolated_solc_data: Any) -> None:
54+
"""
55+
Test that running solc without a global version selected throws an error.
56+
"""
57+
# Install at least one version but don't select it globally
58+
run_command("solc-select install 0.8.10", check=True)
59+
60+
# Try to run solc without setting a global version - this should fail
61+
result = run_command("solc --version", check=False)
62+
63+
# Should have non-zero exit code and error message about no version selected
64+
assert result.returncode != 0, "Expected solc to fail when no version is selected"
65+
error_output = result.stdout.lower()
66+
assert "no solc version set" in error_output, (
67+
f"Expected error about no version selected, got: {result.stdout}"
68+
)

0 commit comments

Comments
 (0)