Files
VoiceStudio/tests/test_ci_pytest_parallel.py
T
Shimul Debnath 82fe41a44e ci: run tests/ in parallel with pytest-xdist (~3 min faster) (#3223)
* ci: run tests/ in parallel with pytest-xdist

10m52s serial -> 2m51s on 4 cores with identical results (10,052 passed, the
same single environmental failure). backend/tests stays serial: one test there
depends on another's leftover state and fails when run alone.

* docs(changelog): note parallel pytest (#3223)

* test: isolate pytest-xdist workers and one leaky registry test

Workers inherited the controller's auto-created OMNIVOICE_DATA_DIR, so they all
shared one prefs.json/omnivoice.db and the LLM skill tests failed in parallel
CI. Re-create the dir per worker, with a test that fails without it.

test_list_loaded_empty only cleared two of the four registries list_loaded()
reads, so it failed whenever an earlier test on the same worker left an engine
loaded.

* test: address review on parallel pytest

Reset the dictation ASR and NLLB registries in test_list_loaded_empty, keep
absolute paths out of the xdist probe file, and state the measured CI saving
(about 3 minutes on a real runner, not the 8 seen on a faster machine).
2026-10-23 21:34:35 +05:30

29 lines
1.2 KiB
Python

"""CI runs tests/ in parallel (pytest-xdist); the plugin must be a declared dev dependency-group member.
`-n auto` fails with "unrecognized arguments" when the plugin is missing, which
would break every CI run, so the workflow flag and the dependency move together.
"""
from __future__ import annotations
import re
import tomllib
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
def test_parallel_flag_requires_the_declared_plugin():
workflow = (ROOT / ".github/workflows/ci.yml").read_text(encoding="utf-8")
uses_parallel = re.search(r"pytest tests/ [^\n]*-n (auto|\d+)", workflow) is not None
dev = tomllib.loads((ROOT / "pyproject.toml").read_text(encoding="utf-8"))[
"dependency-groups"
]["dev"]
declared = any(dep.lower().startswith("pytest-xdist") for dep in dev)
assert declared or not uses_parallel, "ci.yml uses -n but pytest-xdist is not in the dev dependency group"
def test_backend_suite_stays_serial_until_its_order_dependence_is_fixed():
workflow = (ROOT / ".github/workflows/ci.yml").read_text(encoding="utf-8")
line = next(l for l in workflow.splitlines() if "pytest backend/tests/" in l)
assert " -n " not in line