Skip to content

Commit cfcd6b7

Browse files
committed
Fix tests on Windows
1 parent 93ac29f commit cfcd6b7

File tree

4 files changed

+32
-16
lines changed

4 files changed

+32
-16
lines changed

solc_select/infrastructure/filesystem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def get_version_source(self) -> str:
7373
return "SOLC_VERSION"
7474

7575
global_version_file = self.config_dir / "global-version"
76-
return str(global_version_file)
76+
return global_version_file.as_posix()
7777

7878
def get_artifact_directory(self, version: SolcVersion) -> Path:
7979
"""Get the directory for a version's artifacts.

solc_select/services/artifact_manager.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,15 +308,17 @@ def install_versions(self, versions: List[SolcVersion], silent: bool = False) ->
308308
success_count += 1
309309
if not silent:
310310
print(
311-
f" Version '{version}' installed ({success_count}/{total_count})"
311+
f"[OK] Version '{version}' installed ({success_count}/{total_count})"
312312
)
313313
elif not silent:
314314
print(
315-
f" Version '{version}' failed to install ({success_count}/{total_count})"
315+
f"[FAIL] Version '{version}' failed to install ({success_count}/{total_count})"
316316
)
317317
except SolcSelectError as e:
318318
if not silent:
319-
print(f"✗ Version '{version}' failed: {e} ({success_count}/{total_count})")
319+
print(
320+
f"[FAIL] Version '{version}' failed: {e} ({success_count}/{total_count})"
321+
)
320322

321323
except KeyboardInterrupt:
322324
if not silent:

tests/test_version_verification.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def test_all_versions_work_correctly(self, isolated_solc_data: Any, test_mode: s
4141
# Test each version
4242
for version in versions:
4343
# Run solc --version with the specific version set
44-
result = run_command(f"SOLC_VERSION={version} solc --version", check=True)
44+
result = run_command("solc --version", check=True, env={"SOLC_VERSION": version})
4545
output = result.stdout.lower()
4646

4747
# Check that output contains "solidity compiler" and the version

tests/utils.py

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def run_in_venv(
4444

4545

4646
def run_command(
47-
cmd: str, check: bool = True, capture_stderr: bool = True
47+
cmd: str, check: bool = True, capture_stderr: bool = True, env: dict[str, str] | None = None
4848
) -> subprocess.CompletedProcess[str]:
4949
"""
5050
Execute shell commands and return output.
@@ -56,19 +56,33 @@ def run_command(
5656
cmd: Command to run
5757
check: Whether to raise on non-zero exit code
5858
capture_stderr: Whether to capture stderr
59+
env: Additional environment variables to set
5960
6061
Returns:
6162
CompletedProcess instance with stdout, stderr, and returncode
6263
"""
6364
stderr_setting = subprocess.STDOUT if capture_stderr else subprocess.PIPE
6465

65-
result = subprocess.run(
66-
cmd,
67-
shell=True,
68-
capture_output=False,
69-
stdout=subprocess.PIPE,
70-
stderr=stderr_setting,
71-
text=True,
72-
check=check,
73-
)
74-
return result
66+
# Merge environment variables
67+
process_env = os.environ.copy()
68+
if env:
69+
process_env.update(env)
70+
71+
try:
72+
return subprocess.run(
73+
cmd,
74+
shell=True,
75+
capture_output=False,
76+
stdout=subprocess.PIPE,
77+
stderr=stderr_setting,
78+
text=True,
79+
check=check,
80+
env=process_env,
81+
)
82+
except subprocess.CalledProcessError as e:
83+
print("Command failed with CalledProcessError.")
84+
print("Exit code:", e.returncode)
85+
print("Command:", e.cmd)
86+
print("Stdout:", e.stdout)
87+
print("Stderr:", e.stderr)
88+
raise

0 commit comments

Comments
 (0)