Skip to content

Commit

Permalink
Allow disabling Zig test collection for performance (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
gatesn authored Oct 19, 2023
1 parent 4a947f5 commit 2151bf4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pydust/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class ToolPydust(BaseModel):
zig_exe: Path | None = None
build_zig: Path = Path("build.zig")

# Whether to include Zig tests as part of the pytest collection.
zig_tests: bool = True

# When true, python module definitions are configured by the user in their own build.zig file.
# When false, ext_modules is used to auto-generated a build.zig file.
self_managed: bool = False
Expand Down
6 changes: 5 additions & 1 deletion pydust/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,15 @@ def pytest_collection(session):
"""
optimize = session.config.getoption("zig_optimize")
buildzig.zig_build(["install", f"-Doptimize={optimize}", f"-Dpython-exe={sys.executable}"])
buildzig.zig_build(["pydust-test-build", f"-Doptimize={optimize}", f"-Dpython-exe={sys.executable}"])
if config.load().zig_tests:
buildzig.zig_build(["pydust-test-build", f"-Doptimize={optimize}", f"-Dpython-exe={sys.executable}"])


def pytest_collect_file(file_path, path, parent):
"""Grab any Zig roots for PyTest collection."""
if not config.load().zig_tests:
return None

if file_path.suffix == ".zig":
for ext_module in pydust_conf.ext_modules:
if ext_module.root.absolute() == file_path.absolute():
Expand Down

0 comments on commit 2151bf4

Please sign in to comment.