Skip to content

Commit ab9fc24

Browse files
committed
fix: Resolve Windows test failures and CI improvements
- Fixed Windows test failures by removing /dev/null redirects - Fixed path validation to work with Windows backslashes - Added GITHUB_TOKEN permissions to CI workflow - Updated CONTRIBUTING.md with pytest test instructions - Applied ruff linting and formatting to all test files
1 parent 02d8828 commit ab9fc24

File tree

7 files changed

+200
-202
lines changed

7 files changed

+200
-202
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ concurrency:
1414
group: ${{ github.workflow }}-${{ github.ref }}
1515
cancel-in-progress: true
1616

17+
permissions:
18+
contents: read
19+
1720
jobs:
1821
tests:
1922
name: CI (Python ${{ matrix.python }} on ${{ matrix.os }})

CONTRIBUTING.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,23 @@ pylint solc_select --rcfile pyproject.toml
7171

7272
## Running Tests
7373

74-
Tests are platform-specific and can be run locally:
74+
Tests use pytest and can be run locally:
7575

7676
```bash
77-
# Run tests for your platform
78-
bash scripts/test_linux.sh # On Linux
79-
bash scripts/test_macos.sh # On macOS
80-
bash scripts/test_windows.sh # On Windows
77+
# Install development dependencies (includes pytest)
78+
pip install -e ".[dev]"
79+
80+
# Run all tests
81+
pytest tests/
82+
83+
# Run specific test file
84+
pytest tests/test_compiler_versions.py
85+
86+
# Run tests with verbose output
87+
pytest tests/ -v
88+
89+
# Skip slow tests (upgrade test) and platform boundary tests
90+
pytest tests/ -k "not version_boundaries" -m "not slow"
8191

8292
# Tests also run automatically in GitHub Actions on all platforms
8393
```

tests/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"""Test suite for solc-select."""
1+
"""Test suite for solc-select."""

tests/conftest.py

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@ def solc_select_path() -> Path:
2929
def backup_current_version(solc_select_path: Path) -> Generator[None, None, None]:
3030
"""
3131
Backup and restore the current solc version.
32-
32+
3333
This fixture ensures that each test starts with a clean state
3434
and doesn't affect the user's current solc configuration.
3535
"""
3636
global_version_file = solc_select_path / "global-version"
3737
backup_file = None
38-
38+
3939
# Backup current version if it exists
4040
if global_version_file.exists():
4141
backup_file = global_version_file.with_suffix(".backup")
4242
shutil.copy2(global_version_file, backup_file)
43-
43+
4444
yield
45-
45+
4646
# Restore original version
4747
if backup_file and backup_file.exists():
4848
shutil.copy2(backup_file, global_version_file)
@@ -56,27 +56,27 @@ def backup_current_version(solc_select_path: Path) -> Generator[None, None, None
5656
def clean_artifacts(solc_select_path: Path) -> Generator[None, None, None]:
5757
"""
5858
Clean up test artifacts after each test.
59-
59+
6060
This is used for tests that need complete isolation and
6161
should start with no installed versions.
6262
"""
6363
artifacts_dir = solc_select_path / "artifacts"
6464
backup_dir = None
65-
65+
6666
# Backup existing artifacts if they exist
6767
if artifacts_dir.exists():
6868
backup_dir = artifacts_dir.with_suffix(".backup")
6969
if backup_dir.exists():
7070
shutil.rmtree(backup_dir)
7171
shutil.copytree(artifacts_dir, backup_dir)
7272
shutil.rmtree(artifacts_dir)
73-
73+
7474
yield
75-
75+
7676
# Clean up test artifacts
7777
if artifacts_dir.exists():
7878
shutil.rmtree(artifacts_dir)
79-
79+
8080
# Restore original artifacts if they existed
8181
if backup_dir and backup_dir.exists():
8282
shutil.copytree(backup_dir, artifacts_dir)
@@ -87,35 +87,38 @@ def clean_artifacts(solc_select_path: Path) -> Generator[None, None, None]:
8787
def run_command():
8888
"""
8989
Execute shell commands and return output.
90-
90+
9191
This fixture provides a conservative way to run commands,
9292
exactly as the bash tests did.
9393
"""
94-
def _run(cmd: str, check: bool = True, capture_stderr: bool = True) -> subprocess.CompletedProcess:
94+
95+
def _run(
96+
cmd: str, check: bool = True, capture_stderr: bool = True
97+
) -> subprocess.CompletedProcess:
9598
"""
9699
Run a shell command and return the result.
97-
100+
98101
Args:
99102
cmd: Command to run
100103
check: Whether to raise on non-zero exit code
101104
capture_stderr: Whether to capture stderr
102-
105+
103106
Returns:
104107
CompletedProcess instance with stdout, stderr, and returncode
105108
"""
106109
stderr_setting = subprocess.STDOUT if capture_stderr else subprocess.PIPE
107-
110+
108111
result = subprocess.run(
109112
cmd,
110113
shell=True,
111114
capture_output=False,
112115
stdout=subprocess.PIPE,
113116
stderr=stderr_setting,
114117
text=True,
115-
check=check
118+
check=check,
116119
)
117120
return result
118-
121+
119122
return _run
120123

121124

@@ -129,33 +132,23 @@ def test_contracts_dir() -> Path:
129132
def ensure_solc_select_installed():
130133
"""
131134
Ensure solc-select is installed in development mode.
132-
135+
133136
This runs once per test session to ensure the current
134137
development version is being tested.
135138
"""
136139
# Check if solc-select is available
137-
result = subprocess.run(
138-
["solc-select", "--help"],
139-
capture_output=True,
140-
text=True
141-
)
142-
140+
result = subprocess.run(["solc-select", "--help"], capture_output=True, text=True)
141+
143142
if result.returncode != 0:
144143
pytest.exit("solc-select is not installed. Please run: pip install -e .")
145144

146145

147146
# Platform markers for conditional test execution
148147
def pytest_configure(config):
149148
"""Register custom markers."""
150-
config.addinivalue_line(
151-
"markers", "linux: mark test to run only on Linux"
152-
)
153-
config.addinivalue_line(
154-
"markers", "macos: mark test to run only on macOS"
155-
)
156-
config.addinivalue_line(
157-
"markers", "windows: mark test to run only on Windows"
158-
)
149+
config.addinivalue_line("markers", "linux: mark test to run only on Linux")
150+
config.addinivalue_line("markers", "macos: mark test to run only on macOS")
151+
config.addinivalue_line("markers", "windows: mark test to run only on Windows")
159152

160153

161154
def pytest_runtest_setup(item):
@@ -165,4 +158,4 @@ def pytest_runtest_setup(item):
165158
if "macos" in item.keywords and sys.platform != "darwin":
166159
pytest.skip("Test requires macOS")
167160
if "windows" in item.keywords and sys.platform != "win32":
168-
pytest.skip("Test requires Windows")
161+
pytest.skip("Test requires Windows")

0 commit comments

Comments
 (0)