Skip to content

armgit / laya

Public Imported from GitHub
0

Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.

test(packaging): bind CONTRIBUTING.md's suite section to the shared list

Aashish9d055ef393a3
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index beebceb4..f2e44482 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -56,13 +56,29 @@ python tests/test_hooks.py
python tests/test_hooks_api.py
```
-A few are pytest based and run with `python -m pytest tests/test_serve.py`, `tests/test_onnx.py`
-and `tests/test_truncation_direction.py`.
+A handful are pytest based and run under one pytest invocation:
-The full set, including the ones the CI runs, is in [`.github/workflows/ci.yml`](.github/workflows/ci.yml).
-A handful of suites need hardware or local weights and are skipped otherwise: `tests/test_fast.py`
-needs CUDA, and `tests/test_local_e2e.py` and `tests/test_mcp_local_e2e.py` expect checkpoints under
-`~/laya_models`.
+```bash
+python -m pytest tests/test_serve.py tests/test_truncation_direction.py -q
+```
+
+The one list that both the CI `test` job and the release gate run is
+[`scripts/test_suites.py`](scripts/test_suites.py). It keeps two lists because `python tests/<name>.py`
+does not execute a pytest suite -- it defines the test functions and exits 0, having asserted nothing
+(#374): `SCRIPT_SUITES` print their own PASS/FAIL summary and exit non-zero on failure, and
+`PYTEST_SUITES` are collected and run by pytest in a single invocation. Some lanes still name their own
+suites inline under `.github/workflows/`, and `tests/test_packaging.py` fails if a suite ends up in
+neither the shared list nor any workflow.
+
+The suites that need hardware, a compiler or local weights are not part of the PR `test` job:
+
+- `tests/test_compile_cuda.py` -- needs CUDA; CI installs CPU-only torch.
+- `tests/test_fast.py` -- needs CUDA and the `tilelang` extra.
+- `tests/test_fast_cpu.py` -- needs the `tilelang` extra and a C++ compiler; its CUDA parity checks skip.
+- `tests/test_local_e2e.py` -- expects checkpoints under `~/laya_models`.
+- `tests/test_mcp_local_e2e.py` -- expects checkpoints under `~/laya_models` and the `mcp` extra.
+- `tests/test_onnx.py` -- needs the `onnx` extra; it runs in the ONNX lane of `evals.yml`, not the PR job.
+- `tests/test_server_example.py` -- needs the weights `examples/server.py` loads; it runs in `evals.yml`.
Before opening a pull request, run the lint and compile checks the CI runs:
diff --git a/tests/test_packaging.py b/tests/test_packaging.py
index 7199fca4..fcb6f6c3 100644
--- a/tests/test_packaging.py
+++ b/tests/test_packaging.py
@@ -245,6 +245,98 @@ check_true("ci and the release gate share one suite list",
"scripts/test_suites.py" in workflow and "scripts/test_suites.py" in release_workflow, "")
+# -------------------------------------------------- CONTRIBUTING.md's "Running the tests" section
+# That section is what a new contributor runs, and it had drifted in three ways at once: it sent
+# readers to `.github/workflows/ci.yml` for "the full set" (ci.yml names 21 suite paths while the
+# shared list holds 86, and the two checks just above assert the workflows invoke the module instead
+# of naming suites), transcribed three of ten `PYTEST_SUITES` members as if that were the set, and
+# named three of the seven suites `EXEMPT_TEST_SUITES` exempts. So bind the page to the same lists
+# the gate uses. This also keeps #374's trap off the page: `python tests/<name>.py` on a pytest suite
+# defines the test functions, asserts nothing and exits 0, so an example run in the wrong style is a
+# contributor who believes they tested something.
+_contrib = read("CONTRIBUTING.md")
+
+
+def _shared_list(name):
+ """One of `scripts/test_suites.py`'s two lists, as bare file names."""
+ found = re.search(name + r" = \[(.*?)\n\]", shared_suites, re.S)
+ if not found:
+ return set()
+ return {p.split("/")[-1] for p in re.findall(r'"(tests/[^"]+\.py)"', found.group(1))}
+
+
+_script_suites = _shared_list("SCRIPT_SUITES")
+_pytest_suites = _shared_list("PYTEST_SUITES")
+# A suite is pytest-based if the shared list says so or a lane runs it under pytest. Workflow
+# *comments* mention pytest too (evals.yml explains its ONNX export there), so only run lines count.
+_pytest_lanes = set()
+for _wf_name in sorted(os.listdir(os.path.join(ROOT, ".github", "workflows"))):
+ if not _wf_name.endswith((".yml", ".yaml")):
+ continue
+ for _line in read(os.path.join(".github", "workflows", _wf_name)).splitlines():
+ if "pytest" in _line and not _line.strip().startswith("#"):
+ _pytest_lanes.update(re.findall(r"\btests/(test_[a-zA-Z0-9_]+\.py)\b", _line))
+
+check_true("contrib/the two shared lists parse",
+ len(_script_suites) >= 50 and len(_pytest_suites) >= 5,
+ "%d script, %d pytest" % (len(_script_suites), len(_pytest_suites)))
+
+
+def _contrib_examples():
+ """(names the page runs as scripts, names it runs under pytest), from its bash blocks."""
+ scripts, under_pytest = set(), set()
+ for block in re.findall(r"```bash\n(.*?)```", _contrib, re.S):
+ for line in block.splitlines():
+ if re.match(r"^\s*python\s+-m\s+pytest\b", line):
+ under_pytest.update(re.findall(r"tests/(test_[a-zA-Z0-9_]+\.py)", line))
+ elif re.match(r"^\s*python\s+tests/", line):
+ scripts.update(re.findall(r"tests/(test_[a-zA-Z0-9_]+\.py)", line))
+ return scripts, under_pytest
+
+
+def _contrib_exempt_bullets():
+ """The exempt suites the page lists, or None when it no longer has that list at all."""
+ lines = _contrib.splitlines()
+ try:
+ start = next(i for i, line in enumerate(lines) if "not part of the PR `test` job" in line)
+ except StopIteration:
+ return None
+ names = []
+ for line in lines[start + 1:]:
+ if not line.strip():
+ if names:
+ break
+ continue
+ if not line.startswith("- `tests/"):
+ break
+ names.append(line.split("`")[1].split("/")[-1])
+ return names
+
+
+_contrib_paths = set(re.findall(r"\btests/(test_[a-zA-Z0-9_]+\.py)\b", _contrib))
+_missing_paths = sorted(_contrib_paths - set(all_test_files))
+_example_scripts, _example_pytest = _contrib_examples()
+_stale_pointer = [line.strip() for line in _contrib.splitlines()
+ if "full set" in line and ".github/workflows/" in line]
+_exempt_list = _contrib_exempt_bullets()
+
+check_true("contrib/the page points at the one shared suite list",
+ "scripts/test_suites.py" in _contrib, "CONTRIBUTING.md never names it")
+check("contrib/no sentence sends readers to a workflow for the full set", _stale_pointer, [])
+check("contrib/every suite the page names exists", _missing_paths, [])
+check("contrib/every script example is a script suite",
+ sorted(_example_scripts - _script_suites), [])
+check("contrib/every pytest example is a pytest-based suite",
+ sorted(_example_pytest - (_pytest_suites | _pytest_lanes)), [])
+# A set difference, so a suite that gains an exemption without a line on the page is as red as one
+# that loses an exemption and keeps its line.
+if _exempt_list is None:
+ _exempt_diff = ["the page no longer carries the exempt-suite list"]
+else:
+ _exempt_diff = sorted(set(_exempt_list) ^ set(EXEMPT_TEST_SUITES))
+check("contrib/the page lists every exempt suite, and only those", _exempt_diff, [])
+
+
# --------------------------------------------------------------- markdown links
# Nothing checked these, and the README ships to PyPI and to the model card. Only
# targets inside the repository are checked: external URLs would make the suite depend