Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/jmrplens/phonometry. Standards-conformant acoustics library for Python: measurement and metrology, docs.jmrp.io/phonometry
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849# Copyright (c) 2026. Jose Manuel Requena Plens"""The guard that keeps the jitted-kernel CI job honest.
``scripts/check_jit_kernel.py`` runs before the test suite in the job thatinstalls the ``perf`` extra, and fails when the impulse kernel produced nomachine code. Its verdict has to follow the environment in both directions:green only where numba is installed *and* ``NUMBA_DISABLE_JIT`` is off, redeverywhere else, because a guard that always passes would hide exactly theregression it is there to catch."""
from __future__ import annotations
import importlib.utilimport osimport pathlibimport sys
import pytest
_SCRIPTS = str(pathlib.Path(__file__).resolve().parent.parent / "scripts")if _SCRIPTS not in sys.path: sys.path.insert(0, _SCRIPTS)
import check_jit_kernel
#: True only in the environment the guard is meant to pass in: numba installed#: (the ``perf`` extra) and the JIT left enabled._JITTED = ( importlib.util.find_spec("numba") is not None and os.environ.get("NUMBA_DISABLE_JIT") == "0")
def test_guard_verdict_follows_the_environment() -> None: """The exit status must agree with whether the kernel really compiles.""" assert (check_jit_kernel.main() == 0) is _JITTED
@pytest.mark.skipif(not _JITTED, reason="numba is absent or the JIT is disabled")def test_a_pass_is_backed_by_a_printed_signature( capsys: pytest.CaptureFixture[str],) -> None: """A pass has to name the compiled signatures, not just return zero.""" assert check_jit_kernel.main() == 0 out = capsys.readouterr().out assert "compiled signature" in out assert "array(float64" in out