Skip to content

Commit 1467226

Browse files
committed
Enable minimal testing with windows and ubuntu
Due to the specific nature of how uv works, some minimal testing on Windows and MacOS would be needed. Related: #193 #183
1 parent 33173a7 commit 1467226

4 files changed

Lines changed: 52 additions & 15 deletions

File tree

.github/workflows/check.yaml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches: ["main"]
66
tags-ignore: ["**"]
77
pull_request:
8+
pull_request_target:
89
schedule:
910
- cron: "0 8 * * *"
1011

@@ -14,7 +15,8 @@ concurrency:
1415

1516
jobs:
1617
test:
17-
runs-on: ubuntu-latest
18+
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
19+
name: ${{ matrix.env }}${{ matrix.suffix || ''}}
1820
strategy:
1921
fail-fast: false
2022
matrix:
@@ -28,6 +30,17 @@ jobs:
2830
- type
2931
- dev
3032
- pkg_meta
33+
os:
34+
- ubuntu-latest
35+
suffix:
36+
- ""
37+
include:
38+
- env: "3.13"
39+
os: windows-latest
40+
suffix: -windows
41+
- env: "3.13"
42+
os: macos-latest
43+
suffix: -macos
3144
steps:
3245
- uses: actions/checkout@v4
3346
with:
@@ -45,10 +58,12 @@ jobs:
4558
- name: Setup test suite
4659
run: tox run -vv --notest --skip-missing-interpreters false -e ${{ matrix.env }}
4760
env:
61+
FORCE_COLOR: "1"
4862
UV_PYTHON_PREFERENCE: "only-managed"
4963
- name: Run test suite
5064
run: tox run --skip-pkg-install -e ${{ matrix.env }}
5165
env:
66+
FORCE_COLOR: "1"
5267
PYTEST_ADDOPTS: "-vv --durations=20"
5368
DIFF_AGAINST: HEAD
5469
UV_PYTHON_PREFERENCE: "only-managed"

src/tox_uv/_venv.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def _get_python(self, base_python: list[str]) -> PythonInfo | None: # noqa: PLR
135135
free_threaded=sysconfig.get_config_var("Py_GIL_DISABLED") == 1,
136136
)
137137
base_path = Path(base)
138-
if base_path.is_absolute():
138+
if base_path.is_absolute(): # pragma: win32 no cover
139139
info = VirtualEnv.get_virtualenv_py_info(base_path)
140140
return PythonInfo(
141141
implementation=info.implementation,
@@ -173,7 +173,7 @@ def python_spec_for_path(cls, path: Path) -> PythonSpec:
173173
:param path: the path investigated
174174
:return: the found spec
175175
"""
176-
return VirtualEnv.python_spec_for_path(path)
176+
return VirtualEnv.python_spec_for_path(path) # pragma: win32 no cover
177177

178178
@property
179179
def uv(self) -> str:
@@ -247,10 +247,9 @@ def env_python(self) -> Path:
247247
suffix = ".exe" if sys.platform == "win32" else ""
248248
return self.env_bin_dir() / f"python{suffix}"
249249

250-
def env_site_package_dir(self) -> Path:
250+
def env_site_package_dir(self) -> Path: # pragma: win32 no cover
251251
if sys.platform == "win32": # pragma: win32 cover
252252
return self.venv_dir / "Lib" / "site-packages"
253-
# pragma: win32 no cover
254253
py = self._py_info
255254
impl = "pypy" if py.implementation == "pypy" else "python"
256255
return self.venv_dir / "lib" / f"{impl}{py.version_dot}" / "site-packages"
@@ -261,7 +260,7 @@ def env_version_spec(self) -> str:
261260
executable = self.base_python.extra.get("executable")
262261
architecture = self.base_python.extra.get("architecture")
263262
free_threaded = self.base_python.free_threaded
264-
if executable:
263+
if executable: # pragma: win32 no cover
265264
version_spec = str(executable)
266265
elif (
267266
architecture is None
@@ -273,7 +272,7 @@ def env_version_spec(self) -> str:
273272
else:
274273
uv_imp = imp or ""
275274
free_threaded_tag = "+freethreaded" if free_threaded else ""
276-
if not base.major:
275+
if not base.major: # pragma: win32 no cover
277276
version_spec = f"{uv_imp}"
278277
elif not base.minor:
279278
version_spec = f"{uv_imp}{base.major}{free_threaded_tag}"

tests/test_tox_uv_installer.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,18 +132,23 @@ def test_uv_install_broken_venv(tox_project: ToxProjectCreator) -> None:
132132
[testenv]
133133
skip_install = true
134134
install = false
135-
commands = python3 --version
135+
commands = {env_python} --version
136136
"""
137137
})
138138
result = project.run("run", "-v")
139139
result.assert_success()
140140
assert "recreate env because existing venv is broken" not in result.out
141141
# break the environment
142-
bin_dir = project.path / ".tox" / "py" / "bin"
142+
if sys.platform != "win32": # pragma: win32 no cover
143+
bin_dir = project.path / ".tox" / "py" / "bin"
144+
executables = ("python", "python3")
145+
else: # pragma: win32 cover
146+
bin_dir = project.path / ".tox" / "py" / "Scripts"
147+
executables = ("python.exe", "pythonw.exe")
143148
bin_dir.mkdir(parents=True, exist_ok=True)
144-
for filename in ("python", "python3"):
149+
for filename in executables:
145150
path = bin_dir / filename
146-
path.unlink()
151+
path.unlink(missing_ok=True)
147152
path.symlink_to("/broken-location")
148153
# run again and ensure we did run the repair bits
149154
result = project.run("run", "-v")

tests/test_tox_uv_venv.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ def test_uv_venv_spec_major_only(tox_project: ToxProjectCreator) -> None:
9999
result.assert_success()
100100

101101

102+
@pytest.mark.xfail(
103+
sys.platform == "win32",
104+
reason="Bug https://github.com/tox-dev/tox-uv/issues/193 https://github.com/astral-sh/uv/issues/14239",
105+
)
102106
@pytest.mark.parametrize(
103107
("pypy", "expected_uv_pypy"),
104108
[
@@ -133,7 +137,7 @@ def test_uv_venv_spec_pypy(
133137
project = tox_project({"tox.ini": f"[tox]\nenv_list = {pypy}"})
134138
try:
135139
result = project.run("config", "-vv")
136-
except tox.tox_env.errors.Skip:
140+
except tox.tox_env.errors.Skip: # pragma: win32 no cover
137141
stdout, _ = capfd.readouterr()
138142
else: # pragma: no cover (PyPy might not be available on the system)
139143
stdout = result.out
@@ -208,25 +212,39 @@ def other_interpreter_exe() -> pathlib.Path: # pragma: no cover
208212
return base_python
209213

210214

211-
def test_uv_venv_spec_abs_path(tox_project: ToxProjectCreator, other_interpreter_exe: pathlib.Path) -> None:
215+
@pytest.mark.xfail(
216+
sys.platform == "win32",
217+
reason="Bug https://github.com/tox-dev/tox-uv/issues/193 https://github.com/astral-sh/uv/issues/14239",
218+
)
219+
def test_uv_venv_spec_abs_path(
220+
tox_project: ToxProjectCreator, other_interpreter_exe: pathlib.Path
221+
) -> None: # pragma: win32 no cover
212222
project = tox_project({"tox.ini": f"[testenv]\npackage=skip\nbase_python={other_interpreter_exe}"})
213223
result = project.run("-vv")
214224
result.assert_success()
215225

216226

227+
@pytest.mark.xfail(
228+
sys.platform == "win32",
229+
reason="Bug https://github.com/tox-dev/tox-uv/issues/193 https://github.com/astral-sh/uv/issues/14239",
230+
)
217231
def test_uv_venv_spec_abs_path_conflict_ver(
218232
tox_project: ToxProjectCreator, other_interpreter_exe: pathlib.Path
219-
) -> None:
233+
) -> None: # pragma: win32 no cover
220234
# py27 is long gone, but still matches the testenv capture regex, so we know it will fail
221235
project = tox_project({"tox.ini": f"[testenv:py27]\npackage=skip\nbase_python={other_interpreter_exe}"})
222236
result = project.run("-vv", "-e", "py27")
223237
result.assert_failed()
224238
assert f"failed with env name py27 conflicting with base python {other_interpreter_exe}" in result.out
225239

226240

241+
@pytest.mark.xfail(
242+
sys.platform == "win32",
243+
reason="Bug https://github.com/tox-dev/tox-uv/issues/193 https://github.com/astral-sh/uv/issues/14239",
244+
)
227245
def test_uv_venv_spec_abs_path_conflict_impl(
228246
tox_project: ToxProjectCreator, other_interpreter_exe: pathlib.Path
229-
) -> None:
247+
) -> None: # pragma: win32 no cover
230248
env = "pypy" if platform.python_implementation() == "CPython" else "cpython"
231249
project = tox_project({"tox.ini": f"[testenv:{env}]\npackage=skip\nbase_python={other_interpreter_exe}"})
232250
result = project.run("-vv", "-e", env)

0 commit comments

Comments
 (0)