Skip to content

Commit c49076b

Browse files
test: ensure tests uses the current source of this project
1 parent 18d63d4 commit c49076b

File tree

4 files changed

+31
-29
lines changed

4 files changed

+31
-29
lines changed

tests/conftest.py

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,30 @@ def top_level_dir() -> Path:
1919

2020

2121
@pytest.fixture(scope="session")
22-
def buildenv(tmp_path_factory: pytest.TempPathFactory) -> VEnv:
22+
def wheelhouse(tmp_path_factory: pytest.TempPathFactory) -> Path:
23+
return tmp_path_factory.mktemp("wheelhouse")
24+
25+
26+
@pytest.fixture(scope="session")
27+
def buildenv(tmp_path_factory: pytest.TempPathFactory, top_level_dir: Path, wheelhouse: Path) -> VEnv:
2328
path = tmp_path_factory.mktemp("cmake_env")
2429
venv = VEnv(path)
30+
# install cmake in the venv as it is used as a python module
2531
venv.install("cmake")
32+
# fill wheelhouse with all required wheels
33+
# This enable this project to be always the current source, not from a remote index
34+
# This also serves as a manual cache, making everything faster when running all tests
35+
# All builds must use: "--find-links", wheelhouse.as_posix(), "--no-index"
36+
venv.module("pip", "wheel",
37+
"cmake",
38+
"scikit-build-core",
39+
"hatchling",
40+
"vtk==9.6.0",
41+
"vtk-sdk==9.6.0",
42+
top_level_dir.as_posix(),
43+
"--extra-index-url", "https://vtk.org/files/wheel-sdks",
44+
"--wheel-dir", wheelhouse.as_posix()
45+
)
2646
return venv
2747

2848

@@ -58,51 +78,34 @@ def dependency(buildenv: VEnv, tmp_path_factory: pytest.TempPathFactory, curdir:
5878

5979

6080
@pytest.fixture(scope="session")
61-
def wheelhouse(tmp_path_factory: pytest.TempPathFactory) -> Path:
62-
return tmp_path_factory.mktemp("wheelhouse")
63-
64-
65-
@pytest.fixture(scope="session")
66-
def vtksdk_helper(buildenv: VEnv, top_level_dir: Path, wheelhouse: Path) -> None:
67-
buildenv.module(
68-
"pip", "wheel", top_level_dir.as_posix(),
69-
"--wheel-dir", wheelhouse.as_posix()
70-
)
71-
assert list(wheelhouse.glob("vtk_sdk_python_wheel_helper-*.whl"))
72-
73-
74-
@pytest.fixture(scope="session")
75-
def basic_project(buildenv: VEnv, curdir: Path, dependency: str, wheelhouse: Path, vtksdk_helper) -> None:
81+
def basic_project(buildenv: VEnv, curdir: Path, dependency: str, wheelhouse: Path) -> None:
7682
os.environ["Dependency_ROOT"] = dependency
7783

7884
basic_project_src = (curdir / "BasicProject").as_posix()
7985
buildenv.module(
8086
"pip", "wheel", basic_project_src,
8187
"--wheel-dir", wheelhouse.as_posix(),
8288
"--find-links", wheelhouse.as_posix(),
83-
"--extra-index-url", "https://vtk.org/files/wheel-sdks",
84-
"--extra-index-url", "https://wheels.vtk.org"
89+
"--no-index"
8590
)
8691
assert list(wheelhouse.glob("basic_project-*.whl"))
8792

8893

8994
@pytest.fixture(scope="session")
90-
def basic_project_sdk(buildenv: VEnv, curdir: Path, dependency: str, wheelhouse: Path, vtksdk_helper) -> None:
95+
def basic_project_sdk(buildenv: VEnv, curdir: Path, dependency: str, wheelhouse: Path) -> None:
9196
os.environ["Dependency_ROOT"] = dependency
9297

9398
basic_project_src = (curdir / "BasicProject" / "SDK").as_posix()
9499
buildenv.module(
95100
"pip", "wheel", basic_project_src,
96101
"--wheel-dir", wheelhouse.as_posix(),
97102
"--find-links", wheelhouse.as_posix(),
98-
"--extra-index-url", "https://vtk.org/files/wheel-sdks",
99-
"--extra-index-url", "https://wheels.vtk.org"
103+
"--no-index"
100104
)
101-
assert list(wheelhouse.glob("basic_project_sdk-*.whl"))
102105

103106

104107
# tmp virtualenv for the test projects
105108
@pytest.fixture()
106-
def virtualenv(tmp_path: Path, top_level_dir: Path) -> VEnv:
109+
def virtualenv(tmp_path: Path, buildenv) -> VEnv:
107110
path = tmp_path / "venv"
108-
return VEnv(path)
111+
return VEnv(path)

tests/test_all_modules.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
from pathlib import Path
66
from .venv import VEnv
77

8-
def test_all_modules(virtualenv: VEnv, curdir: Path, wheelhouse: Path, vtksdk_helper):
8+
def test_all_modules(virtualenv: VEnv, curdir: Path, wheelhouse: Path):
99
all_modules_src = (curdir / "packages" / "all_modules").as_posix()
1010
virtualenv.module(
1111
"pip", "install", all_modules_src,
1212
"--find-links", wheelhouse.as_posix(),
13-
"--extra-index-url", "https://vtk.org/files/wheel-sdks",
14-
"--extra-index-url", "https://wheels.vtk.org",
13+
"--no-index",
1514
"--verbose"
1615
)
1716

tests/test_build_module.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ def test_build_module(virtualenv: VEnv, curdir: Path, wheelhouse: Path, basic_pr
1010
virtualenv.module(
1111
"pip", "install", test_src,
1212
"--find-links", wheelhouse.as_posix(),
13-
"--extra-index-url", "https://vtk.org/files/wheel-sdks",
14-
"--extra-index-url", "https://wheels.vtk.org",
13+
"--no-index",
1514
"--verbose"
1615
)
1716

tests/test_find_package.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ def test_find_package(virtualenv: VEnv, curdir: Path, wheelhouse: Path, basic_pr
1010
virtualenv.module(
1111
"pip", "install", test_src,
1212
"--find-links", wheelhouse.as_posix(),
13+
"--no-index",
1314
"--verbose"
1415
)

0 commit comments

Comments
 (0)