Files

75 lines
2.2 KiB
Python

"""Wheel-content regression tests."""
import subprocess
import sys
import shutil
import zipfile
from pathlib import Path
import pytest
_REPO = Path(__file__).resolve().parent.parent
def test_wheel_contains_runtime_nodes_and_frontend(tmp_path):
setuptools = pytest.importorskip("setuptools")
wheel = pytest.importorskip("wheel")
packaging = pytest.importorskip("packaging")
source = tmp_path / "source"
output = tmp_path / "wheel"
output.mkdir()
shutil.copytree(
_REPO,
source,
ignore=shutil.ignore_patterns(
".git", ".pytest_cache", "__pycache__", "build", "*.egg-info",
),
)
module_roots = {
str(Path(module.__file__).resolve().parent.parent)
for module in (setuptools, wheel, packaging)
}
script = (
"import os,sys;"
"sys.path[:0]=sys.argv[3:];"
"os.chdir(sys.argv[1]);"
"from setuptools.build_meta import build_wheel;"
"print(build_wheel(sys.argv[2]))"
)
proc = subprocess.run(
[
sys.executable,
"-S",
"-c",
script,
str(source),
str(output),
*sorted(module_roots),
],
capture_output=True,
text=True,
timeout=120,
)
assert proc.returncode == 0, proc.stdout + proc.stderr
wheels = list(output.glob("comfyui_timeline-*.whl"))
assert len(wheels) == 1
with zipfile.ZipFile(wheels[0]) as archive:
names = set(archive.namelist())
packaged_init = archive.read(
"timelineanim_nodes/__init__.py",
).decode("utf-8")
expected = {
"timelineanim_nodes/__init__.py",
"timelineanim_nodes/node_timeline_animation.py",
"timelineanim_nodes/node_timeline_image_viewer.py",
"timelineanim_nodes/node_timeline_3d_viewer.py",
"timelineanim_nodes/web/global_timeline.css",
"timelineanim_nodes/web/js/timeline_3d_viewer.js",
"timelineanim_nodes/web/js/native_3d_bridge.js",
"comfy_timeline/py.typed",
}
assert expected <= names, f"wheel missing: {sorted(expected - names)}"
assert 'WEB_DIRECTORY = "./web"' in packaged_init