mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-12-06 01:48:35 +00:00
Tests: Add Hypothesis, with dev, ci and thorough profiles
hypothesis joins the test extra. conftest.py registers three profiles, chosen with HYPOTHESIS_PROFILE: - dev (the default): 100 examples. - ci: 100 examples, derandomized, so a CI failure always reproduces. - thorough: 3000 examples, for bug hunting. None of them has a deadline: an example compiles a program twice. CI runs the suite with the ci profile. The example database (.hypothesis/) is ignored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
3
.github/workflows/test.yml
vendored
3
.github/workflows/test.yml
vendored
@ -72,6 +72,9 @@ jobs:
|
||||
run: uv pip install --system -e ".[test]"
|
||||
|
||||
- name: Run test suite
|
||||
env:
|
||||
# tests/property: derandomized, so a failure always reproduces
|
||||
HYPOTHESIS_PROFILE: ci
|
||||
run: make test
|
||||
|
||||
- name: Check whether sudo is usable
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@ -14,3 +14,4 @@ vmlinux.h
|
||||
# Documentation build artifacts
|
||||
docs/_build/
|
||||
docs/_templates/
|
||||
.hypothesis/
|
||||
|
||||
@ -42,6 +42,7 @@ docs = [
|
||||
test = [
|
||||
"pytest>=8.0",
|
||||
"pytest-cov>=5.0",
|
||||
"hypothesis>=6.100",
|
||||
"ctypeslib2",
|
||||
# Pinned rather than left to ctypeslib2's own (unpinned) dependency: pip
|
||||
# installs the latest release by default, and its libclang API surface
|
||||
|
||||
@ -116,3 +116,22 @@ def pytest_collection_modifyitems(items):
|
||||
def set_log_level(caplog):
|
||||
with caplog.at_level(logging.ERROR, logger="pythonbpf"):
|
||||
yield
|
||||
|
||||
|
||||
# ── Hypothesis profiles (tests/property) ────────────────────────────────────
|
||||
# dev (default) for local runs, ci for GitHub Actions (derandomized, so a PR
|
||||
# never fails on an example nobody can reproduce), thorough for bug hunting:
|
||||
# HYPOTHESIS_PROFILE=thorough pytest tests/property
|
||||
|
||||
try:
|
||||
import os
|
||||
|
||||
from hypothesis import HealthCheck, settings
|
||||
|
||||
_common = dict(deadline=None, suppress_health_check=[HealthCheck.too_slow])
|
||||
settings.register_profile("dev", max_examples=100, **_common)
|
||||
settings.register_profile("ci", max_examples=100, derandomize=True, **_common)
|
||||
settings.register_profile("thorough", max_examples=3000, **_common)
|
||||
settings.load_profile(os.environ.get("HYPOTHESIS_PROFILE", "dev"))
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user